Codex Autoresearch Skill — A self-directed iterative system for Codex that continuously cycles through: modify, verify, retain or discard, and repeat indefinitely. Inspired by Karpathy’s autoresearch concept.
# Add to your Claude Code skills
git clone https://github.com/leo-lilinxiao/codex-autoresearchGuides for using ai agents skills like codex-autoresearch.
Turn a repo-level goal into a controlled loop:
inspect -> change one thing -> verify -> keep or revert -> repeat
Codex supplies the engineering judgment. The bundled control script supplies strict Git boundaries, measurement, rollback, state, and logs.
references/workflow.md for every invocation, including status, history, report, stop, and resume.references/experiment.md before starting or continuing an active run.references/background.md only for a background run.Resolve commands from this skill's own directory as <skill-root>/scripts/autoresearch.py. Never assume the target repository contains the script.
Require one Git repository root. If the task spans repositories, ask the user to choose one run per repository.
Check for autoresearch-results/run.json with:
python3 <skill-root>/scripts/autoresearch.py status --repo <repo>
not_initialized is fresh. Any other status or schema error must be surfaced; do not infer state from other files.
For a fresh run, inspect the repo and propose:
Run candidate measurement commands read-only if needed, then show one concise confirmation. Include the baseline, target, scope, commands, mode, and the fact that each trial is committed and failed trials are reverted.
Do not write project files, initialize artifacts, create a Goal, or launch a controller before clear user approval such as go.
After approval, use the exact confirmed values.
Initialize once:
python3 <skill-root>/scripts/autoresearch.py init \
--repo <repo> --goal <goal> --scope <path> \
--metric-name <name> --direction <lower|higher> \
--verify <command> [--metric-key <key>] --target <number> \
[--guard <command>] [--max-iterations <n>]
Then call get_goal. Reuse a matching unfinished Goal, otherwise call create_goal. The Goal objective must identify this as codex-autoresearch, include the returned run id, metric and target, and say to continue the validated experiment loop until terminal status. If a different unfinished Goal exists, stop and explain the conflict. Official Codex Goal continuation owns foreground persistence; this skill does not install hooks or modify Codex configuration.
If Goal tools are unavailable, do not claim the foreground run can continue autonomously across turns. Explain that the installed Codex does not expose the required Goal capability.
Launch once with the same configuration:
python3 <skill-root>/scripts/autoresearch.py launch \
--repo <repo> --goal <goal> --scope <path> \
--metric-name <name> --direction <lower|higher> \
--verify <command> [--metric-key <key>] --target <number> \
[--guard <command>] [--max-iterations <n>] \
--execution-policy <danger-full-access|workspace-write>
Background defaults to danger-full-access; show this in the confirmation. Use workspace-write only when the user explicitly prefers the sandbox and accepts that Git operations may be restricted. Do not create a Codex Goal for background runs.
After a successful launch, report the run id, baseline, controller PID, results path, and status command. Do not poll unless asked.
For each foreground iteration:
Read validated status and recent events.
Inspect evidence and choose one focused hypothesis that differs from discarded attempts.
Modify only confirmed scopes. Do not manually commit, revert, or edit autoresearch-results/.
Finalize exactly once:
python3 <skill-root>/scripts/autoresearch.py finish \
--repo <repo> --description <short-description>
finish checks scope and Git provenance, creates the trial commit, runs the metric and guard, keeps an improvement, reverts a failed trial, appends the audit event, and marks the run complete when the target is reached.
Continue immediately while status is active. On complete, verify status, call update_goal(status="complete"), and summarize the baseline, final metric, iterations, and retained commits.
Use block only when progress truly requires external input or an environment change, and only after the same blocker has prevented progress on three consecutive Goal turns:
python3 <skill-root>/scripts/autoresearch.py block --repo <repo> --reason <reason>
Then call update_goal(status="blocked"). A failed hypothesis, difficult bug, or lack of immediate improvement is not a blocker.
history --repo <repo>; use --format tsv only for tabular export.report --repo <repo> and return its generated path. Both views validate the complete event history; neither is runtime state.status, resume the matching official Goal, and continue.status, stop, or resume: use the corresponding script command. Resume requires a user note or new direction./goal clear. Then ask before archive and initialize the fresh run.complete: never resume it. Archive before a new goal.init-error.json and command logs but no run.json. Report the diagnostic and use explicit archive before retrying; do not treat it as a fresh run.run.json and one append-only state history in events.jsonl.finish; one repository per run.autoresearch-results/ for diagnosis.Last scanned: 5/4/2026
{
"issues": [],
"status": "PASSED",
"scannedAt": "2026-05-04T06:42:28.449Z",
"semgrepRan": false,
"npmAuditRan": true,
"pipAuditRan": true
}Tell Codex what measurable result you want. Codex inspects the repository, confirms the experiment with you, changes one thing, verifies it, keeps improvements, reverts failures, and repeats until the target is reached.
Autoresearch works for test failures, coverage, type errors, warnings, latency, binary size, reproducible security findings, and any other outcome a command can measure.
Install from Codex:
$skill-installer install https://github.com/leo-lilinxiao/codex-autoresearch
Open a clean Git repository with Full Access:
codex --dangerously-bypass-approvals-and-sandbox
Then invoke the skill:
You: $codex-autoresearch
Reduce `python3 scripts/score.py` error_count to 0.
Codex: Baseline: 5
Target: 0 (lower is better)
Scope: src/
Verify: python3 scripts/score.py, JSON key error_count
Guard: python3 -m pytest -q
Run in foreground or background?
You: Background. Go.
Codex launches the confirmed run. No Codex configuration changes or special prompt syntax are required.
See Installation for manual and development installs.
inspect evidence
|
change one focused thing
|
commit and measure
|
+-- improved + guard passes --> keep
|
+-- otherwise ---------------> revert
|
append an audit event
|
repeat until target
The control script owns commits, verification, rollback, and state. Codex owns the hypotheses and code changes.
| Foreground | Background | |
|---|---|---|
| Runs in | Current Codex task | Detached controller |
| Continuation | Official Codex Goal | One codex exec worker per iteration |
| Best for | Watching and steering live | Long or overnight runs |
| Control | Codex Goal pause/resume | Ask $codex-autoresearch for status, stop, or resume |
Foreground and background use the same experiment rules. A run uses one mode at a time. Foreground continuation uses a Codex Goal; background continuation belongs to the detached controller.
Before the first write, Codex shows:
Initialization requires a clean named Git branch. One run manages one repository.
Run artifacts live in autoresearch-results/ and stay uncommitted:
| Path | Purpose |
|---|---|
run.json |
Immutable confirmed configuration |
events.jsonl |
Append-only baseline, iteration, stop, and completion history |
logs/ |
Full metric, guard, and background worker output |
runtime.json |
Background process state |
runtime.log |
Background controller lifecycle events |
report.html |
Optional, regenerated visual snapshot |
events.jsonl is the state history. Missing, malformed, contradictory, or partial state is an error; the skill never guesses a result from old files or conversational memory.
Ask the skill to show the validated experiment history:
$codex-autoresearch show experiment history
Codex Autoresearch
Run: 0a516883 Status: complete Mode: foreground
Metric: error_count 2 -> 0 Target: 0 (lower is better)
SEQ ITER EVENT PREVIOUS TRIAL RETAINED DESCRIPTION
--- ---- -------- -------- ----- -------- ------------------------------------
0 0 baseline - - 2 Initial measurement
1 1 discard 2 3 2 Broaden parser fallback
2 2 keep 2 1 1 Fix nested parser branch
3 3 keep 1 0 0 Remove final parser error
4 3 complete - - 0 retained metric satisfies the target
The same validated events can be exported as TSV or rendered as a self-contained static report:
$codex-autoresearch export experiment history as TSV
$codex-autoresearch generate an HTML report
The report is written to autoresearch-results/report.html. It is a replaceable snapshot, not runtime state.
git revert.complete only when the retained metric reaches the confirmed target.This strictness is intentional. Silent recovery makes long autonomous runs impossible to trust.
The verify command must exit successfully and place one finite number on its final non-empty stdout line. It may instead print a JSON object on that line when Codex names one numeric key explicitly.
7
{"error_count": 7, "passed": 12}
Use a guard for behavior the metric does not protect, such as a test suite around a latency benchmark. The guard must pass at baseline.
| Guide | Contents |
|---|---|
| Installation | Install, update, and verify the skill |
| User Guide | Configuration, lifecycle, state, and troubleshooting |
| Examples | Practical prompts and metric patterns |
| Contributing | Architecture and validation for contributors |
Does installation change my Codex settings?
No. Installation copies the skill files. Use a current Codex release so foreground runs can use the built-in Goal capability.
Why Full Access?
Each iteration creates or reverts a Git commit. Restricted sandboxes may block writes under .git. Background runs therefore default to Full Access; workspace-write remains an explicit option when its limitations are acceptable.
Can I stop and resume?
Yes. Interrupt or pause a foreground Goal. For background, invoke $codex-autoresearch and ask for status, stop, or resume with a new direction.
Can it run without Git or across several repos?
No. Git is the experiment memory and rollback boundary. Use one run per repository so commit ownership and metrics remain unambiguous.
Is this only for small changes?
No. One experiment should test one coherent hypothesis. Its size should match the hypothesis, while still being independently measurable and reversible.
Inspired by Karpathy's autoresearch, generalized for Codex and software repositories.
@misc{codex-autoresearch,
author = {Li, Linxiao},
title = {Codex Autoresearch: Autonomous Goal-Driven Experimentation for Codex},
year = {2026},
publisher = {GitHub},
url = {https://github.com/leo-lilinxiao/codex-autoresearch}
}
GitHub also reads CITATION.cff for its Cite this repository menu.
MIT, see LICENSE.
codex-autoresearch is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by leo-lilinxiao. Codex Autoresearch Skill — A self-directed iterative system for Codex that continuously cycles through: modify, verify, retain or discard, and repeat indefinitely. Inspired by Karpathy’s autoresearch concept. It has 2,111 GitHub stars.
Yes. codex-autoresearch passed SkillsLLM's automated security scan — a dependency vulnerability audit plus prompt-injection heuristics — with no high-severity issues. You can read the full report in the Security Report section on this page.
Clone the repository with "git clone https://github.com/leo-lilinxiao/codex-autoresearch" and add it to your Claude Code skills directory (see the Installation section above). codex-autoresearch ships a SKILL.md manifest, so compatible agents can discover and load it automatically.
codex-autoresearch is primarily written in Python. It is open-source under leo-lilinxiao on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh codex-autoresearch against similar tools.
No comments yet. Be the first to share your thoughts!
Based on votes and bookmarks from developers who liked this skill