Back/Engineering/Codex/GitHub Copilot
AdvancedEngineering

Build a Self-Improving AI to Generate Agent Skills in Codex

Use a Codex Automation to create a 'meta-agent' that analyzes your codebase, identifies opportunities for new reusable agent skills, and then spawns sub-agents to automatically test and validate those new skills.

Build a Self-Improving AI to Generate Agent Skills in Codex

From 19:00 to 25:27, Claire builds a weekly Codex loop that inspects recent work, identifies reusable skills, and uses subagents to produce them. Clip range: 19:00 to 25:27.

Before you start

What you need

  • Codex account with automation templates enabled
  • GitHub repository with recent pull request history
  • Weekly automation schedule
  • Permission to create agent threads and update the skill library
  • Repository main branch for validation testing

What you’ll make

A validated set of reusable agent skills with test results recorded against the repository base branch.

Tools used

Step by step

The workflow

Follow the sequence once, then adapt the prompts, checks, and handoffs to your own setup.

4 steps

Step01

Customize the 'Suggest Skills' Automation

In Codex, select the 'From recent PRs and reviews suggest next skills to deepen' automation template. Configure the automation to run on a recurring schedule, such as weekly on Fridays at 10:00 a.m.

Step02

Enhance the Prompt with a Validation Loop

Modify the template's prompt to instruct the agent to identify potential new skills, such as those from a command line tool, and then validate them. The prompt should require the main agent to spawn a sub agent for each potential skill, giving it a specific goal to test the skill against the repository's main branch.

Example prompt
If you identify a skill, spin up its own thread and use that skill... validated against the base branch of the repo. We want to confirm that the skill actually works and outputs high quality... You should use a goal when validating the skill.
Step03

Run the Automation and Observe Sub-Agents

Run the automation. The main agent will scan your GitHub history and start creating sub agents for each potential skill it identifies. Monitor the chat list in Codex to observe these new sub agents appearing, each assigned a specific goal to validate one skill.

Step04

Review and Implement Validated Skills

After a sub agent completes its goal, it will report whether the new skill is functional. Review the results from each sub agent. For each validated skill, add it to your agent's reusable skill library.

What good looks like

  • Automation launches on the configured weekly schedule
  • Sub-agents are created for each proposed skill
  • Each skill is tested against the repository main branch with a defined goal
  • Validated skills are added to the reusable skill library

Build your next product with ChatPRD

Turn an idea into a PRD, user stories, and a plan.

Try ChatPRD free

After the steps

Runbook notes

How to recover when the loop fails and where human judgment helps.

Recover

If it goes sideways

Suggested skills fail on the repository base branch
Record the failing commands and restrict the skill to supported environments
Sub-agent validation lacks measurable success checks
Define explicit repository tasks such as passing tests or successful builds
Automation analyzes stale pull request data
Limit scans to merged PRs from a recent date range

Start shipping
better products.

Join 100,000+ product managers who use ChatPRD to write better docs, align teams faster, and build products users love.

Free to start
No credit card
SOC 2 certified
Enterprise ready