Master Loop Engineering: Complete Configuration Guide for Claude Code, Codex, and Opencode
This guide provides a comprehensive walkthrough of Loop Engineering configuration, covering file layouts, CLAUDE.md and AGENTS.md templates, scheduling commands, unique features, cross‑tool migration steps, and reusable Skill files for Claude Code, Codex, and Opencode.
Configuration Quick Reference
Dimensions
Project configuration files: .claude/CLAUDE.md, .codex/AGENTS.md, AGENTS.md (Opencode)
Skill directories (project level): .claude/skills/, .codex/skills/, skills/ User‑level skill directory: ~/.claude/skills/, ~/.codex/skills/, ~/.opencode/skills/ State file: STATE.md Loop configuration file: LOOP.md Scheduler commands: /loop 1d, /schedule, /goal Important Reminder : Skill files are compatible across tools. The same SKILL.md can be placed in .claude/skills/, .codex/skills/, and skills/ – the format follows the public standard (agentskills.io).
1. Claude Code Configuration
1.1 Where to place configuration files
project-root/
├── .claude/
│ ├── CLAUDE.md # project rules (loop constitution)
│ ├── skills/
│ │ ├── loop-triage/ # SKILL.md – triage skill
│ │ ├── minimal-fix/ # SKILL.md – minimal fix skill
│ │ └── loop-verifier/ # SKILL.md – verifier skill
│ └── agents/
│ ├── implementer.md # implementer Agent
│ └── reviewer.md # reviewer Agent
├── STATE.md # loop memory
└── LOOP.md # loop configuration1.2 CLAUDE.md template
# CLAUDE.md — Loop Constitution
## Project Rules
- Language: TypeScript / Python
- Test: `npm test`, `pytest`
- Build: `npm run build`
## Loop Modes
- Initial L1 report mode, no automatic code changes
- Each run reads STATE.md first
- Each run writes back to STATE.md
## Safety Boundaries
- No automatic push or merge
- Do not touch .env, auth/, secrets/, payments/
- Code changes must use a git worktree isolation
## Verification
- Any code change must be checked by an independent Verifier
- Verification must run real tests, not just static analysis1.3 Scheduling commands
# L1 — Daily triage (report mode)
/loop 1d $loop-triage # read STATE.md, append results, no code changes
# L2 — Triage + automatic small fixes
/loop 1d $loop-triage # high‑priority small fixes: open worktree → $minimal-fix → $loop-verifier → PR
# /goal — Continue until condition is met
/goal "All tests under test/auth pass, lint is clean"
# /schedule — Schedule via Claude Code web UI
/schedule "Run daily‑triage at 9 am each morning"1.4 Unique Features
Independent /goal judgment model : defaults to Haiku for completion checks; the code‑generation model does not self‑score.
Hooks integration : configure GitHub Actions callbacks in .claude/hooks.json.
MCP ecosystem completeness : native connectors for GitHub, Linear, Slack, Jira, Notion.
2. Codex Configuration
2.1 Where to place configuration files
project-root/
├── .codex/
│ ├── AGENTS.md # project rules
│ └── skills/
│ ├── loop-triage/ # SKILL.md
│ ├── minimal-fix/ # SKILL.md
│ └── loop-verifier/ # SKILL.md
├── STATE.md
└── LOOP.md2.2 AGENTS.md template
# AGENTS.md — Loop Configuration
## Loop Rules
- L1 report mode, no auto‑fix for first two weeks
- Read STATE.md before deciding actions
- Update STATE.md after each run
## Safety
- No push without approval
- Do not modify .env, credentials/, secrets/
- Use git worktree isolation for code experiments
## Budget
- Daily token limit 100k
- >80% usage switches to report‑only mode
- >100% usage skips the run2.3 Scheduling method
Configure scheduling in the web interface (Codex Code → Automations tab):
Open codex.ai/app Navigate to the Automations tab
Select project → write Prompt → choose frequency
Output can be sent to Triage Inbox or written back to STATE.md Automation Prompt Example (L1 triage)
Run loop‑triage Skill. Read STATE.md. Scan recent 24‑hour CI failures and open Issues.
Output a structured priority report, append to project‑root STATE.md.
Do not modify code, only report.Automation Prompt Example (L2 triage + fix)
Run loop‑triage Skill. For high‑priority items that are small fixes:
open worktree → run minimal‑fix Skill → run loop‑verifier Skill → open PR if verification passes.
Mark medium‑risk items as "needs manual review".
Update STATE.md. Do not change unrelated code.2.4 Unique Features
Automations configured via web UI – no need to remember CLI commands.
Triage Inbox for L1 report mode.
Sub‑Agent definitions via TOML files in .codex/agents/.
3. Opencode Configuration
3.1 Where to place configuration files
project-root/
├── AGENTS.md # project rules (root)
├── skills/
│ ├── loop-triage/ # SKILL.md
│ ├── minimal-fix/ # SKILL.md
│ └── loop-verifier/ # SKILL.md
├── STATE.md
└── LOOP.md3.2 AGENTS.md template
# AGENTS.md — Opencode Loop Configuration
## Loop Modes
- L1 report mode, no code changes
- Each run reads STATE.md first
- Each run writes back to STATE.md
## Safety
- No automatic push or merge
- Do not modify .env, secrets/, payments/
- Code changes must use git worktree isolation
## Verification
- All code changes must be checked by an independent Verifier
- Verifier must run real tests3.3 Scheduling method
Opencode does not include a built‑in scheduler; use external cron, systemd timers, or GitHub Actions.
# /etc/cron.d/opencode-daily-triage
# Run triage every weekday at 9 am
0 9 * * 1-5 cd /path/to/project && opencode run "run $loop-triage, read STATE.md, only report" --timeout 300
# L1 – single triage
opencode run "run $loop-triage. Read STATE.md. Append results to STATE.md."
# /goal mode
opencode run "Goal: all test/auth pass. Verifier confirms then stop."
# L2 – triage + fix (manual trigger)
opencode run "run $loop-triage. High‑priority small fix: open worktree → $minimal-fix → $loop-verifier → PR. Update STATE.md."3.4 Unique Features
AGENTS.md is highly flexible – can be placed directly in the project root.
Skill directory structure is simple: skills/<name>/SKILL.md without hidden prefixes.
External scheduling offers high freedom (cron, systemd, GitHub Actions).
Export functionality: opencode export <sessionID> for full session audit.
4. Cross‑Tool Migration Guide
4.1 Directly copy Skill files
# Copy from Claude Code to Opencode
cp -r .claude/skills/loop-triage skills/loop-triage
# Copy from Claude Code to Codex
cp -r .claude/skills/loop-triage .codex/skills/loop-triage
# One‑click sync (if loop‑sync is installed)
npx @cobusgreyling/loop-sync .4.2 Scaffold generation (recommended)
# Generate Claude Code loop
npx @cobusgreyling/loop-init . --pattern daily-triage --tool claude
# Generate Codex loop
npx @cobusgreyling/loop-init . --pattern daily-triage --tool codex
# Generate Opencode loop
npx @cobusgreyling/loop-init . --pattern daily-triage --tool opencode4.3 Cross‑tool mapping (summary)
Start daily loop
Claude Code: /loop 1d <prompt> Codex: configure via Automations page
Opencode: cron + opencode run Continuous goal
All tools: /goal <condition> (Opencode uses opencode run "Goal: …")
Invoke Skill
Claude Code & Codex: $skill-name Opencode: reference in prompt
Define sub‑Agent
Claude Code: .claude/agents/*.md Codex: .codex/agents/*.toml Opencode: opencode agent <name> Set MCP
Claude Code: .claude/settings.json Codex: apply settings via UI
Opencode: opencode.json Token budget
All tools use loop-budget.md Run log
All tools write to
loop-run-log.md5. Three Reusable Skill Files
loop‑triage (triage)
---
name: loop-triage
description: >
Triage CI failures, Issues and recent commits from the last 24 hours.
Produce a structured priority report for the loop to consume.
Write results to STATE.md.
---
# Loop Triage Skill
You are a triage Agent. Output a priority list.
## Input (provided by loop)
- CI/test failures in the last 24 h
- Open Issues assigned to the owner
- Commits to main in the last 24‑48 h
- Current STATE.md
## Output format
### 1. High priority (act immediately)
- One‑line description
- Why it matters
- Suggested next loop step
### 2. Observation items
### 3. Noise / ignore
### 4. State updateminimal‑fix (minimal fix)
---
name: minimal-fix
description: >
Produce the smallest code change that resolves a specific issue.
Do not modify unrelated code or perform refactoring.
---
# Minimal Fix Skill
Only fix a single identified problem with the minimal diff.
## Process
1. Confirm root cause
2. Change only the necessary parts
3. Run relevant tests
4. Output what changed, why, and which tests ran
## Rules
- One problem per invocation
- Do not touch prohibited paths
- If not using a worktree, require isolationloop‑verifier (independent verification)
---
name: loop-verifier
description: >
Independently verify code changes produced by the loop.
Look for reasons to reject; only accept with solid evidence.
Run real tests.
---
# Loop Verifier Skill
Default stance: reject unless evidence is sufficient.
## Checklist
1. Scope: only the intended files were changed
2. Intent: truly solves the declared problem
3. Tests: executed tests and reported results
4. No cheating: no test skipping
5. Risk: medium‑high risk items should be flagged for manual review6. Quick‑Start Checklist
Write .claude/CLAUDE.md (Claude Code), .codex/AGENTS.md (Codex), or AGENTS.md (Opencode) with project rules.
Place the three SKILL.md files into the respective skills/ directories ( .claude/skills/, .codex/skills/, skills/).
Create a STATE.md template for each tool.
Run the first loop: /loop 1d $loop-triage (Claude Code), configure an Automation prompt (Codex), or set up a cron job calling opencode run "run $loop-triage, only report" (Opencode).
After a week, review STATE.md and fine‑tune the configuration.
Add $minimal-fix and $loop-verifier to the workflow for L2 automation.
Run health checks: npx @cobusgreyling/loop-audit . (same for all tools).
By following these steps you can set up a robust, AI‑driven development loop that triages work, applies minimal fixes, and verifies changes across Claude Code, Codex, and Opencode.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Su San Talks Tech
Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
