
Coding Router
- 13 installs
- 82 repo stars
- Updated August 2, 2026
- aaaaqwq/claude-code-skills
coding-router is a Claude Code skill that routes plan-first coding, plan-review, and PR-review requests to plan-issue or coding-agent siblings behind approval gates.
About
coding-router is a Claude Code skill that acts as a compatibility entry point for plan-first coding work, routing requests to plan-issue or coding-agent sibling skills. A developer uses it so planning, plan review, and PR review requests dispatch to the right behavior, and so implementation always produces a plan and waits for an explicit APPROVE before any writes. It defines command aliases, a run-event status contract, and non-negotiable approval gates.
- Compatibility entry skill that routes plan-first coding work to plan-issue or coding-agent siblings
- Enforces plan-before-write gates: no writes, installs, commits, or PRs before explicit APPROVE
- Maps channel aliases (/coding, /plan, /plan-review, /review_pr) and defines a run-event status contract
Coding Router by the numbers
- 13 all-time installs (skills.sh)
- Ranked #11,355 of 16,556 AI & Agent Building skills by installs in the Skillselion catalog
- Data as of Aug 3, 2026 (Skillselion catalog sync)
coding-router capabilities & compatibility
- Capabilities
- agent routing · plan first gating · pr review · approval gate
- Works with
- github
- Use cases
- orchestration · planning · code review
What coding-router says it does
This file exists for backward compatibility with single-entry skill setups (for example `/coding`).
Never write files, install packages, commit, or open PRs before explicit `APPROVE`.
npx skills add https://github.com/aaaaqwq/claude-code-skills --skill coding-routerAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 13 |
|---|---|
| repo stars | ★ 82 |
| Last updated | August 2, 2026 |
| Repository | aaaaqwq/claude-code-skills ↗ |
What it does
Route plan-first coding, plan-review, and PR-review requests to the right sibling skill behind approval gates.
Who is it for?
Routing coding requests to plan-first vs implementation behavior behind an APPROVE gate
Skip if: Direct implementation without planning, or defaulting to bypass flags
When should I use this skill?
A user asks to plan, scope, review a plan, or review a PR via /coding, /plan, or /review_pr aliases
By the numbers
- Routes 6 channel aliases (/coding, /plan, /plan-review, /plan-review-live, /review_pr)
- 3 non-negotiable approval gates
- emits 5 run-event types (start, heartbeat, interrupted, failed, done)
Files
Coding Router Skill 💻
This file exists for backward compatibility with single-entry skill setups (for example /coding). Canonical sibling skills live at:
skills/plan-issue/SKILL.mdskills/coding-agent/SKILL.md
Routing Rules
1. If user asks to plan/scope/estimate/design, follow plan-issue behavior. 2. For non-trivial implementation requests, produce a plan first and wait for exact APPROVE before any writes. 3. Only after APPROVE, follow coding-agent behavior with ACP-aware execution routing and CLI fallback.
Command Routing (Channel Aliases)
When invoked via channel aliases:
/coding→ use this compatibility skill as router./plan→ route directly toplan-issuebehavior./plan-review→ route to plan review flow usingscripts/plan-review./plan-review-live→ route to interactive plan review checkpoints usingscripts/plan-review-live(Lobster in-repo workflow first, legacy fallback)./review_pr→ route to review flow usingreferences/reviews.md.
Runtime Status Contract
When wrappers are used for planning/review:
- Emit
RUN_EVENT startat run start. - If the run exceeds 30s, emit
RUN_EVENT heartbeatevery 20s. - If interrupted or timed out, emit
RUN_EVENT interruptedimmediately with exit code. - On non-interruption failure, emit
RUN_EVENT failed. - On success, emit
RUN_EVENT done.
Non-Negotiable Gates
1. Never write files, install packages, commit, or open PRs before explicit APPROVE. 2. Never default to bypass flags (--yolo, --dangerously-skip-permissions). 3. Use bypass flags only when the user explicitly asks to bypass approvals.
name: Bug report
description: Report a defect or unexpected behavior in this skill repository.
title: "bug: <symptom> when <condition>"
labels:
- bug
- needs triage
body:
- type: markdown
attributes:
value: |
Thanks for filing this report. Keep it concise, reproducible, and evidence-based.
- type: textarea
id: summary
attributes:
label: Summary
description: One-sentence statement of what is broken.
placeholder: Wrapper rejects valid CLI flags on macOS.
validations:
required: true
- type: textarea
id: repro
attributes:
label: Steps to reproduce
description: Provide the shortest deterministic repro path.
placeholder: |
1. cd /path/to/repo
2. export FOO=bar
3. ./scripts/...
validations:
required: true
- type: textarea
id: expected
attributes:
label: Expected behavior
description: What should happen if the bug does not exist.
validations:
required: true
- type: textarea
id: actual
attributes:
label: Actual behavior
description: What happened instead, including user-visible errors.
validations:
required: true
- type: input
id: version
attributes:
label: Skill version/ref
description: Exact branch/commit/tag tested.
placeholder: main@<sha>
validations:
required: true
- type: input
id: os
attributes:
label: Operating system
description: OS and shell where this occurs.
placeholder: macOS 15.x + zsh / Ubuntu 24.04 + bash
validations:
required: true
- type: input
id: tooling
attributes:
label: Related tool versions
description: Include versions for codex/gh/claude if relevant.
placeholder: codex --version, gh --version, claude --version
- type: textarea
id: logs
attributes:
label: Logs, screenshots, and evidence
description: Include redacted logs/screenshots/recordings that prove the behavior.
render: shell
- type: textarea
id: impact
attributes:
label: Impact and severity
description: |
Explain who is affected, severity, frequency, and practical consequence.
Include:
- Affected users/workflows
- Severity (annoying, blocks workflow, data risk, etc.)
- Frequency (always/intermittent/edge case)
- Consequence (failed reviews, incorrect fallback, extra manual work, etc.)
- type: textarea
id: additional_information
attributes:
label: Additional information
description: Any context that helps triage but does not fit above.
- type: checkboxes
id: confirmations
attributes:
label: Confirmations
options:
- label: I reproduced this on the latest `main`.
required: true
- label: I searched existing issues and did not find a duplicate.
required: true
blank_issues_enabled: false
contact_links:
- name: Security disclosure
url: https://github.com/kesslerio/coding-agent-openclaw-skill/security/advisories/new
about: Report security vulnerabilities privately.
name: "📗 Documentation issue"
description: Tell us if documentation is missing, incorrect, or confusing.
labels:
- docs
- needs triage
body:
- type: markdown
attributes:
value: |
Thank you for submitting a documentation issue.
- type: dropdown
id: issue_type
attributes:
label: What is the type of issue?
multiple: true
options:
- Documentation is missing
- Documentation is incorrect
- Documentation is confusing
- Example command is not working
- Something else
validations:
required: true
- type: textarea
id: details
attributes:
label: What is the issue?
description: Explain what should be changed.
validations:
required: true
- type: textarea
id: locations
attributes:
label: Where did you find it?
description: Provide file paths and/or URLs.
placeholder: README.md, references/quick-reference.md
validations:
required: true
name: Feature request
description: Propose a capability or workflow improvement.
title: "feat: <capability> (for <surface>)"
labels:
- enhancement
- needs triage
body:
- type: markdown
attributes:
value: |
Help us evaluate this request with concrete use cases and tradeoffs.
- type: textarea
id: summary
attributes:
label: Summary
description: One-line statement of the requested capability.
placeholder: Add automatic base-branch detection helper for review commands.
validations:
required: true
- type: textarea
id: problem
attributes:
label: Problem to solve
description: What user pain this solves and why current behavior is insufficient.
validations:
required: true
- type: textarea
id: proposed_solution
attributes:
label: Proposed solution
description: Desired behavior/API/docs changes with as much specificity as possible.
validations:
required: true
- type: textarea
id: alternatives
attributes:
label: Alternatives considered
description: Other approaches considered and why they are weaker.
- type: textarea
id: impact
attributes:
label: Impact
description: |
Explain who is affected, severity/urgency, frequency, and practical consequence.
Include:
- Affected users/workflows
- Severity (annoying, blocks workflow, etc.)
- Frequency (always/intermittent/edge case)
- Consequence (delays, errors, extra manual work, etc.)
validations:
required: true
- type: textarea
id: acceptance
attributes:
label: Acceptance criteria
description: Checklist that can be verified by tests/commands.
placeholder: |
- [ ] ...
- [ ] ...
validations:
required: true
- type: textarea
id: evidence
attributes:
label: Evidence/examples
description: Prior art, links, snippets, or metrics.
- type: textarea
id: additional_information
attributes:
label: Additional information
description: Extra context, constraints, or references not covered above.
name: "🧹 Task / chore"
description: Track maintenance/refactor/process work.
title: "TODO: <cleanup> after <dependency>"
labels:
- chore
- needs triage
body:
- type: markdown
attributes:
value: |
Use this for concrete, non-feature work with clear verification steps.
- type: textarea
id: objective
attributes:
label: Objective
description: What needs to be done and why now?
validations:
required: true
- type: textarea
id: scope
attributes:
label: Scope
description: Explicit in-scope and out-of-scope items.
placeholder: |
In scope:
- ...
Out of scope:
- ...
validations:
required: true
- type: textarea
id: plan
attributes:
label: Execution plan
description: Ordered implementation steps.
placeholder: |
1. ...
2. ...
3. ...
validations:
required: true
- type: textarea
id: verification
attributes:
label: Verification commands
description: Exact commands and expected outcomes.
render: shell
validations:
required: true
- type: textarea
id: risks
attributes:
label: Risks and rollback
description: Main risks + how to revert safely.
validations:
required: true
- type: checkboxes
id: done_definition
attributes:
label: Definition of done
options:
- label: Scope, plan, and verification are specific and testable.
required: true
- label: Risk and rollback plan is documented.
required: true
Summary
Describe the problem and fix in 2-5 bullets:
- Problem:
- Why it matters:
- What changed:
- What did not change (scope boundary):
Change Type (select all)
- [ ] Bug fix
- [ ] Feature
- [ ] Refactor
- [ ] Docs
- [ ] Security hardening
- [ ] Chore/infra
Scope (select all touched areas)
- [ ] Scripts/wrappers
- [ ] Skill docs/references
- [ ] Issue/PR templates or community files
- [ ] CI/workflows
- [ ] Other
Linked Issue/PR
- Closes #
- Related #
User-visible / Behavior Changes
List user-visible changes (including defaults/config). If none, write None.
Security Impact (required)
- New permissions/capabilities? (
Yes/No) - Secrets/tokens handling changed? (
Yes/No) - New/changed network calls? (
Yes/No) - Tool execution surface changed? (
Yes/No) - If any
Yes, explain risk + mitigation:
Repro + Verification
Environment
- OS:
- Shell/runtime:
- Relevant tool versions:
Steps
1. 2. 3.
Expected
-
Actual
-
Evidence
Attach at least one:
- [ ] Failing output before + passing output after
- [ ] Log snippets
- [ ] Screenshot/recording
- [ ] N/A (docs-only or template-only change)
Human Verification (required)
What you personally verified (not just CI), and how:
- Verified scenarios:
- Edge cases checked:
- What you did not verify:
Compatibility / Migration
- Backward compatible? (
Yes/No) - Config/env changes? (
Yes/No) - Migration needed? (
Yes/No) - If yes, exact upgrade steps:
Failure Recovery
- How to disable/revert this change quickly:
- Files/config to restore:
- Known bad symptoms reviewers should watch for:
Risks and Mitigations
- Risk:
- Mitigation:
AI Assistance
- AI-assisted: yes/no
- Tools/agents/models used:
- Testing level: untested/lightly tested/fully tested
- Human understanding confirmation: yes/no
name: PR Policy Gates
on:
pull_request_target:
branches:
- main
- master
types:
- opened
- edited
- synchronize
- reopened
- ready_for_review
- labeled
- unlabeled
permissions:
contents: read
pull-requests: read
jobs:
policy-checks:
uses: ./.github/workflows/reusable-pr-checks.yml
with:
pr_number: ${{ github.event.pull_request.number }}
pr_title: ${{ github.event.pull_request.title }}
pr_body: ${{ github.event.pull_request.body || '' }}
head_ref: ${{ github.event.pull_request.head.ref }}
base_ref: ${{ github.event.pull_request.base.ref }}
author_login: ${{ github.event.pull_request.user.login }}
labels_json: ${{ toJson(github.event.pull_request.labels) }}
name: Reusable PR Checks
on:
workflow_call:
inputs:
pr_number:
description: Pull request number
required: true
type: string
pr_title:
description: Pull request title
required: true
type: string
pr_body:
description: Pull request body
required: true
type: string
head_ref:
description: Source branch name
required: true
type: string
base_ref:
description: Target branch name
required: true
type: string
author_login:
description: PR author login
required: false
default: ""
type: string
labels_json:
description: JSON array of PR labels
required: false
default: "[]"
type: string
concurrency:
group: pr-checks-${{ github.repository }}-${{ inputs.pr_number }}
cancel-in-progress: true
jobs:
policy-context:
name: Policy Context
runs-on: ubuntu-latest
outputs:
exempt: ${{ steps.exemption.outputs.exempt }}
reason: ${{ steps.exemption.outputs.reason }}
steps:
- name: Evaluate policy exemptions
id: exemption
env:
AUTHOR_LOGIN: ${{ inputs.author_login }}
LABELS_JSON: ${{ inputs.labels_json }}
run: |
set -euo pipefail
labels_compact="$(printf '%s' "${LABELS_JSON}" | tr -d '[:space:]')"
exempt="false"
reason=""
if [[ "${AUTHOR_LOGIN}" == "dependabot[bot]" || "${AUTHOR_LOGIN}" == "renovate[bot]" ]]; then
exempt="true"
reason="bot allowlist (${AUTHOR_LOGIN})"
elif [[ "${labels_compact}" == *"\"name\":\"policy-exempt\""* ]]; then
exempt="true"
reason="policy-exempt label"
fi
echo "exempt=${exempt}" >> "$GITHUB_OUTPUT"
echo "reason=${reason}" >> "$GITHUB_OUTPUT"
exemption-notice:
name: Policy Exemption Notice
runs-on: ubuntu-latest
needs:
- policy-context
if: needs.policy-context.outputs.exempt == 'true'
steps:
- name: Emit exemption warning
env:
REASON: ${{ needs.policy-context.outputs.reason }}
PR_BODY: ${{ inputs.pr_body }}
run: |
set -euo pipefail
echo "::warning title=Policy Gate Exempted::Policy checks bypassed (${REASON})."
if [[ "${REASON}" == "policy-exempt label" ]]; then
echo "::warning title=Justification Required::Include policy exemption rationale in the PR body."
if ! printf '%s' "${PR_BODY}" | grep -Eiq 'policy[ -]?exempt(ion)?|justification|emergency'; then
echo "::warning title=Missing Justification::No exemption rationale detected in PR body text."
fi
fi
branch-policy:
name: Branch Policy
runs-on: ubuntu-latest
needs:
- policy-context
if: needs.policy-context.outputs.exempt != 'true'
steps:
- name: Branch policy gate
env:
BRANCH_NAME: ${{ inputs.head_ref }}
run: |
set -euo pipefail
branch_regex='^kesslerio/(feat|fix|docs|chore|refactor|test|style)/[a-z0-9][a-z0-9._/-]*$'
if [[ ! "${BRANCH_NAME}" =~ ${branch_regex} ]]; then
echo "❌ Branch policy violation"
echo "Observed: ${BRANCH_NAME}"
echo "Expected regex: ${branch_regex}"
echo "Remediation examples:"
echo "- kesslerio/feat/add-pr-policy-gates"
echo "- kesslerio/fix/timeout-cleanup"
exit 1
fi
echo "✅ Branch policy passed: ${BRANCH_NAME}"
title-policy:
name: PR Title Policy
runs-on: ubuntu-latest
needs:
- policy-context
if: needs.policy-context.outputs.exempt != 'true'
steps:
- name: Title policy gate
env:
PR_TITLE: ${{ inputs.pr_title }}
run: |
set -euo pipefail
title_regex='^(feat|fix|docs|style|refactor|test|chore)(\([a-z0-9._/-]+\))?: [^ ].+$'
if [[ ! "${PR_TITLE}" =~ ${title_regex} ]]; then
echo "❌ PR title policy violation"
echo "Observed: ${PR_TITLE}"
echo "Expected regex: ${title_regex}"
echo "Remediation examples:"
echo "- feat(ci): add reusable pr policy workflow"
echo "- docs(reviews): enforce config safety checklist"
exit 1
fi
echo "✅ PR title policy passed: ${PR_TITLE}"
linked-issue-policy:
name: Linked Issue Policy
runs-on: ubuntu-latest
needs:
- policy-context
if: needs.policy-context.outputs.exempt != 'true'
steps:
- name: Linked issue gate
env:
PR_BODY: ${{ inputs.pr_body }}
run: |
set -euo pipefail
issue_regex='\b(closes|fixes|resolves|relates to)\s+#[0-9]+\b'
if ! printf '%s' "${PR_BODY}" | grep -Eiq "${issue_regex}"; then
echo "❌ Linked issue policy violation"
echo "Observed: no required issue reference pattern in PR body"
echo "Expected regex (case-insensitive): ${issue_regex}"
echo "Remediation examples:"
echo "- Closes #33"
echo "- Fixes #12"
echo "- Relates to #101"
exit 1
fi
echo "✅ Linked issue policy passed"
name: Wrapper Smoke Tests
on:
pull_request:
push:
branches:
- main
- master
jobs:
wrappers:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install shellcheck
run: sudo apt-get update && sudo apt-get install -y shellcheck
- name: Bash syntax check
run: |
set -euo pipefail
while IFS= read -r script; do
[[ -f "$script" ]] || continue
bash -n "$script"
done < <(git ls-files scripts)
- name: Shellcheck
run: |
set -euo pipefail
while IFS= read -r script; do
[[ -f "$script" ]] || continue
shellcheck "$script"
done < <(git ls-files scripts)
- name: Codex doc drift checks
run: ./scripts/doc-drift-check
- name: Wrapper smoke tests
run: ./scripts/smoke-wrappers.sh
Current date: 2026-02-19
Purpose
High-signal instructions for coding agents in this repository. Keep this file concise; move long examples and deep procedures to README.md and references/.
Scope
- Applies to the repository root and descendants.
- Add nested
AGENTS.mdfiles only when a subdirectory needs different rules. CLAUDE.mdshould remain a symlink to this file.
Language
- English only for code, comments, docs, examples, commits, configs, errors, and tests.
Tooling
- Prefer
rgovergrep. - Prefer
fd/treewhen available; fall back tofind/ls -Rwhen missing. - Resolve Claude CLI in this order:
~/.claude/local/claude(if present), otherwiseclaudefromPATH. - Prefer non-interactive command execution.
Runtime Reality Check
- Before running major workflows, verify toolchain:
command -v codex && codex --versioncommand -v timeoutcommand -v ghcommand -v claude || test -x ~/.claude/local/claude- If a required binary is missing, stop and report exact install/unblock steps.
Codex Command Canon
- Prefer Codex for implementation and review:
- Implementation:
codex exec "..."(orcodex --yolo exec "..."only in trusted/sandboxed environments) - Resume:
codex exec resume --last - Review:
codex review --base <branch> "custom focus prompt" - Use
--full-autofor sandboxed low-friction automation. - Use
--yoloonly when bypassing sandbox/approvals is explicitly intended.
Workflow
1. Gather context with read-only operations first. 2. For non-trivial work, propose a concise plan with assumptions, risks, and one alternative. 3. Get explicit APPROVE before file writes, package installs, or system changes. 4. After approval, execute end-to-end and report progress, results, and deviations.
Review Routing Contract (Hard Rule)
- Plan artifact reviews must run through wrappers first:
scripts/plan-reviewscripts/plan-review-live- PR/code reviews must run via
codex review --base ...directly orscripts/safe-review.sh. - Never post a manual review summary before the corresponding wrapper/CLI run is attempted.
Verbosity Mode
CODING_AGENT_VERBOSEcontrols execution progress verbosity and is opt-in.- Default behavior is concise when the variable is unset or falsy.
- When enabled, use
Now/Why/Nextprogress updates for active execution. - Verbosity must never delay action once execution is approved and unblocked.
- Status updates are not a pause point: after any progress update, execute the next unblocked step immediately.
- Do not end on a progress-only response when a command can be run in the same turn.
Long-Running Commands
- Ensure
tsxscripts close watchers/timers and callprocess.exit(0). - Wrap long tasks with process-group timeout, e.g.:
timeout -k5s 60s bash -lc 'exec npx --yes tsx scripts/tool-schema-lint.ts'- Avoid
timeout --foreground. - After timeout, verify child processes are stopped; if not, run
pkill -P <wrapper_pid>. - Hard-fail run status contract:
- Emit
RUN_EVENT startwhen a wrapper run begins. - For runs exceeding 30 seconds, emit
RUN_EVENT heartbeatevery 20 seconds. - On interruption/timeouts/signals, emit
RUN_EVENT interruptedimmediately. - On non-interruption failure, emit
RUN_EVENT failed. - Emit
RUN_EVENT doneon success.
Code Standards
- Prefer KISS and YAGNI; avoid speculative abstractions.
- Apply DRY with a three-strikes rule before abstraction.
- Keep modules and classes focused (SRP).
- TypeScript: avoid
any; prefer precise types orRecord<string, unknown>. - Use explicit error handling; never fail silently.
- Import order: node -> external -> internal.
- Use descriptive names and named constants instead of magic numbers.
Review Expectations (Plan/Review Mode)
- Review in this order: Architecture, Code Quality, Tests, Performance.
- For each issue:
- include file/line references,
- present 2-3 options (include do-nothing when reasonable),
- state effort, risk, impact, and maintenance burden per option,
- recommend one option and ask for user decision before implementation.
- Interactive flow:
- Big change: section-by-section with up to 4 top issues per section.
- Small change: one focused question per section.
Testing and Validation
- Reproduce first when debugging.
- Before finalizing, run relevant checks:
- formatting/lint
- typecheck
- unit/integration/e2e tests as applicable
- Report exact commands run and outcomes.
- Explicitly call out checks not run and residual risk.
Documentation Hygiene
- Update
README.mdorreferences/when public behavior/workflow changes. - Final report must summarize files changed, key diffs, and side effects.
- Prefer inclusive language: allowlist/blocklist, primary/replica, main branch.
Humanized Communication Policy
- For user-facing long-form writing (outreach copy, status updates, explanations, docs prose), run a humanization pass by default.
- Preferred invocation in OpenClaw contexts:
/humanizer. - Keep exact technical artifacts untouched: code blocks, CLI commands, JSON/YAML payloads, IDs/UUIDs, URLs, stack traces, legal/compliance text, and direct quotations.
- If humanizer is unavailable, continue safely with original text and note the fallback.
OpenClaw Skill Notes
- Keep each
SKILL.mdAgentSkills-compatible: clearname+description, concise body, references for deep detail. - For OpenClaw compatibility, keep frontmatter keys single-line and keep
metadataas a single-line JSON object when metadata is present.
CLI Drift Check
- Periodically verify docs/scripts against real CLI help:
codex --helpcodex review --helpclaude --help- Update references when flags/behavior drift.
AGENTS.md
Contributing
How to contribute
- Bugs and focused fixes: open a PR.
- New features or architecture changes: open an issue/discussion first.
- Questions: open an issue or discussion.
Before you open a PR
- Search existing issues and PRs first.
- Keep PRs focused; do not mix unrelated concerns.
- Use the issue forms in
.github/ISSUE_TEMPLATE/for new reports and requests.
Branches and commits
- Branch names should be short and descriptive (example:
codex/<topic>). - Prefer commit format
type(scope): subject.
Validation expectations
Include exact commands and outcomes in every PR.
For script changes, run:
while IFS= read -r script; do [[ -f "$script" ]] || continue; bash -n "$script"; done < <(git ls-files scripts)
while IFS= read -r script; do [[ -f "$script" ]] || continue; shellcheck "$script"; done < <(git ls-files scripts)
./scripts/doc-drift-check
./scripts/smoke-wrappers.shWhen wrapper behavior is involved, also run:
./scripts/doctorAI-assisted contributions
AI-assisted PRs are welcome. Be explicit:
- Mark AI assistance in the PR.
- State testing level (untested/lightly tested/fully tested).
- Include prompt/session notes when feasible.
- Confirm you understand the final code and behavior.
PR requirements
Complete all sections in .github/pull_request_template.md, especially:
- Security impact
- Repro + verification
- Human verification
- Compatibility/migration
- Failure recovery
coding-agent Skill Pack 💻
Plan-first OpenClaw skill pack.
Skill Layout
This repo now ships two sibling skills:
skills/plan-issue/SKILL.mdskills/coding-agent/SKILL.md
SKILL.md at repo root is a compatibility entry for single-skill setups.
Behavior Model
1. Use plan-issue for planning/scoping tasks. 2. Wait for explicit APPROVE. 3. Use coding-agent to execute the approved plan with ACP-first routing, then CLI fallback.
Guardrail: no bypass flags (--yolo, --dangerously-skip-permissions) unless explicitly requested.
Review Routing + Run Status Contract
- Plan artifact review: use
./scripts/plan-reviewor./scripts/plan-review-live. - PR/code review: use
codex review --base ...directly or./scripts/safe-review.sh. - Never provide a manual review summary before running the matching wrapper/command.
Long-run wrapper status events (hard-fail policy):
RUN_EVENT startRUN_EVENT heartbeatevery 20s after 30s elapsedRUN_EVENT interruptedon signal/timeout/interruptionRUN_EVENT failedon non-interruption errorsRUN_EVENT doneon success
Usage
In OpenClaw:
/coding
/plan <task>
/plan-review [--plan <path>]
/plan-review-live [--plan <path>]
/review_pr <number|url>CLI wrappers:
# Generate a read-only plan artifact
./scripts/plan --engine codex --repo /path/to/repo "Implement feature X"
# Review latest generated plan (or pass --plan explicitly)
./scripts/plan-review --repo /path/to/repo
# Review with interactive section checkpoints (Architecture -> Code Quality -> Tests -> Performance)
# Default engine: Lobster workflow in this repo (falls back to legacy engine if lobster is unavailable)
./scripts/plan-review-live --repo /path/to/repo
# Non-TTY/chat-safe live review finalization (no interactive prompts)
./scripts/plan-review-live --repo /path/to/repo --decisions "1A,2B,3A,4A" --blocking none
# or
./scripts/plan-review-live --repo /path/to/repo --resolve-file /path/to/decisions.json
# Force legacy engine explicitly
./scripts/plan-review-live --engine legacy --repo /path/to/repo
# Resume a paused Lobster approval run
./scripts/plan-review-live --resume-token <token> --output /path/to/repo/.ai/plan-reviews/<same-file>.md
# Execute an approved plan artifact
# Requires latest plan-review metadata to be ready unless --force is used.
./scripts/code-implement --plan /path/to/repo/.ai/plans/<plan>.mdCommand Map (Telegram/OpenClaw)
These aliases are routing hints at the channel layer. Behavior is enforced by skills.
/coding→ compatibility entry skill (SKILL.md), routes plan-first + execution flow/plan <task>→skills/plan-issue/SKILL.md(plan only, no writes)/plan-review [--plan <path>]→ batch plan review (single-pass full report, marks unresolved blocking decisions)/plan-review-live [--plan <path>]→ Lobster workflow checkpoints by default (in-repoworkflows/plan-review-live.lobster), legacy fallback if Lobster is unavailable; in non-TTY/chat use--decisions/--blockingor--resolve-fileto finalize readiness metadata/review_pr <number|url>→ review workflow with standards checks viareferences/reviews.md
Approval Semantics
APPROVEapplies only to the latest plan in the current conversation context.- Approval is not global, does not carry across unrelated threads/chats, and does not auto-approve future plans.
- If no pending plan exists in context, return:
No pending plan found. Run /plan first. - Plan approval is text-gated via
APPROVE; this workflow does not require a separate "ExitPlanMode" tool.
OpenClaw Setup: Add Coding Skill Slash Commands
To enable this skill’s aliases for your team, add these entries under telegram.customCommands in OpenClaw.
1. Open your OpenClaw JSON config. 2. Find the telegram block and replace or extend customCommands in place. 3. Save the file and restart/reload OpenClaw. 4. Verify in Telegram that commands appear in the bot command list.
[
{ "command": "coding", "description": "Run coding-agent workflow" },
{ "command": "plan", "description": "Plan implementation only (no writes)" },
{ "command": "plan-review", "description": "Review generated plan in read-only mode" },
{ "command": "plan-review-live", "description": "Interactive plan review with decision checkpoints" },
{ "command": "review_pr", "description": "Review PR + standards check" }
]If some commands already exist in your config, keep existing entries and append only missing new ones to avoid overriding other aliases.
Example resolve file for non-TTY finalization:
{
"resolved_decisions": ["1A", "2B", "3A", "4A"],
"blocking_decisions": []
}Requirements
- GitHub CLI (
gh) - One of: Codex CLI (
codex) or Claude Code CLI (claude/~/.claude/local/claude) - GNU
timeoutcommand (coreutils on macOS) - Optional: tmux (wrapper workflows)
Validation
./scripts/doctor
./scripts/smoke-wrappers.shACP-First Wrapper Routing
Execution routing in scripts/safe-fallback.sh is mode-specific:
impl: ACP first (viaacpx), then CLI fallback chainreview:codex review --basefirst, then ACP fallback, then remaining CLI fallback chain
CODING_AGENT_ACP_ENABLE:1(default) or0to skip ACP attemptCODING_AGENT_ACP_AGENT: ACP harness alias (default:codex)CODING_AGENT_ACPX_CMD: executable path override for ACPX binary
Verbosity Configuration
The coding-agent skill supports an opt-in execution progress verbosity mode via CODING_AGENT_VERBOSE.
- Default: off (concise updates)
- On: structured progress updates (
Now,Why,Next) during execution - Scope: progress updates only (not globally longer planning/review prose)
Truthy values (case-insensitive): 1, true, on, yes, verbose
Planning/review wrapper heartbeat settings:
CODING_AGENT_STATUS_PING_SECONDS(default20)CODING_AGENT_LONG_RUN_THRESHOLD_SECONDS(default30)
One-shot example:
CODING_AGENT_VERBOSE=1 ./scripts/code-implement --plan /path/to/repo/.ai/plans/<plan>.mdPersistent OpenClaw gateway setup:
1. Add to ~/.config/systemd/user/secrets.conf: CODING_AGENT_VERBOSE="1" 2. Reload the user unit:
systemctl --user daemon-reload && systemctl --user restart openclaw-gateway.serviceCI Workflows
wrapper-smoke.yml: wrapper syntax, drift, and smoke validation.pr-policy.yml: PR policy caller formain/masterpull requests.reusable-pr-checks.yml: reusable branch/title/linked-issue policy checks with concurrency cancellation.
References
references/WORKFLOW.mdreferences/STANDARDS.mdreferences/tooling.mdreferences/codex-cli.mdreferences/claude-code.mdreferences/reviews.mdreferences/lobster-workflows.md
License
MIT
Claude Code CLI Reference
Detailed reference for Claude Code as a fallback when Codex is unavailable, or as primary CLI for Claude-based workflows.
Plan-First Gate
For non-trivial tasks: 1. Plan first. 2. Wait for explicit APPROVE. 3. Execute with Claude commands after approval.
Contents
- Non-interactive mode flags
- Session resume (non-interactive)
- Model selection
- Permission modes
- Budget controls
- Output formats
- Examples
- Codex → Claude mapping
---
Non-Interactive Mode (-p/--print)
The -p flag runs Claude in non-interactive mode: it processes the prompt and exits.
claude -p "Your prompt here"Note: The -p flag skips workspace trust dialogs. Only use in trusted directories.
---
Flags Reference
| Flag | Description |
|---|---|
-p, --print | Non-interactive mode, print and exit |
--model <model> | Model: sonnet, opus, haiku, or full name |
--permission-mode <mode> | Permission handling (see below) |
--dangerously-skip-permissions | Skip all permission checks |
--max-budget-usd <amount> | Cap API spending |
--fallback-model <model> | Auto-fallback if primary overloaded |
--output-format <format> | Output: text, json, stream-json |
--add-dir <dirs> | Additional directories to allow access |
-c, --continue | Continue most recent conversation |
-r, --resume <id> | Resume specific session |
--resume | Interactive session picker (no ID = browse) |
---
Session Resume (Non-Interactive)
Session resume restores full conversation context from disk. Use this for multi-phase workflows where context must persist across separate CLI invocations.
Continue Most Recent Session
# Continue the last conversation with a new prompt
claude -p -c "Fix the review findings from the previous session"
# Continue without a new prompt (re-runs last context)
claude -p -cResume Specific Session
# Browse sessions interactively to find the ID
claude --resume
# Resume a specific session by ID
claude -p --resume abc123 "Address the security concern raised in review"Session Storage
Sessions persist to ~/.claude/projects/<project>/sessions/. Each session contains the full conversation history, tool calls, and file context.
When to Use Resume
| Scenario | Command |
|---|---|
| Fix review findings | claude -p -c "Fix the issues from code review" |
| Continue implementation | claude -p --resume <id> "Continue implementing the auth module" |
| Follow-up on same PR | claude -p -c "Now add tests for the changes" |
| Unrelated new task | claude -p "New task prompt" (fresh session) |
Multi-Phase Example
# Phase 1: Implement
claude -p --permission-mode acceptEdits "Implement JWT auth middleware"
# Phase 2: Fix review findings (context preserved)
claude -p -c --permission-mode acceptEdits "Fix the review findings: add token expiry check"
# Phase 3: Add tests (context preserved)
claude -p -c --permission-mode acceptEdits "Add unit tests for the JWT middleware"---
Permission Modes
| Mode | Behavior |
|---|---|
default | Prompt for approval (interactive) |
acceptEdits | Auto-accept file edits |
bypassPermissions | Skip all permission checks |
dontAsk | Don't ask, but still enforce permissions |
plan | Planning mode only |
# Auto-accept edits (recommended for automation)
claude -p --permission-mode acceptEdits "Fix the bug"
# Explicit bypass (only when user asks to bypass approvals)
claude -p --permission-mode bypassPermissions "Build the feature"---
Model Selection
# Use Opus for complex tasks
claude -p --model opus "Design the database schema"
# Use Haiku for quick/cheap tasks
claude -p --model haiku "Add a docstring"
# Use Sonnet (default, balanced)
claude -p --model sonnet "Refactor this function"
# With fallback
claude -p --model opus --fallback-model sonnet "Complex task"Models:
opus- Most capable, highest costsonnet- Balanced (default)haiku- Fastest, lowest cost
---
Budget Controls
# Cap spending at $5
claude -p --max-budget-usd 5 "Build a REST API"
# Combine with fallback for cost optimization
claude -p --model opus --fallback-model haiku --max-budget-usd 2 "Review this code"---
Output Formats
# Plain text (default)
claude -p "Summarize this file"
# JSON (single result)
claude -p --output-format json "List the functions in this file"
# Streaming JSON (for real-time processing)
claude -p --output-format stream-json "Analyze this codebase"---
Working Directory
# Add specific directories for file access
claude -p --add-dir ~/project --add-dir ~/shared "Refactor across both directories"---
Session Management
# Continue last conversation
claude -p -c "Follow up on the previous task"
# Resume specific session
claude -p -r session-id "Continue from here"
# Browse/pick sessions interactively
claude --resume---
Examples
Quick Code Fix
claude -p --permission-mode acceptEdits "Fix the null pointer exception in src/api.ts"Full Auto Build
claude -p --permission-mode acceptEdits "Build a REST API with CRUD endpoints for users"Code Review with Budget
claude -p --model opus --max-budget-usd 1 "Review this PR for security issues"Multi-Phase Implementation
# Phase 1: Implement
claude -p --permission-mode acceptEdits "Implement the user registration endpoint"
# Phase 2: Fix issues (resume context)
claude -p -c --permission-mode acceptEdits "Fix the validation error in registration"
# Phase 3: Add tests
claude -p -c --permission-mode acceptEdits "Add integration tests for registration"---
Codex → Claude Mapping
| Codex | Claude |
|---|---|
codex exec "prompt" | claude -p "prompt" |
codex exec --full-auto "prompt" | claude -p --permission-mode acceptEdits "prompt" |
codex exec --dangerously-bypass-approvals-and-sandbox "prompt" | claude -p --permission-mode bypassPermissions "prompt" |
codex review --base <base> | claude -p "Review changes vs <base> branch" |
codex exec resume --last | claude -p -c "prompt" |
codex exec resume <id> | claude -p --resume <id> "prompt" |
Codex CLI Reference
Canonical Codex guidance for plan-issue + coding-agent.
Plan-First Gate
For non-trivial tasks: 1. Plan first (plan-issue behavior). 2. Wait for explicit APPROVE. 3. Execute with Codex (coding-agent behavior).
Do not perform writes before APPROVE.
Preferred plan artifact flow:
./scripts/plan --engine codex --repo /path/to/repo "Implement feature X"
./scripts/plan-review --repo /path/to/repo
./scripts/plan-review-live --repo /path/to/repoDefault Strategy
Use single-agent Codex for most work: 1. codex -c 'model_reasoning_effort="high"' exec --full-auto "..." for feature implementation/refactors after approval. 2. codex exec resume --last "..." for follow-up work. 3. Use tmux only when persistence/reattach is required.
Reasoning default policy:
- Use
highfor feature implementation and architectural refactors. - Use
medium/lowonly for simple fixes/docs tasks or explicit fast/cheap requests.
Core Commands
Implementation (post-approval)
codex -c 'model_reasoning_effort="high"' exec --full-auto "Implement feature X according to the approved plan."Resume previous context
codex exec resume --last "Address review findings from the previous run"Review against base branch
timeout 600s codex review --base <base> --title "PR #N Review"Review latest generated plan (read-only)
./scripts/plan-review --repo /path/to/repoReview latest generated plan (interactive checkpoints)
./scripts/plan-review-live --repo /path/to/repo
# Optional: force legacy engine
./scripts/plan-review-live --engine legacy --repo /path/to/repocode-implement --plan enforces latest per-plan review metadata readiness. If blocking decisions remain unresolved, run plan-review-live first or use --force to bypass explicitly.
Structured non-interactive output
codex exec --json --output-last-message /tmp/last.txt "Summarize changes"Useful automation flags:
--json--output-schema <FILE>--output-last-message <FILE>--skip-git-repo-check
Safety Profiles
- Guardrailed default:
codex exec --full-auto "..." - Explicit bypass (only when user asks to bypass approvals):
codex exec --dangerously-bypass-approvals-and-sandbox "..."Execution Policy Matrix
| Task | Primary | Secondary | Notes |
|---|---|---|---|
| Implementation | direct codex -c 'model_reasoning_effort=\"high\"' exec --full-auto | tmux transport | Use resume for iterative loops; lower reasoning only for simple/docs or explicit fast/cheap requests |
| PR review | codex review --base | Claude CLI fallback | Keep timeout >= 600s |
| Long-running implementation | tmux transport | direct codex -c 'model_reasoning_effort=\"high\"' exec --full-auto | For reattach/log durability |
Implementation-mode env var:
CODING_AGENT_IMPL_MODE=direct|tmux|autodirect: run Codex directly firsttmux: run tmux transport firstauto: tmux first only when attached to TTY and tmux is available
MCP Clarification
1. codex mcp ...: configure external MCP tools for Codex runs. 2. codex mcp-server: expose Codex itself as an MCP server.
Official Sources
- https://developers.openai.com/codex/cli/reference
- https://developers.openai.com/codex/noninteractive
- https://developers.openai.com/codex/mcp
- https://developers.openai.com/codex/multi-agent
Violation Examples and Recovery
Violation Consequences
If any rule is violated: 1. Stop immediately. 2. Acknowledge the violation. 3. Revert or fix. 4. Document the violation in PR/commit notes. 5. Resume correctly.
Common Pitfalls
❌ Writing code directly
Wrong:
Edit file.py: add function xyz...Correct:
./scripts/code-implement "Add function xyz to file.py"❌ Skipping review
Wrong:
git push && gh pr create && gh pr mergeCorrect:
gh pr create
timeout 600s codex review --base <base> --title "PR Review"
./scripts/tmux-run timeout 1200s codex --yolo exec -c model_reasoning_effort="medium" \
"Review against STANDARDS.md and report PASS/FAIL per category"❌ Chaining without timeouts
Wrong:
codex exec "Part 1" && codex exec "Part 2"Correct:
timeout 300s codex --yolo exec -c model_reasoning_effort="high" "Part 1"
timeout 300s codex --yolo exec -c model_reasoning_effort="high" "Part 2"Real Violation Examples
Example 1: “Trivial Change” Rationalization
- What happened: Direct edit for a typo.
- Why wrong: Rule 1 has no exceptions.
- Fix:
./scripts/code-implement "Fix typo in config.py line 42"Example 2: Skipped PR Creation
- What happened: Commit on main, pushed directly.
- Why wrong: Rule 2 and Rule 3.
- Fix:
git checkout -b fix/typo-config
git add -A && git commit -m "fix: correct typo"
git push -u origin fix/typo-config
gh pr createExample 3: Missing Self-Check
- What happened: Implementation started without STOP-AND-VERIFY.
- Why wrong: Mandatory protocol.
- Fix: perform STOP-AND-VERIFY before any changes.
Frontend Design References
When reviewing frontend/UI work, check consistency with these sources:
1. Anthropic frontend-design
- https://github.com/anthropics/skills/blob/main/skills/frontend-design/SKILL.md
- Anti-AI-slop philosophy, typography, color, motion, spatial composition
- BANNED: Inter, Roboto, Arial, purple gradients, centered layouts
2. Anthropic web-artifacts-builder
- https://github.com/anthropics/skills/blob/main/skills/web-artifacts-builder/SKILL.md
- React 18 + TypeScript + Vite + Tailwind + shadcn/ui
- Single-file HTML bundling with Parcel
3. Community frontend-design-v2
- https://github.com/nhatmobile1/claude-skills/blob/main/skills/frontend/frontend-design-v2/SKILL.md
- Mobile-first patterns, hero layouts, accordions, form consistency
Gemini CLI Reference
Optional reference for Gemini CLI. This skill does not use Gemini by default. To enable Gemini as a fallback in scripts/safe-fallback.sh, set:
export GEMINI_FALLBACK_ENABLE=1Contents
- Basic usage
- Approval modes
- Model selection
- Sandbox mode
- Session management
- Output formats
- Examples
---
Basic Usage
Gemini CLI defaults to one-shot mode with positional prompts:
gemini "Your prompt here"For interactive mode, use -i:
gemini -i "Start with this prompt"---
Flags Reference
| Flag | Description |
|---|---|
-y, --yolo | Auto-approve all actions |
--approval-mode <mode> | Approval handling (see below) |
-m, --model <model> | Select model |
-s, --sandbox | Run in sandbox mode |
-i, --prompt-interactive | Interactive mode with initial prompt |
-o, --output-format <format> | Output: text, json, stream-json |
-r, --resume <id> | Resume session (latest or index) |
--include-directories <dirs> | Additional directories to include |
-d, --debug | Debug mode |
---
Approval Modes
| Mode | Behavior |
|---|---|
default | Prompt for approval |
auto_edit | Auto-approve edit tools only |
yolo | Auto-approve all tools |
# Auto-approve edits only
gemini --approval-mode auto_edit "Fix the bug in api.ts"
# Full auto (yolo)
gemini -y "Build the feature"
# or
gemini --approval-mode yolo "Build the feature"---
Model Selection
# Specify model
gemini -m gemini-2.5-pro "Complex analysis task"
# Default model (usually gemini-2.5-flash)
gemini "Quick task"---
Sandbox Mode
Run in a sandboxed environment for safety:
gemini -s "Experiment with this code"
gemini --sandbox "Run untrusted operations"---
Working Directories
# Include additional directories
gemini --include-directories ~/project,~/shared "Work across directories"
# Multiple flags
gemini --include-directories ~/project --include-directories ~/lib "Cross-repo task"---
Session Management
# List available sessions
gemini --list-sessions
# Resume latest session
gemini -r latest "Continue where we left off"
# Resume specific session by index
gemini -r 5 "Continue session 5"
# Delete a session
gemini --delete-session 3---
Output Formats
# Plain text (default)
gemini "Summarize this"
# JSON output
gemini -o json "List functions in this file"
# Streaming JSON
gemini -o stream-json "Analyze codebase"---
Examples
Quick Code Fix
gemini --approval-mode auto_edit "Fix the null check in src/api.ts"Full Auto Build
gemini -y "Build a REST API with user authentication"Sandboxed Experiment
gemini -s -y "Try refactoring this module using a different pattern"Interactive Session (with PTY)
bash pty:true workdir:~/project command:"gemini -i 'Help me debug this issue'"Background Task
bash pty:true workdir:~/project background:true command:"gemini -y 'Build the feature module'"---
Codex → Gemini Mapping
| Codex | Gemini |
|---|---|
codex exec "prompt" | gemini "prompt" |
codex exec --full-auto "prompt" | gemini --approval-mode auto_edit "prompt" |
codex --yolo "prompt" | gemini -y "prompt" |
---
Extensions & MCP
Gemini supports extensions and MCP servers:
# List extensions
gemini -l
# Use specific extensions
gemini -e code-search,git "Find and fix the bug"
# Manage MCP servers
gemini mcpLobster Workflows (In-Repo)
This repository contains the plan-review-live Lobster workflow used by ./scripts/plan-review-live.
Files
workflows/plan-review-live.lobster: workflow definition.scripts/plan-review-lobster/section-step.sh: per-section review runner.scripts/plan-review-live-lobster: wrapper integration for metadata contract and decision collection.
Execution Contract
- Default live engine is Lobster (
PLAN_REVIEW_LIVE_ENGINE=lobster). - If
lobsterbinary is missing, wrapper falls back to legacy engine automatically. - Output + metadata contract remains unchanged:
- markdown output in
.ai/plan-reviews/*.md - metadata history file +
latest-<plan-id>.json - fields:
schema_version,plan_id,plan_path,mode,
ready_for_implementation, blocking_decisions, resolved_decisions, created_at, review_markdown_path
Commands
# Default (Lobster first)
./scripts/plan-review-live --repo /path/to/repo
# Legacy path
./scripts/plan-review-live --engine legacy --repo /path/to/repo
# Resume a paused Lobster run
./scripts/plan-review-live --resume-token <token> --output /path/to/repo/.ai/plan-reviews/<same-file>.mdResume behavior persists decision state in:
<review-markdown-path>.lobster-session.json
That file is removed automatically when the live review completes successfully.
Environment
PLAN_REVIEW_LIVE_ENGINE:lobster(default) orlegacy.PLAN_REVIEW_LOBSTER_FILE: override workflow file path.PLAN_REVIEW_LIVE_SECTION_TIMEOUT: per-section timeout seconds.PLAN_REVIEW_LIVE_TOTAL_TIMEOUT: total timeout budget seconds.PLAN_REVIEW_LIVE_ALLOW_NON_TTY: allow live mode in non-TTY for scripted runs.
coding-agent Reference
Contents
- Plan-First Execution Gate
- STOP-AND-VERIFY (Before ANY Implementation)
- Self-Audit Triggers (Option A)
- Forbidden Flags & Minimum Timeouts
- Tool Fallback Chain
- Direct CLI Commands (Primary)
- Plan Mode Commands
- Wrapper Scripts (Secondary)
- Preflight Checks
- Pre-Completion Checklist
- Quick Reference
- Command Reference
- Code Quality Standards
- Issue Priority (P0-P3)
- tmux for Interactive Sessions (Optional)
Plan-First Execution Gate
For non-trivial requests: 1. Run planning flow first. 2. Wait for explicit APPROVE. 3. Execute implementation only after approval.
STOP-AND-VERIFY (Before ANY Implementation)
Say this out loud before writing/changing any code:
STOP. Before I proceed, let me verify:
□ Am I using an agent CLI (Codex/Claude)? (not Edit/Write tools)
□ Am I on a feature branch? (not main)
□ Will I create a PR before completing this task?
□ Am I using adequate timeout? (minimum: 600s for reviews)
□ Am I avoiding --max-turns? (let it complete naturally)If any box is unchecked → STOP and fix before proceeding.
Self-Audit Triggers (Option A)
Run self-audit before final response when:
- code/config changed,
- tests changed (or should have changed),
- review requested,
- docs commands/examples changed.
Skip only when:
- informational response with zero repo changes, or
- user asks for raw output only.
Forbidden Flags & Minimum Timeouts
❌ FORBIDDEN: --max-turns (any value)
❌ FORBIDDEN: timeout < 600s for reviews
✅ Reviews: TIMEOUT=600 minimum
✅ Architecture: TIMEOUT=600 minimumReview Routing + Run Events (Hard Rules)
- Plan artifact review:
./scripts/plan-reviewor./scripts/plan-review-live - PR/code review:
timeout 600s codex review --base <base> --title "PR #N Review"orsafe-review.sh - Never produce manual review output before running the matching command.
- Required wrapper events:
RUN_EVENT startRUN_EVENT heartbeatevery 20s after 30s elapsedRUN_EVENT interruptedorRUN_EVENT failedRUN_EVENT done
Tool Fallback Chain
Implementation: ACPX → Codex CLI (direct) → Codex CLI (tmux) → Claude CLI → BLOCKED
Reviews: Codex CLI (direct) → ACPX → Claude CLI → BLOCKED
⛔ NEVER skip to direct edits — request user override insteadImplementation mode routing:
CODING_AGENT_IMPL_MODE=direct|tmux|auto(default:direct)auto-> tmux-first only in interactive TTY + tmux available; otherwise direct-first- ACP-first toggle:
CODING_AGENT_ACP_ENABLE=1|0(default:1) - ACPX binary override:
CODING_AGENT_ACPX_CMD=/path/to/acpx
Direct CLI Commands (Primary)
Codex
# Implementation default (feature work / architectural refactor)
codex -c 'model_reasoning_effort="high"' exec --full-auto "Implement feature X based on approved plan."
# Simple fix/docs or explicit fast/cheap request
codex -c 'model_reasoning_effort="medium"' exec --full-auto "Fix typo in one file"
codex -c 'model_reasoning_effort="low"' exec --full-auto "Update README command example quickly"
# Resume last session (context preserved)
codex exec resume --lastClaude Code
# Implementation (post-approval)
claude -p --permission-mode acceptEdits "Implement feature X"
# Complex task with Opus
claude -p --model opus --permission-mode acceptEdits "Complex refactor..."
# Continue most recent session
claude -p -c "Fix the review findings"
# Resume specific session
claude -p --resume <session-id> "Continue implementation"
# List sessions
claude --resumePlan Mode Commands
# Generate read-only plan (Codex)
./scripts/plan --engine codex --repo /path/to/repo --base main "Implement feature X"
# Generate strict plan mode output (Claude)
./scripts/plan --engine claude --model sonnet --repo /path/to/repo "Implement feature X"
# Review latest plan with Codex read-only mode (or pass --plan)
./scripts/plan-review --repo /path/to/repo
# Interactive section-by-section review with decision checkpoints
./scripts/plan-review-live --repo /path/to/repo
# Force legacy live-review engine
./scripts/plan-review-live --engine legacy --repo /path/to/repo
# Non-TTY/chat-safe finalization (no interactive prompts)
./scripts/plan-review-live --repo /path/to/repo --decisions "1A,2B,3A,4A" --blocking none
# Resolve from machine-readable file
./scripts/plan-review-live --repo /path/to/repo --resolve-file /path/to/decisions.json
# Resume a paused Lobster run
./scripts/plan-review-live --resume-token <token> --output /path/to/repo/.ai/plan-reviews/<same-file>.md
# Execute approved plan (prompts for approval if still PENDING)
# Requires latest plan-review metadata to be ready unless --force is used.
./scripts/code-implement --plan /path/to/repo/.ai/plans/<plan>.mdWrapper Scripts (Secondary)
# Implementation (3 min timeout, tmux)
./scripts/code-implement "Implement feature X"
# Enforcement wrappers
TIMEOUT=600 ./scripts/safe-review.sh codex review --base <base> --title "PR Review"
TIMEOUT=180 ./scripts/safe-impl.sh codex -c 'model_reasoning_effort="high"' exec --full-auto "Implement feature X"Preflight Checks
# Verify local prerequisites and Claude binary resolution
./scripts/doctor
# Verify Codex command/flag drift before editing command docs
./scripts/doc-drift-check
# Validate wrapper behavior
./scripts/smoke-wrappers.shClaude is resolved in this order: CODING_AGENT_CLAUDE_BIN → ~/.claude/local/claude → claude in PATH.
Pre-Completion Checklist
Before marking ANY task complete:
- [ ] On feature branch? (not main)
- [ ] PR created with URL?
- [ ] Used agent CLI (direct or tmux)? (not direct edits)
- [ ] Code review posted to PR?
- [ ] Standards review posted to PR?
- [ ] Implementation audit completed?
- [ ] Review audit completed?
- [ ] User-facing long-form text passed through
/humanizer(or fallback explicitly noted)? - [ ] PR body includes
What,Why,Tests,AI Assistance? - [ ] Issue/PR title follows repo conventions?
Unchecked box = Task NOT complete.
---
Quick Reference
Activate
Use /coding in OpenClaw to activate this skill. For plan-first flow, use /plan <task> (maps to scripts/plan), /plan-review (batch), and /plan-review-live (Lobster workflow by default with legacy fallback; pass --decisions/--blocking or --resolve-file in non-TTY chat flows).
Agent CLI Commands
Codex — guarded implementation:
codex -c 'model_reasoning_effort="high"' exec --full-auto "Your approved task."Codex — resume session:
codex exec resume --lastClaude Code — guarded implementation:
claude -p --permission-mode acceptEdits "Your task"Claude Code — resume session:
claude -p -c "Follow up prompt"PR Review (direct CLI):
cd /path/to/repo
timeout 600s codex review --base <base> --title "Review PR #N"PR Review config-safety trigger check:
gh pr view <PR> --json files --jq '.files[].path'Git Workflow
# If no PR arg was provided, list and select one PR first
gh pr list --repo owner/repo
# Checkout and review
gh pr checkout <PR> --repo owner/repo
gh pr view <PR> --repo owner/repo
gh pr diff <PR> --repo owner/repo
timeout 600s codex review --base <base> --title "Review PR #<PR>"
# Merge (Martin only)
gh pr merge <PR> --repo owner/repo --admin --mergeIssue/PR Title Patterns
PR: type(scope): imperative summary
Issue: feat: <capability> (for <surface>)
Issue: bug: <symptom> when <condition>
Issue: TODO: <cleanup> after <dependency>PR Body Skeleton
## What
- ...
## Why
- ...
## Tests
- `command 1`
- `command 2`
## AI Assistance
- AI-assisted: yes/no
- Testing level: untested/lightly tested/fully tested
- Prompt/session log: <link or note>
- I understand this code: yesSelf-Audit Response Skeleton
## Self-Audit Summary
- Audit status: complete | skipped (reason)
- Tests run:
- `command ...`
- Residual risks:
- ...
- Assumptions:
- ...
- Command/docs verification:
- VERIFIED: ...
- UNVERIFIED: ...Definitions:
VERIFIED: command/example was executed in this session.UNVERIFIED: command/example was not executed in this session.
Configuration Safety Checklist (/review_pr)
Trigger when changed files include:
.env,.env.**.yml,*.yaml,*.json,*.toml,*.ini,*.conf,*.propertiesDockerfile,docker-compose*.github/workflows/*config/,infra/,deploy/,k8s/,helm/
For each flagged config change, include:
- Load-test evidence (or explicit "not tested")
- Rollback method + expected rollback time
- Monitoring signals/alerts
- Dependency/limit interactions
- Historical context (incidents or none known)
Command Reference
| Task | Command |
|---|---|
| List PRs | gh pr list --repo owner/repo |
| View PR | gh pr view <PR> --json number,title,state |
| List PR files | gh pr view <PR> --json files --jq '.files[].path' |
| Diff PR | gh pr diff <PR> --repo owner/repo |
| Checkout PR | gh pr checkout <PR> |
| Review PR | timeout 600s codex review --base <base> --title "PR #N Review" |
| Preflight wrappers | ./scripts/doctor |
| Codex doc drift check | ./scripts/doc-drift-check |
| Wrapper smoke tests | ./scripts/smoke-wrappers.sh |
| Check CI | gh pr checks <PR> --repo owner/repo |
| Merge PR | gh pr merge <PR> --repo owner/repo --admin --merge |
| Resume Codex | codex exec resume --last |
| Resume Claude | claude -p -c "prompt" |
| Pick Claude session | claude --resume (interactive) |
Code Quality Standards
- Functions: max 30-40 lines
- Classes: max 500 lines
- Files: max 500 lines
- KISS, YAGNI, DRY, SRP principles
Issue Priority (P0-P3)
- P0: Critical (security, data loss)
- P1: High (major feature broken)
- P2: Medium (minor features)
- P3: Low (nice-to-have)
tmux for Interactive Sessions (Optional)
For durable TTY sessions with logging. See references/tooling.md for full tmux documentation.
SOCKET_DIR="${OPENCLAW_TMUX_SOCKET_DIR:-${CLAWDBOT_TMUX_SOCKET_DIR:-${TMPDIR:-/tmp}/openclaw-tmux-sockets}}"
mkdir -p "$SOCKET_DIR"
SOCKET="$SOCKET_DIR/openclaw.sock"
SESSION=codex-impl
tmux -S "$SOCKET" new-session -d -s "$SESSION" -n shell
TARGET="$(tmux -S "$SOCKET" list-panes -t "$SESSION" -F "#{session_name}:#{window_index}.#{pane_index}" | head -n 1)"
tmux -S "$SOCKET" send-keys -t "$TARGET" -l -- "codex exec --full-auto 'Implement feature X'"
tmux -S "$SOCKET" send-keys -t "$TARGET" Enter
# Monitor
tmux -S "$SOCKET" attach -t "$SESSION"
tmux -S "$SOCKET" capture-pane -p -J -t "$TARGET" -S -200
# Cleanup
tmux -S "$SOCKET" kill-session -t "$SESSION"Reviews and Standards
Review Workflow
New Features (Issue → PR)
1. Implement with agent CLI. 2. Create PR. 3. Run Codex review. 4. Run standards review (references/STANDARDS.md) — required. 5. Fix issues, push updates to same branch.
Existing PRs
1. Checkout PR. 2. Run Codex review locally. 3. Run standards review. 4. Post both reviews to GitHub. 5. Fix issues, push updates.
Codebase Reviews
1. Run full review (Codex or Claude CLI with long timeout). 2. Classify findings by severity (P0–P3). 3. Create issues with file:line references.
PR Intake (/review_pr)
1. If no PR number/URL is provided, run gh pr list and ask user to choose one PR. 2. If a PR number is provided, run gh pr view <number> to gather PR metadata. 3. Run gh pr diff <number> and review the actual patch before issuing findings.
Review Focus Checklist (Required)
- Code correctness
- Architecture and dependency boundaries
- Project conventions and style
- Performance implications
- Test coverage quality and gaps
- Security considerations
Configuration Safety Review (Required When Triggered)
Run a configuration safety section in the review output when the PR touches any of:
.env,.env.**.yml,*.yaml,*.json,*.toml,*.ini,*.conf,*.propertiesDockerfile,docker-compose*.github/workflows/*config/,infra/,deploy/,k8s/,helm/
Treat numeric/config value changes as risky until justified. For each flagged config change, require:
- Load-test evidence (or explicit "not tested")
- Rollback method and expected rollback time
- Monitoring signals/alerts to detect regressions
- Dependency/limit interaction analysis (upstream/downstream/system caps)
- Historical context (similar prior incidents or "none known")
Review Output Contract (Required)
- List findings first, ordered by severity (
P0->P3). - Include concrete file:line reference for each finding.
- Include open questions/assumptions after findings.
- Include a short PR overview after findings (what changed and why).
- Include specific improvement suggestions and key risks.
- When configuration safety is triggered, include a dedicated
Configuration Safetysubsection with evidence. - If command/docs examples were changed, label each as:
VERIFIED(executed) orUNVERIFIED(not executed)- Never imply a command was validated when it was not run.
Self-Audit Summary Block (Required in final review response)
## Self-Audit Summary
- Audit status: complete | skipped (reason)
- Tests run:
- `command ...`
- Residual risks:
- ...
- Assumptions:
- ...
- Command/docs verification:
- VERIFIED: ...
- UNVERIFIED: ...Issue/PR Authoring Standard (Peter-style)
PR Titles
- Default:
type(scope): imperative summary - Use repo-specific override only when documented (e.g.,
Type: Description #issue)
Issue Titles
- Feature:
feat: <capability> (for <surface>) - Bug:
bug: <symptom> when <condition> - Tracking:
TODO: <cleanup> after <dependency>
PR Body Sections (required)
1. What (3-6 concrete bullets) 2. Why (impact/reason) 3. Tests (exact commands run) 4. AI Assistance (used/not used, testing level, prompt/session log, understanding confirmation)
Review Commands
# If PR number is missing, list open PRs first
gh pr list
# Load PR metadata
gh pr view <PR>
# Inspect patch before review output
gh pr diff <PR>
# Optional: list changed file paths to detect config-safety trigger
gh pr view <PR> --json files --jq '.files[].path'
# Code review (direct CLI)
timeout 600s codex review --base <base> --title "PR #N Review"
# Standards review (direct CLI, preferred)
timeout 1200s codex --yolo exec -c model_reasoning_effort="medium" \
"Review against coding standards in references/STANDARDS.md. Report PASS/FAIL per category with file:line refs."
# Standards review (tmux transport, optional for persistence)
./scripts/tmux-run timeout 1200s codex --yolo exec -c model_reasoning_effort="medium" \
"Review against coding standards in references/STANDARDS.md. Report PASS/FAIL per category with file:line refs."Posting Reviews to GitHub
# Approve
gh pr review <PR> --approve --body "LGTM"
# Request changes
gh pr review <PR> --request-changes --body "Found issues that need fixing"
# Comment only
gh pr review <PR> --comment --body "Suggestions and notes"Standards Review Output Format
## references/STANDARDS.md Standards Review ✅|⚠️|❌
### ✅ PASSED
- Code Quality: Functions under 40 lines
### ⚠️ WARNINGS (P2)
- [file:23] Function has 7 parameters (limit: 4)
### ❌ ISSUES (P1)
- [file:8] Commit uses wrong format
### Assumptions / Open Questions
- Assumption: ...
### Command/Docs Verification
- VERIFIED: `timeout 600s codex review --base main`
- UNVERIFIED: `claude ...`
### Recommendation: APPROVE / REQUEST_CHANGESCoding Standards
Contents
- Principles
- Size Limits
- Naming & Clarity
- Error Handling
- Testing
- Security
- Documentation
Language: English only - all code, comments, docs, examples, commits, configs, errors, tests
Foundational Principles
KISS (Keep It Simple)
- Simplest solution wins | Avoid premature abstraction | Reduce complexity
- Inline single-use helpers | Remove unused flexibility | Flatten unnecessary layers
YAGNI (You Aren't Gonna Need It)
- Build only what's needed now | No speculative features | No "future-proofing"
- Delete unused code completely | Add complexity when required, not before
DRY (Don't Repeat Yourself)
- Extract common patterns | Maintain consistency | Single source of truth
- Three strikes rule - don't abstract until third occurrence
SRP (Single Responsibility)
- One class, one reason to change | One responsibility per module
- Separate authentication, database operations, business logic, UI concerns
Design Principles
Law of Demeter
- Classes know only direct dependencies | Avoid chaining | "Don't talk to strangers"
- Add delegation methods | Pass required objects directly | Flatten access patterns
Dependency Injection
- Inject dependencies explicitly | Avoid hidden coupling | Make relationships visible
- Constructor injection for required dependencies | Method injection for optional
Polymorphism over Conditionals
- Prefer polymorphism to if/else chains | Use interfaces for extensibility
- Extract strategy pattern | Replace conditionals with polymorphic dispatch
Size Limits & Refactoring Triggers
- Functions: Max 30-40 lines
- Classes: Max 500 lines | Refactor when >30 methods
- Files: Max 500 lines | Split when exceeding or mixing multiple concerns
- Methods per Class: Max 20-30 methods
Refactoring Best Practices
- Small Steps: Incremental changes to reduce bugs | Test each modification
- Separate Concerns: Never mix refactoring with bug fixing
- No Backwards-Compatibility Hacks: Delete unused code completely | No renaming to _vars | No // removed comments
Universal Coding Standards
- Naming: Descriptive, searchable names | Replace magic numbers with named constants
- Functions: Max 3-4 parameters | Encapsulate boundary conditions | Declare variables near usage
- TypeScript: Use Record<string, unknown> over any | PascalCase (classes/interfaces) | camelCase (functions/variables)
- Error Handling: Explicit error patterns | Never silent failures
- Imports: Order as node → external → internal | Remove unused immediately
- Git Commits: Conventional format: type(scope): subject | 50 chars max, imperative mood | Atomic changes
- Repo override: If a repository defines a different format (e.g.,
Type: Description #issue), follow the repo and retain#issuelinkage.
Inclusive Language
- Terms: allowlist/blocklist, primary/replica, placeholder/example, main branch, conflict-free, concurrent/parallel
Process Compliance Checks
During standards review, also verify process compliance:
Git Workflow Compliance
- [ ] Changes made on feature branch (not main)
- [ ] PR exists with descriptive title
- [ ] Commits follow conventional format (
type(scope): description) - [ ] No force pushes to shared branches
- [ ] No direct commits to main
- [ ] PR/issue titles follow repo conventions
- [ ] PR body includes
What,Why,Tests,AI Assistance - [ ]
Testssection lists exact commands run
Tool Usage Compliance
- [ ] If agent CLI specified → verify CLI was used (look for CLI invocation in session log)
- [ ] Implementation done via agent CLI (Codex/Claude); direct CLI primary, tmux optional for durable runs (not direct file edits)
- [ ] Reviews done via
codex revieworclaude -p - [ ] Tool used is documented in PR description
- [ ] If AI-assisted, PR documents testing level and prompt/session log reference
Review Process Compliance
- [ ] Code/logic review completed
- [ ] Standards review completed
- [ ] Both reviews posted to GitHub PR
- [ ] Self-audit completed (or explicit skip reason documented)
- [ ] Issues found are addressed before merge
Compliance Review Output Format
## Process Compliance Review ✅|❌
### Git Workflow
- [x] Feature branch used
- [x] PR created
- [x] Conventional commits
### Tool Usage
- [x] Specified tools used
- [x] Implementation via agent CLI (direct or tmux)
### Review Process
- [x] Code review posted
- [x] Standards review posted
**Status**: COMPLIANT / NON-COMPLIANT---
name: plan-exit-review
version: 2.0.0
description: |
Review a plan thoroughly before implementation. Challenges scope, reviews
architecture/code quality/tests/performance, and walks through issues
interactively with opinionated recommendations.
allowed-tools:
- Read
- Grep
- Glob
- AskUserQuestion
---
# Plan Review Mode
Review this plan thoroughly before making any code changes. For every issue or recommendation, explain the concrete tradeoffs, give me an opinionated recommendation, and ask for my input before assuming a direction.
## Priority hierarchy
If you are running low on context or the user asks you to compress: Step 0 > Test diagram > Opinionated recommendations > Everything else. Never skip Step 0 or the test diagram.
## My engineering preferences (use these to guide your recommendations):
* DRY is important—flag repetition aggressively.
* Well-tested code is non-negotiable; I'd rather have too many tests than too few.
* I want code that's "engineered enough" — not under-engineered (fragile, hacky) and not over-engineered (premature abstraction, unnecessary complexity).
* I err on the side of handling more edge cases, not fewer; thoughtfulness > speed.
* Bias toward explicit over clever.
* Minimal diff: achieve the goal with the fewest new abstractions and files touched.
## Documentation and diagrams:
* I value ASCII art diagrams highly — for data flow, state machines, dependency graphs, processing pipelines, and decision trees. Use them liberally in plans and design docs.
* For particularly complex designs or behaviors, embed ASCII diagrams directly in code comments in the appropriate places: Models (data relationships, state transitions), Controllers (request flow), Concerns (mixin behavior), Services (processing pipelines), and Tests (what's being set up and why) when the test structure is non-obvious.
* **Diagram maintenance is part of the change.** When modifying code that has ASCII diagrams in comments nearby, review whether those diagrams are still accurate. Update them as part of the same commit. Stale diagrams are worse than no diagrams — they actively mislead. Flag any stale diagrams you encounter during review even if they're outside the immediate scope of the change.
## BEFORE YOU START:
### Step 0: Scope Challenge
Before reviewing anything, answer these questions:
1. **What existing code already partially or fully solves each sub-problem?** Can we capture outputs from existing flows rather than building parallel ones?
2. **What is the minimum set of changes that achieves the stated goal?** Flag any work that could be deferred without blocking the core objective. Be ruthless about scope creep.
3. **Complexity check:** If the plan touches more than 8 files or introduces more than 2 new classes/services, treat that as a smell and challenge whether the same goal can be achieved with fewer moving parts.
Then ask if I want one of three options:
1. **SCOPE REDUCTION:** The plan is overbuilt. Propose a minimal version that achieves the core goal, then review that.
2. **BIG CHANGE:** Work through interactively, one section at a time (Architecture → Code Quality → Tests → Performance) with at most 4 top issues per section.
3. **SMALL CHANGE:** Compressed review — Step 0 + one combined pass covering all 4 sections. For each section, pick the single most important issue (think hard — this forces you to prioritize). Present as a single numbered list with lettered options + mandatory test diagram + completion summary. One AskUserQuestion round at the end.
**Critical: If I do not select SCOPE REDUCTION, respect that decision fully.** Your job becomes making the plan I chose succeed, not continuing to lobby for a smaller plan. Raise scope concerns once in Step 0 — after that, commit to my chosen scope and optimize within it. Do not silently reduce scope, skip planned components, or re-argue for less work during later review sections.
## Review Sections (after scope is agreed)
### 1. Architecture review
Evaluate:
* Overall system design and component boundaries.
* Dependency graph and coupling concerns.
* Data flow patterns and potential bottlenecks.
* Scaling characteristics and single points of failure.
* Security architecture (auth, data access, API boundaries).
* Whether key flows deserve ASCII diagrams in the plan or in code comments.
* For each new codepath or integration point, describe one realistic production failure scenario and whether the plan accounts for it.
**STOP.** You MUST call AskUserQuestion NOW with your findings from this section. Do NOT proceed to the next section until the user responds.
### 2. Code quality review
Evaluate:
* Code organization and module structure.
* DRY violations—be aggressive here.
* Error handling patterns and missing edge cases (call these out explicitly).
* Technical debt hotspots.
* Areas that are over-engineered or under-engineered relative to my preferences.
* Existing ASCII diagrams in touched files — are they still accurate after this change?
**STOP.** You MUST call AskUserQuestion NOW with your findings from this section. Do NOT proceed to the next section until the user responds.
### 3. Test review
Make a diagram of all new UX, new data flow, new codepaths, and new branching if statements or outcomes. For each, note what is new about the features discussed in this branch and plan. Then, for each new item in the diagram, make sure there is a JS or Rails test.
For LLM/prompt changes: check the "Prompt/LLM changes" file patterns listed in CLAUDE.md. If this plan touches ANY of those patterns, state which eval suites must be run, which cases should be added, and what baselines to compare against. Then use AskUserQuestion to confirm the eval scope with the user.
**STOP.** You MUST call AskUserQuestion NOW with your findings from this section. Do NOT proceed to the next section until the user responds.
### 4. Performance review
Evaluate:
* N+1 queries and database access patterns.
* Memory-usage concerns.
* Caching opportunities.
* Slow or high-complexity code paths.
**STOP.** You MUST call AskUserQuestion NOW with your findings from this section. Do NOT proceed to the next section until the user responds.
## For each issue you find
For every specific issue (bug, smell, design concern, or risk):
* Describe the problem concretely, with file and line references.
* Present 2–3 options, including "do nothing" where that's reasonable.
* For each option, specify in one line: effort, risk, and maintenance burden.
* **Lead with your recommendation.** State it as a directive: "Do B. Here's why:" — not "Option B might be worth considering." Be opinionated. I'm paying for your judgment, not a menu.
* **Map the reasoning to my engineering preferences above.** One sentence connecting your recommendation to a specific preference (DRY, explicit > clever, minimal diff, etc.).
* **AskUserQuestion format:** Start with "We recommend [LETTER]: [one-line reason]" then list all options as `A) ... B) ... C) ...`. Label with issue NUMBER + option LETTER (e.g., "3A", "3B"). Never ask yes/no or open-ended questions.
## Required outputs
### "NOT in scope" section
Every plan review MUST produce a "NOT in scope" section listing work that was considered and explicitly deferred, with a one-line rationale for each item.
### "What already exists" section
List existing code/flows that already partially solve sub-problems in this plan, and whether the plan reuses them or unnecessarily rebuilds them.
### TODOS.md updates
Any deferred work that is genuinely valuable — not just "nice to have" but would meaningfully improve the system — MUST be written up as TODOS.md entries. Each entry needs:
* **What:** One-line description of the work.
* **Why:** The concrete problem it solves or value it unlocks (not just "would be nice").
* **Context:** Enough detail that someone picking this up in 3 months understands the motivation, the current state, and where to start — without needing to re-derive it from scratch.
* **Depends on / blocked by:** Any prerequisites or ordering constraints.
Do NOT just append vague bullet points. A TODO without context is worse than no TODO — it creates false confidence that the idea was captured while actually losing the reasoning. Ask me which deferred items I want captured before writing them.
### Diagrams
The plan itself should use ASCII diagrams for any non-trivial data flow, state machine, or processing pipeline. Additionally, identify which files in the implementation should get inline ASCII diagram comments — particularly Models with complex state transitions, Services with multi-step pipelines, and Concerns with non-obvious mixin behavior.
### Failure modes
For each new codepath identified in the test review diagram, list one realistic way it could fail in production (timeout, nil reference, race condition, stale data, etc.) and whether:
1. A test covers that failure
2. Error handling exists for it
3. The user would see a clear error or a silent failure
If any failure mode has no test AND no error handling AND would be silent, flag it as a **critical gap**.
### Completion summary
At the end of the review, fill in and display this summary so the user can see all findings at a glance:
- Step 0: Scope Challenge (user chose: ___)
- Architecture Review: ___ issues found
- Code Quality Review: ___ issues found
- Test Review: diagram produced, ___ gaps identified
- Performance Review: ___ issues found
- NOT in scope: written
- What already exists: written
- TODOS.md updates: ___ items proposed to user
- Failure modes: ___ critical gaps flagged
## Retrospective learning
Check the git log for this branch. If there are prior commits suggesting a previous review cycle (e.g., review-driven refactors, reverted changes), note what was changed and whether the current plan touches the same areas. Be more aggressive reviewing areas that were previously problematic.
## Formatting rules
* NUMBER issues (1, 2, 3...) and give LETTERS for options (A, B, C...).
* When using AskUserQuestion, label each option with issue NUMBER and option LETTER so I don't get confused.
* Recommended option is always listed first.
* Keep each option to one sentence max. I should be able to pick in under 5 seconds.
* After each review section, pause and ask for feedback before moving on.
## Unresolved decisions
If the user does not respond to an AskUserQuestion or interrupts to move on, note which decisions were left unresolved. At the end of the review, list these as "Unresolved decisions that may bite you later" — never silently default to an option.
You are in PLAN MODE for a coding task.
CRITICAL CONSTRAINTS:
1) READ-ONLY behavior only.
2) Do NOT modify files.
3) Do NOT run install commands.
4) Do NOT run git mutation commands (commit/push/merge/rebase/reset/checkout -b/cherry-pick).
5) Do NOT claim work was implemented.
6) If information is missing, state assumptions explicitly.
7) Do NOT run file-mutation commands (`touch`, `mkdir`, `rm`, `mv`, `cp`, `sed -i`, redirection `>`/`>>`, heredocs that write files).
8) Read-only shell usage is allowed for evidence gathering only (`ls`, `rg`, `cat`, `git status`, `git log`, `git diff`).
OUTPUT CONTRACT:
- Return ONLY markdown.
- Use EXACT section headers and order from the required schema below.
- No extra sections.
- No preamble, no epilogue.
- Keep content concrete, testable, and implementation-ready.
- Include exact commands where requested.
- Use concise bullets; avoid fluff.
REQUIRED SCHEMA (EXACT):
# Plan: <short title>
## Fast-Path
- Eligible: yes|no
- Reason: <one sentence>
## 1. Problem statement
<content>
## 2. Current state evidence
- Files:
- `<path>#Lx-Ly` — <why relevant>
- Commands run:
- `<command>`
- Observations:
- <bullet>
## 3. Proposed approach
<content>
## 4. Step-by-step change list
1. <step>
2. <step>
## 5. Risks + rollback
- Risks:
- <risk>
- Rollback:
- <exact rollback command/process>
## 6. Test plan
- Automated:
- `<exact command>`
- Manual:
- <manual check>
- Success criteria:
- <bullet>
## 7. Out-of-scope
- <bullet>
## 8. Approval prompt
Reply with one:
- `APPROVE: <plan-id>`
- `REVISE: <what to change>`
QUALITY BAR:
- Evidence must reference real files/commands (or explicitly say “not verified”).
- Step list must be actionable and sequenced.
- Include a "Critical files for implementation" list (3-5 files with one-line reason each) inside the plan body.
- Test plan must be executable.
- If task is trivial, still fill all sections; mark Fast-Path Eligible: yes.
Plan: <short title>
Fast-Path
- Eligible: yes|no
- Reason: <one sentence>
1. Problem statement
2. Current state evidence
- Files:
<path>#Lx-Ly— <why relevant>- Commands run:
<command>- Observations:
- <bullet>
3. Proposed approach
4. Step-by-step change list
1. <step> 2. <step>
5. Risks + rollback
- Risks:
- <risk>
- Rollback:
- <exact rollback command/process>
6. Test plan
- Automated:
<exact command>- Manual:
- <manual check>
- Success criteria:
- <bullet>
7. Out-of-scope
- <bullet>
8. Approval prompt
Reply with one:
APPROVE: <plan-id>REVISE: <what to change>
Tooling and Timeouts
Plan-First Gate
For non-trivial changes: 1. Produce a plan first. 2. Wait for explicit APPROVE. 3. Execute implementation commands only after approval.
Approach Comparison
| Method | Reliability | Output | Best For |
|---|---|---|---|
ACPX (acpx <agent> exec) | ⚠️ Medium | Quiet assistant text | ACP harness-first execution and relay flows |
Direct Codex CLI (exec + resume) | ✅ High | Text/JSON stream | Most implementation loops and iterative follow-ups |
| tmux transport + Codex CLI | ✅ High | Full TTY + logs | Long-running tasks requiring reattach and terminal durability |
| Claude CLI fallback | ⚠️ Medium | Text stream | When Codex is unavailable |
Execution Policy Matrix
| Task | Primary | Secondary | Notes |
|---|---|---|---|
| Plan mode | scripts/code-plan --engine codex | scripts/code-plan --engine claude | Read-only planning artifact + approval gate |
| Implementation | ACPX (safe-fallback.sh ACP-first) | direct/tmux Codex CLI | Use CLI fallback when ACP is unavailable; lower reasoning only for simple/docs or explicit fast/cheap requests |
| PR review | codex review --base <base> | ACPX then Claude CLI | Keep timeout >= 600s |
| Long-running implementation | tmux transport | direct codex -c 'model_reasoning_effort="high"' exec --full-auto | Use tmux when persistence/reattach is required |
Implementation routing is configurable:
CODING_AGENT_IMPL_MODE=direct-> direct first, tmux secondCODING_AGENT_IMPL_MODE=tmux-> tmux first, direct secondCODING_AGENT_IMPL_MODE=auto-> tmux first only when attached to an interactive TTY and tmux exists
Default behavior: direct.
Direct CLI (Primary)
Agent CLIs support non-interactive execution with session resume and approval-aware modes.
Reasoning defaults for Codex implementation:
highfor feature implementation and architectural refactors.medium/lowfor simple fixes, docs-only work, or explicit fast/cheap requests.
Codex CLI
| Command | Purpose |
|---|---|
codex -c 'model_reasoning_effort="high"' exec --full-auto "prompt" | Guardrailed implementation (feature/refactor default) |
codex exec resume --last "follow-up" | Resume previous context |
codex review --base <base> | Code review against base branch |
codex exec --json "prompt" | Structured event stream for automation |
codex exec --output-last-message /tmp/last.txt "prompt" | Persist final response for wrappers/scripts |
Claude Code CLI
| Command | Purpose |
|---|---|
claude -p --permission-mode acceptEdits "prompt" | Guardrailed implementation fallback |
claude -p --model opus "prompt" | Complex fallback task |
claude -p -c "follow up" | Continue most recent session |
claude -p --resume <id> "follow up" | Resume specific session |
claude --resume | Interactive session picker |
Approval Modes
| CLI | Flag | Behavior |
|---|---|---|
| Codex | --full-auto | Lower-friction sandboxed automation |
| Codex | --dangerously-bypass-approvals-and-sandbox | Explicit bypass (only by user request) |
| Claude | --permission-mode acceptEdits | Auto-accept file edits only |
| Claude | --permission-mode bypassPermissions | Explicit bypass (only by user request) |
Session Management
| CLI | Command | Purpose |
|---|---|---|
| Codex | codex exec resume --last | Resume last session |
| Claude | claude -p -c "prompt" | Continue most recent conversation |
| Claude | claude -p --resume <id> "prompt" | Resume specific session by ID |
| Claude | claude --resume | Interactive session picker |
Sessions persist to disk (~/.codex/sessions/ and ~/.claude/projects/<project>/) and survive process restarts.
MCP Clarification
Two MCP modes exist and should not be conflated:
1. codex mcp ...
- Adds external MCP tools for Codex to use during a run.
2. codex mcp-server
- Exposes Codex itself as an MCP server for another orchestrator.
- Experimental; use behind feature flags/pilots.
Preflight Checks
Run preflight before wrapper use:
./scripts/doctorRun CLI drift checks before changing command docs:
./scripts/doc-drift-checkscripts/doctor checks:
codexghtimeout- Claude binary resolution in this order:
CODING_AGENT_CLAUDE_BIN->~/.claude/local/claude->claudeinPATH - ACPX discovery in this order:
CODING_AGENT_ACPX_CMD->acpxinPATH(warning-only; CLI fallback remains available)
Wrapper Scripts (Plan + Implementation)
# Plan mode wrapper (read-only)
"${CODING_AGENT_DIR:-./}/scripts/code-plan" --engine codex --repo /path/to/repo "Implement feature X"
# Implementation (tmux transport wrapper)
"${CODING_AGENT_DIR:-./}/scripts/code-implement" "Implement feature X in /path/to/repo"
# Execute an approved plan artifact
"${CODING_AGENT_DIR:-./}/scripts/code-implement" --plan /path/to/repo/.ai/plans/<plan>.mdFor review-first behavior, use direct CLI:
# Detect base branch: main, master, or trunk (whichever exists)
timeout 600s codex review --base <base> --title "Review PR #N"Validate wrappers locally:
./scripts/smoke-wrappers.shAdvanced: tmux Wrapper (Optional)
For durable TTY sessions with logging. Use when you need to monitor long-running tasks or preserve terminal output.
tmux Conventions (OpenClaw)
- Socket directory:
OPENCLAW_TMUX_SOCKET_DIR(legacy:CLAWDBOT_TMUX_SOCKET_DIR) - Default socket:
${TMPDIR:-/tmp}/openclaw-tmux-sockets/openclaw.sock - Send commands literally:
tmux ... send-keys -l -- "cmd" - Always print monitor commands after creating a session
Direct tmux Usage
SOCKET_DIR="${OPENCLAW_TMUX_SOCKET_DIR:-${CLAWDBOT_TMUX_SOCKET_DIR:-${TMPDIR:-/tmp}/openclaw-tmux-sockets}}"
mkdir -p "$SOCKET_DIR"
SOCKET="$SOCKET_DIR/openclaw.sock"
SESSION="codex-impl-$(date +%Y%m%d-%H%M%S)"
# Start session and run codex
tmux -S "$SOCKET" new-session -d -s "$SESSION" -n shell
TARGET="$(tmux -S "$SOCKET" list-panes -t "$SESSION" -F "#{session_name}:#{window_index}.#{pane_index}" | head -n 1)"
tmux -S "$SOCKET" send-keys -t "$TARGET" -l -- "codex -c 'model_reasoning_effort=\"high\"' exec --full-auto 'Implement feature X'"
tmux -S "$SOCKET" send-keys -t "$TARGET" Enter
# Monitor
tmux -S "$SOCKET" attach -t "$SESSION"
tmux -S "$SOCKET" capture-pane -p -J -t "$TARGET" -S -200tmux-run Helper
scripts/tmux-run standardizes sockets, logging, and session names. Non-blocking by default unless --wait is passed.
# Run an implementation command in tmux (non-blocking)
CODEX_TMUX_SESSION_PREFIX=codex-impl \
./scripts/tmux-run timeout 180s codex -c 'model_reasoning_effort="high"' exec --full-auto "Implement feature X"
# Run a long implementation in tmux and wait for completion
CODEX_TMUX_SESSION_PREFIX=codex-impl \
./scripts/tmux-run --wait timeout 600s codex -c 'model_reasoning_effort="high"' exec --full-auto "Complex multi-file refactor"Logs: ${XDG_STATE_HOME:-$HOME/.local/state}/openclaw/tmux/<session>.log
Cleanup:
- Kill session:
tmux -S "$SOCKET" kill-session -t "$SESSION" - Remove old logs:
find "$LOG_DIR" -type f -mtime +7 -delete
Minimum Timeouts
| Task Type | Minimum | Default |
|---|---|---|
| Code review | 600s | 600s |
| Architectural review | 600s | 600s |
| Single-file implementation | 120s | 180s |
| Multi-file implementation | 300s | 600s |
Environment Variables
| Variable | Purpose | Default |
|---|---|---|
CODING_AGENT_IMPL_MODE | Implementation routing policy (`direct | tmux |
CODING_AGENT_ACP_ENABLE | Enable ACP-first attempt in safe-fallback.sh (`0 | 1`) |
CODING_AGENT_ACP_AGENT | ACP harness alias for ACPX execution | codex |
CODING_AGENT_ACPX_CMD | Explicit ACPX binary path override | unset |
CODING_AGENT_VERBOSE | Execution progress verbosity (off by default; truthy: `1 | true |
CODING_AGENT_CLAUDE_BIN | Explicit Claude CLI path override | unset |
OPENCLAW_TMUX_SOCKET_DIR | Socket directory (preferred) | ${TMPDIR:-/tmp}/openclaw-tmux-sockets |
CLAWDBOT_TMUX_SOCKET_DIR | Legacy socket directory | unset |
CODEX_TMUX_SOCKET_DIR | Explicit socket directory override | unset |
CODEX_TMUX_SOCKET | Explicit socket path | ${OPENCLAW_TMUX_SOCKET_DIR}/openclaw.sock |
CODEX_TMUX_SESSION | Explicit session name | autogenerated |
CODEX_TMUX_SESSION_PREFIX | Session name prefix | codex |
CODEX_TMUX_LOG_DIR | Log directory | ${XDG_STATE_HOME:-$HOME/.local/state}/openclaw/tmux |
CODEX_TMUX_WAIT | Block until command finishes | 0 |
CODEX_TMUX_CLEANUP | Kill session after completion | 0 |
CODEX_TMUX_WAIT_TIMEOUT | Optional wait timeout (seconds) | unset |
CODEX_TMUX_DISABLE | Legacy override: force direct mode | 0 |
CODEX_TMUX_REQUIRED | Legacy override: force tmux mode | 0 |
GEMINI_FALLBACK_ENABLE | Enable Gemini fallback in safe-fallback.sh | 0 |
CODE_IMPLEMENT_TIMEOUT | Implement wrapper timeout (ms) | 180000 |
Coding Workflow & Operations
Contents
- Overview
- Git Workflow
- Hard Requirements (Violation = Task Failure)
- Self-Audit Protocol
- GitHub CLI (gh)
- Agent Workflow
- Multi-Phase Workflow (Session Resume)
- Agent CLI Reference
- Agent Utilization
Overview
Roles:
- @kesslerIO (Martin): Human Owner. Approves P0/P1 changes.
- @niemandBot (Niemand): AI Agent. Reviews code, runs checks, implements features.
Philosophy:
- Plan First: Always discuss approach before implementation.
- Approval Gate: For non-trivial changes, wait for explicit
APPROVEbefore writing files. - Surface Decisions: Present options with trade-offs.
- Confirm Alignment: Ensure agreement before coding.
- No Direct Edits: Use agent CLIs (Codex/Claude) to write code.
Channel Alias Notes
Some channels expose aliases (/coding, /plan, /plan-review, /plan-review-live, /review_pr). These aliases do not change core policy:
- Plan-first for non-trivial work
- Explicit approval gate before writes
- No bypass-by-default flags unless the user explicitly requests bypass.
- Plan completion is approved through explicit
APPROVEreply (there is no separateExitPlanModetool call in this repo flow).
Review Routing + Run Status (Hard Rules)
- Plan artifact reviews must use wrappers first:
scripts/plan-revieworscripts/plan-review-live. - PR/code reviews must use
codex review --base ...(orsafe-review.shwrapper). - Do not send manual review findings before the matching review command executes.
- For runs >30 seconds, emit wrapper status updates every 20 seconds.
- On interruption/timeout/signal, emit immediate interruption status with exit code and remediation command.
Git Workflow
Note: Niemand does NOT create branches, commit code, or merge PRs unless explicitly requested.
Standard Flow
1. Create Branch: git checkout -b type/description 2. Implement: Use agent CLI (see below) 3. Commit: git commit -m "type(scope): description" 4. Push: git push -u origin branch-name 5. PR: gh pr create 6. Review: Run code review (see below) 7. Fix: Address issues (resume session for context) 8. Merge: gh pr merge
Commit Types
feat: New featurefix: Bug fixdocs: Documentation onlystyle: Formatting (no code change)refactor: Restructuring code (no API change)test: Adding testschore: Build/tooling changes
Hard Requirements (Violation = Task Failure)
These are non-negotiable requirements. Violating any of these means the task has FAILED.
1. Branch Requirement
- MUST create feature branch before any code changes
- MUST NOT commit directly to main
- Violation Response: Stop and ask user to confirm branch creation
2. PR Requirement
- MUST create PR before code can be considered "done"
- MUST post review to PR before merge
- MUST include PR URL in task completion message
- Violation Response: Refuse to mark task complete without PR URL
3. Tool Usage Requirement
- When user specifies "use claude/codex/gemini": MUST use that CLI tool when available/configured
- MUST use agent CLI (direct or tmux wrappers) — not direct file edits
- For reviews: use direct
codex review --base <base>orclaude -p - For implementation: prefer direct CLI (
codex -c 'model_reasoning_effort="high"' exec --full-auto) orscripts/code-implement - When using
scripts/safe-fallback.sh, wrappers attempt ACP first (acpx) and then use CLI fallback chain. - Default reasoning policy: use
highfor feature implementation and architectural refactors; usemedium/lowonly for simple fixes/docs or explicit fast/cheap requests - MUST NOT use direct file edits when agent CLI is specified
- MUST document which tool was used in PR description
- Violation Response: Stop and switch to specified tool
4. Review Requirement
- MUST run code review before merge
- MUST run standards review (references/STANDARDS.md) before merge
- MUST post both reviews to GitHub PR
- Violation Response: Block merge until reviews are posted
5. Self-Audit Requirement
- MUST run self-audit before reporting completion when code/config/docs commands were changed
- MUST use findings-first format with severity order and file:line references for review tasks
- MUST verify changed command examples or explicitly mark them unverified
- Violation Response: Do not mark complete; run audit and report gaps
Self-Check Before Completion
Before reporting task complete, verify:
- [ ] Changes on feature branch (not main)?
- [ ] PR created and URL available?
- [ ] Correct tools used (agent CLI, direct or tmux)?
- [ ] Code review completed and posted?
- [ ] Standards review completed and posted?
- [ ] User-facing long-form text passed through
/humanizer(or explicit fallback noted)? - [ ] Self-audit completed (or explicit skip reason documented)?
Self-Audit Protocol
Run this before final response unless skip conditions apply.
When Required
- Code/config changed.
- Tests changed or should have changed.
- Review requested by user.
- Docs changed with executable commands/examples.
Skip Conditions
- Informational response only, no repo changes.
- User requested raw command output only.
If skipped, explicitly state why.
Phase 1: Implementation Audit
- [ ] Requirement coverage checked against user request.
- [ ] Edge cases and failure paths reviewed.
- [ ] Tests added/updated or explicit rationale for none.
- [ ] Risky assumptions called out.
Phase 2: Review Audit
- [ ] Findings ordered by severity (P0-P3).
- [ ] Every finding includes file:line reference.
- [ ] Regressions/unintended side effects checked.
- [ ] Changed docs commands/examples verified; if not run, mark
UNVERIFIED.
Final Response Contract
Use this block in completion messages:
## Self-Audit Summary
- Audit status: complete | skipped (reason)
- Tests run:
- `command ...`
- Residual risks:
- ...
- Assumptions:
- ...
- Command/docs verification:
- VERIFIED: ...
- UNVERIFIED: ...GitHub CLI (gh)
Authentication
- Check status:
gh auth status - Login:
gh auth login(uses PAT or browser) - Switch account:
gh auth switch --user <username>
Common Commands
- Create PR:
gh pr create --title "feat: ..." --body "..." - View PR:
gh pr view <number> - Checkout PR:
gh pr checkout <number> - Review PR:
gh pr review <number> --approve - Merge PR:
gh pr merge <number> --admin --merge --delete-branch
Issue/PR Hygiene (Required)
- Keep one logical change per PR.
- Search before opening issues:
gh issue list --search "<keywords>". - PR title default:
type(scope): imperative summary(unless repo override). - Issue title defaults:
- Feature:
feat: <capability> (for <surface>) - Bug:
bug: <symptom> when <condition> - Tracking:
TODO: <cleanup> after <dependency> - PR body sections (required):
What,Why,Tests,AI Assistance. Tests: list exact commands run.AI Assistance: used/not used, testing level, prompt/session log link, and "I understand this code."
Agent Workflow
Primary: Direct CLI
Use agent CLIs directly for most tasks. Session resume preserves full context across phases and is preferred over spawning sub-agents for routine implementation.
# Implementation (Codex)
codex -c 'model_reasoning_effort="high"' exec --full-auto "Implement feature X according to approved plan."
# Implementation (Claude)
claude -p --permission-mode acceptEdits "Implement feature X"
# Review (Codex)
codex review --base <base> --title "PR Review"
# Review (Claude)
claude -p --model opus "Review changes vs main branch for bugs, security, quality"Secondary: tmux Wrappers
For durable implementation sessions with logging and monitoring:
# Implementation (tmux)
./scripts/code-implement "Implement feature X in /path/to/repo"Plan Mode Wrapper
For non-trivial work, generate a plan artifact before implementation:
./scripts/plan --engine codex --repo /path/to/repo "Implement feature X"
./scripts/plan-review --repo /path/to/repo
./scripts/plan-review-live --repo /path/to/repo
# Force legacy engine (bypass Lobster workflow path)
./scripts/plan-review-live --engine legacy --repo /path/to/repo
# Non-TTY/chat-safe finalization:
./scripts/plan-review-live --repo /path/to/repo --decisions "1A,2B,3A,4A" --blocking none
# Or:
./scripts/plan-review-live --repo /path/to/repo --resolve-file /path/to/decisions.json
./scripts/code-implement --plan /path/to/repo/.ai/plans/<plan>.mdcode-implement --plan now enforces the latest per-plan review metadata gate. plan-review-live uses the in-repo Lobster workflow by default and falls back to the legacy live-review engine when Lobster is unavailable. Use plan-review-live to resolve blocking decisions before execution, or --force to bypass explicitly.
Code Review Process
Hierarchy: 1. Codex: Primary reviewer (codex review --base <base>). 2. ACPX: Review fallback path through harness routing. 3. Claude: Secondary CLI fallback if Codex is unavailable. 4. Gemini (optional): Only if explicitly enabled (GEMINI_FALLBACK_ENABLE=1). 5. Sub-agent: Last resort for orchestration.
Step 1: Code Review (Logic/Bugs)
gh pr checkout <PR>
timeout 600s codex review --base <base> --title "PR #N Review"Step 2: Standards Review (Required)
codex exec --full-auto --model gpt-5.3-codex \
-c model_reasoning_effort="medium" "Review against STANDARDS.md..."Step 3: Posting Results
gh pr review <PR> --comment --body "$(cat review.md)"Multi-Phase Workflow (Session Resume)
For complex tasks spanning multiple phases, use session resume to preserve full context:
Issue → Implement → PR → Review → Fix → Merge
# Phase 1: Implement from issue
codex -c 'model_reasoning_effort="high"' exec --full-auto "Implement feature described in issue #42 according to approved plan."
# Phase 2: Create PR
gh pr create --title "feat(auth): add JWT validation" --body "..."
# Phase 3: Review
timeout 600s codex review --base <base> --title "Review PR #N"
# Phase 4: Fix review findings (resume preserves context)
codex exec resume --last
# Or with Claude:
claude -p --resume <session-id> "Fix the review findings"
# Phase 5: Re-review after fixes
timeout 600s codex review --base <base> --title "Re-review PR #N"
# Phase 6: Merge
gh pr merge --merge --delete-branchSession Resume Commands
| Phase | Codex | Claude Code |
|---|---|---|
| Resume last | codex exec resume --last | claude -p -c "prompt" |
| Resume specific | codex exec resume <id> | claude -p --resume <id> "prompt" |
| List/pick session | — | claude --resume (interactive picker) |
Codex resume compatibility note:
- Preferred:
codex exec resume --lastorcodex exec resume <id>. - If your installed Codex build does not support
resume, start a fresh run and reference the prior issue/PR context explicitly.
When to Resume vs Start Fresh
- Resume: Fix review findings, continue implementation, follow-up on same codebase
- Fresh: New issue, different repo, unrelated task
Base Branch Detection (<base>)
Use this order:
# Primary
git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@'
# Fallback (when origin/HEAD is unset)
git remote show origin | sed -n '/HEAD branch/s/.*: //p'Prompt Engineering Best Practices
- Be Specific: "Implement X using Y library" vs "Add X".
- Use Explicit Gate: "Plan first; execute only after I reply APPROVE."
- Small Batches: Don't change 50 files at once.
- Clear Exit: "Reply with DONE when finished."
Agent CLI Reference
Codex CLI
For automated runs after approval:
# Implementation (post-approval)
codex -c 'model_reasoning_effort="high"' exec --full-auto "Implement feature X based on approved plan."
# Simple fix/docs or explicit fast/cheap request
codex -c 'model_reasoning_effort="medium"' exec --full-auto "Fix typo in one file"
codex -c 'model_reasoning_effort="low"' exec --full-auto "Update README command example quickly"
# Resume last session
codex exec resume --lastClaude Code CLI
# Implementation (post-approval)
claude -p --permission-mode acceptEdits "Implement feature X"
# With model selection
claude -p --model opus --permission-mode acceptEdits "Complex task"
# Resume/continue
claude -p -c "Follow up on the previous task"
claude -p --resume <session-id> "Continue from here"See references/claude-code.md for full Claude Code reference. See references/codex-cli.md for canonical Codex execution policy (exec, resume, MCP distinctions). See references/tooling.md for tmux wrappers, timeouts, and environment variables.
Agent Utilization
Delegate specific tasks to focused agents only when decomposition is clear and parallelizable:
- requirements-specialist: Specs → GitHub Issues
- implementation-architect: API/UI Design
- quality-assurance-specialist: Tests, Security, Perf
- docs-architect: Documentation updates
Trigger: Use sub-agents for independent tracks (for example: separate security/performance/test review streams). Keep single-agent codex exec + codex exec resume as the default path for implementation loops.
Sub-agent note:
- Codex multi-agent workflows are experimental.
- Non-interactive approval handling can fail if sub-agents request escalation unexpectedly.
#!/usr/bin/env bash
# code-implement - Wrapper for code implementation with proper timeout
#
# Usage:
# code-implement "Implement feature X in /path/to/project"
# code-implement --plan .ai/plans/<plan>.md [--force]
set -euo pipefail
export PATH="$PATH:/run/current-system/sw/bin"
usage() {
cat >&2 <<'USAGE'
Usage:
code-implement "<prompt>"
code-implement --plan <path> [--force]
USAGE
}
PLAN_PATH=""
FORCE=0
PROMPT=""
EXEC_REPO="$(pwd)"
while [[ $# -gt 0 ]]; do
case "$1" in
--plan)
PLAN_PATH="${2:-}"
shift 2
;;
--force)
FORCE=1
shift
;;
-h|--help)
usage
exit 0
;;
--)
shift
break
;;
*)
if [[ -z "$PROMPT" ]]; then
PROMPT="$1"
else
PROMPT="$PROMPT $1"
fi
shift
;;
esac
done
if [[ $# -gt 0 ]]; then
if [[ -z "$PROMPT" ]]; then
PROMPT="$*"
else
PROMPT="$PROMPT $*"
fi
fi
if [[ -n "$PLAN_PATH" && -n "$PROMPT" ]]; then
echo "Error: provide either --plan or a prompt, not both" >&2
exit 1
fi
if [[ -z "$PLAN_PATH" && -z "$PROMPT" ]]; then
usage
exit 1
fi
TIMEOUT_MS="${CODE_IMPLEMENT_TIMEOUT:-180000}"
if [[ ! "$TIMEOUT_MS" =~ ^[0-9]+$ ]]; then
echo "Error: CODE_IMPLEMENT_TIMEOUT must be a number (milliseconds)" >&2
echo "Got: $TIMEOUT_MS" >&2
exit 1
fi
TIMEOUT_SEC=$((TIMEOUT_MS / 1000))
get_frontmatter_field() {
local file="$1"
local key="$2"
awk -F': ' -v wanted="$key" '
BEGIN { in_fm=0 }
$0 == "---" {
if (in_fm == 0) { in_fm=1; next }
else { exit }
}
in_fm == 1 {
if (index($0, wanted ":") == 1) {
sub("^[^:]+:[ ]*", "", $0)
print $0
exit
}
}
' "$file"
}
set_frontmatter_field() {
local file="$1"
local key="$2"
local value="$3"
local tmp
tmp="$(mktemp)"
awk -v k="$key" -v v="$value" '
BEGIN { in_fm=0; replaced=0 }
$0 == "---" {
if (in_fm == 0) { in_fm=1; print; next }
if (in_fm == 1) {
if (replaced == 0) { print k ": " v }
in_fm=2
print
next
}
}
in_fm == 1 {
if (index($0, k ":") == 1) {
print k ": " v
replaced=1
next
}
}
{ print }
' "$file" > "$tmp"
mv "$tmp" "$file"
}
json_extract_string() {
local file="$1"
local key="$2"
sed -nE "s/^[[:space:]]*\"${key}\"[[:space:]]*:[[:space:]]*\"([^\"]*)\"[[:space:]]*,?[[:space:]]*$/\1/p" "$file" | head -n 1
}
json_extract_bool() {
local file="$1"
local key="$2"
sed -nE "s/^[[:space:]]*\"${key}\"[[:space:]]*:[[:space:]]*(true|false)[[:space:]]*,?[[:space:]]*$/\1/p" "$file" | head -n 1
}
json_extract_number() {
local file="$1"
local key="$2"
sed -nE "s/^[[:space:]]*\"${key}\"[[:space:]]*:[[:space:]]*([0-9]+)[[:space:]]*,?[[:space:]]*$/\1/p" "$file" | head -n 1
}
json_array_length() {
local file="$1"
local key="$2"
local line
local content
line="$(grep -m1 "\"${key}\"" "$file" || true)"
if [[ -z "$line" ]]; then
echo "-1"
return 0
fi
content="$(printf '%s\n' "$line" | sed -nE "s/^[[:space:]]*\"${key}\"[[:space:]]*:[[:space:]]*\\[(.*)\\][[:space:]]*,?[[:space:]]*$/\1/p")"
if [[ -z "$content" && "$line" != *"[]"* ]]; then
echo "-1"
return 0
fi
if [[ -z "$content" ]]; then
echo "0"
return 0
fi
printf '%s\n' "$content" | grep -o '"[^"]*"' | wc -l | tr -d '[:space:]'
}
review_gate_blocked() {
local message="$1"
local plan_path="$2"
echo "Error: review gate blocked implementation." >&2
echo "Reason: $message" >&2
echo "Remediation:" >&2
echo " 1) Run interactive review to resolve blocking decisions:" >&2
echo " ./scripts/plan-review-live --plan $plan_path" >&2
echo " 2) Or run batch review to refresh report context:" >&2
echo " ./scripts/plan-review --plan $plan_path" >&2
echo " 3) Use --force only when you explicitly accept bypass risk." >&2
exit 1
}
validate_review_gate() {
local plan_path="$1"
local plan_id="$2"
local repo_path="$3"
local metadata_file
local schema_version
local metadata_plan_id
local metadata_plan_path
local metadata_mode
local ready
local created_at
local review_markdown_path
local blocking_count
metadata_file="$repo_path/.ai/plan-reviews/latest-${plan_id}.json"
if [[ ! -f "$metadata_file" ]]; then
review_gate_blocked "Missing review metadata: $metadata_file" "$plan_path"
fi
schema_version="$(json_extract_number "$metadata_file" "schema_version")"
metadata_plan_id="$(json_extract_string "$metadata_file" "plan_id")"
metadata_plan_path="$(json_extract_string "$metadata_file" "plan_path")"
metadata_mode="$(json_extract_string "$metadata_file" "mode")"
ready="$(json_extract_bool "$metadata_file" "ready_for_implementation")"
created_at="$(json_extract_string "$metadata_file" "created_at")"
review_markdown_path="$(json_extract_string "$metadata_file" "review_markdown_path")"
blocking_count="$(json_array_length "$metadata_file" "blocking_decisions")"
if [[ "$schema_version" != "1" ]]; then
review_gate_blocked "Invalid schema_version in $metadata_file (expected 1)." "$plan_path"
fi
if [[ -z "$metadata_plan_id" || "$metadata_plan_id" != "$plan_id" ]]; then
review_gate_blocked "Metadata plan_id mismatch in $metadata_file." "$plan_path"
fi
if [[ -z "$metadata_plan_path" || "$metadata_plan_path" != "$plan_path" ]]; then
review_gate_blocked "Metadata plan_path mismatch in $metadata_file." "$plan_path"
fi
if [[ "$metadata_mode" != "batch" && "$metadata_mode" != "live" ]]; then
review_gate_blocked "Invalid mode in $metadata_file (expected batch/live)." "$plan_path"
fi
if [[ "$ready" != "true" && "$ready" != "false" ]]; then
review_gate_blocked "Invalid ready_for_implementation in $metadata_file." "$plan_path"
fi
if [[ -z "$created_at" ]]; then
review_gate_blocked "Missing created_at in $metadata_file." "$plan_path"
fi
if [[ -z "$review_markdown_path" || ! -f "$review_markdown_path" ]]; then
review_gate_blocked "Missing review_markdown_path target in $metadata_file." "$plan_path"
fi
if [[ "$ready" != "true" ]]; then
review_gate_blocked "Latest review is not ready for implementation (ready_for_implementation=false)." "$plan_path"
fi
if [[ ! "$blocking_count" =~ ^-?[0-9]+$ ]] || (( blocking_count < 0 )); then
review_gate_blocked "Invalid blocking_decisions array in $metadata_file." "$plan_path"
fi
if (( blocking_count > 0 )); then
review_gate_blocked "Latest review still has unresolved blocking_decisions." "$plan_path"
fi
}
if [[ -n "$PLAN_PATH" ]]; then
if [[ ! -f "$PLAN_PATH" ]]; then
echo "Error: plan file not found: $PLAN_PATH" >&2
exit 1
fi
PLAN_PATH="$(cd "$(dirname "$PLAN_PATH")" && pwd)/$(basename "$PLAN_PATH")"
status="$(get_frontmatter_field "$PLAN_PATH" "status")"
plan_id="$(get_frontmatter_field "$PLAN_PATH" "id")"
if [[ -z "$plan_id" ]]; then
plan_id="$(basename "$PLAN_PATH" .md)"
fi
repo_from_plan="$(get_frontmatter_field "$PLAN_PATH" "repo_path")"
if [[ -n "$repo_from_plan" ]]; then
if ! git -C "$repo_from_plan" rev-parse --git-dir >/dev/null 2>&1; then
echo "Error: repo_path from plan is not a git repo: $repo_from_plan" >&2
exit 1
fi
EXEC_REPO="$repo_from_plan"
fi
if [[ "$status" != "APPROVED" && "$FORCE" != "1" ]]; then
echo "⚠️ Plan $plan_id is currently ${status:-PENDING}."
read -r -p "Do you approve this plan for execution? [y/N/revise] " answer
case "${answer,,}" in
y|yes)
set_frontmatter_field "$PLAN_PATH" "status" "APPROVED"
set_frontmatter_field "$PLAN_PATH" "approved_by" "${USER:-unknown}"
set_frontmatter_field "$PLAN_PATH" "approved_at" "$(date -Iseconds)"
;;
revise)
echo "Plan left unchanged. Revise by rerunning code-plan with updated guidance." >&2
exit 1
;;
*)
echo "Execution cancelled." >&2
exit 1
;;
esac
fi
status="$(get_frontmatter_field "$PLAN_PATH" "status")"
if [[ "$status" != "APPROVED" && "$FORCE" != "1" ]]; then
echo "Error: plan status must be APPROVED to execute. Use --force to bypass." >&2
exit 1
fi
if [[ "$FORCE" == "1" ]]; then
echo "⚠️ --force enabled: bypassing plan-review readiness gate." >&2
else
validate_review_gate "$PLAN_PATH" "$plan_id" "$EXEC_REPO"
fi
echo "Executing approved plan: $PLAN_PATH" >&2
plan_body="$(cat "$PLAN_PATH")"
PROMPT=$(cat <<EOF
Executing approved plan: $PLAN_PATH
Follow this plan exactly unless blocked by new evidence. If blocked, explain deviation and proceed with the safest minimal change set.
PLAN CONTENT:
$plan_body
EOF
)
fi
echo "Starting implementation in tmux with ${TIMEOUT_SEC}s timeout..." >&2
echo "Execution repository: $EXEC_REPO" >&2
if ! command -v codex &> /dev/null; then
echo "Error: codex CLI not found. Please install: npm install -g @openai/codex" >&2
exit 1
fi
if ! command -v tmux &> /dev/null; then
echo "Error: tmux not found. Install tmux or use a host with tmux available." >&2
exit 1
fi
if ! command -v timeout &> /dev/null; then
echo "Error: timeout command not found. Install coreutils (brew install coreutils on macOS)." >&2
exit 1
fi
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
TMUX_RUN="$SCRIPT_DIR/tmux-run"
if [[ ! -x "$TMUX_RUN" ]]; then
echo "Error: tmux-run not found or not executable: $TMUX_RUN" >&2
exit 1
fi
(
cd "$EXEC_REPO"
CODEX_TMUX_SESSION_PREFIX="${CODEX_TMUX_SESSION_PREFIX:-codex-impl}" \
"$TMUX_RUN" timeout "${TIMEOUT_SEC}s" codex exec --full-auto "$PROMPT"
)
#!/usr/bin/env bash
set -euo pipefail
export PATH="$PATH:/run/current-system/sw/bin"
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
ROOT_DIR="$(cd -- "$SCRIPT_DIR/.." && pwd)"
SYSTEM_PROMPT_FILE="$ROOT_DIR/references/templates/plan-system-prompt.txt"
# shellcheck disable=SC1091
source "$SCRIPT_DIR/lib/resolve-cli.sh"
usage() {
cat >&2 <<'USAGE'
Usage:
code-plan [--engine codex|claude] [--model <name>] [--repo <path>] [--base <branch>] [--prompt <text>]
code-plan [--engine codex|claude] [--model <name>] [--repo <path>] [--base <branch>] "<prompt>"
Defaults:
--engine codex
--repo current working directory
--base auto-detected origin default branch (fallback: main)
USAGE
}
ENGINE="${CODING_AGENT_PLAN_ENGINE:-codex}"
MODEL=""
REPO_PATH="$(pwd)"
BASE_BRANCH=""
PROMPT=""
STATUS_PING_SECONDS="${CODING_AGENT_STATUS_PING_SECONDS:-20}"
LONG_RUN_THRESHOLD_SECONDS="${CODING_AGENT_LONG_RUN_THRESHOLD_SECONDS:-30}"
CURRENT_CHILD_PID=""
emit_run_event() {
local event="$1"
local details="${2:-}"
if [[ -n "$details" ]]; then
echo "RUN_EVENT $event ts=$(date -Iseconds) $details" >&2
else
echo "RUN_EVENT $event ts=$(date -Iseconds)" >&2
fi
}
validate_positive_int() {
local value="$1"
local name="$2"
if [[ ! "$value" =~ ^[0-9]+$ ]] || (( value <= 0 )); then
echo "Error: $name must be a positive integer, got '$value'" >&2
exit 1
fi
}
handle_interrupt() {
local signal_name="$1"
emit_run_event "interrupted" "phase=code-plan signal=$signal_name"
if [[ -n "$CURRENT_CHILD_PID" ]] && kill -0 "$CURRENT_CHILD_PID" >/dev/null 2>&1; then
kill "-$signal_name" "$CURRENT_CHILD_PID" >/dev/null 2>&1 || true
fi
exit 130
}
run_command_with_status() {
local output_file="$1"
shift
local -a cmd=("$@")
local start_ts
local now_ts
local elapsed
local last_ping=0
local rc
start_ts="$(date +%s)"
emit_run_event "start" "phase=code-plan engine=$ENGINE repo=$REPO_PATH"
(
cd "$REPO_PATH"
"${cmd[@]}"
) > "$output_file" &
CURRENT_CHILD_PID=$!
while kill -0 "$CURRENT_CHILD_PID" >/dev/null 2>&1; do
now_ts="$(date +%s)"
elapsed=$((now_ts - start_ts))
if (( elapsed >= LONG_RUN_THRESHOLD_SECONDS )); then
if (( last_ping == 0 || now_ts - last_ping >= STATUS_PING_SECONDS )); then
emit_run_event "heartbeat" "phase=code-plan elapsed=${elapsed}s engine=$ENGINE"
last_ping="$now_ts"
fi
fi
sleep 1
done
set +e
wait "$CURRENT_CHILD_PID"
rc=$?
set -e
CURRENT_CHILD_PID=""
now_ts="$(date +%s)"
elapsed=$((now_ts - start_ts))
if [[ "$rc" == "0" ]]; then
emit_run_event "done" "phase=code-plan elapsed=${elapsed}s engine=$ENGINE"
elif [[ "$rc" == "130" || "$rc" == "143" || "$rc" == "124" || "$rc" == "137" ]]; then
emit_run_event "interrupted" "phase=code-plan exit_code=$rc elapsed=${elapsed}s engine=$ENGINE"
else
emit_run_event "failed" "phase=code-plan exit_code=$rc elapsed=${elapsed}s engine=$ENGINE"
fi
return "$rc"
}
trap 'handle_interrupt INT' INT
trap 'handle_interrupt TERM' TERM
while [[ $# -gt 0 ]]; do
case "$1" in
--engine)
ENGINE="${2:-}"
shift 2
;;
--model)
MODEL="${2:-}"
shift 2
;;
--repo)
REPO_PATH="${2:-}"
shift 2
;;
--base)
BASE_BRANCH="${2:-}"
shift 2
;;
--prompt)
PROMPT="${2:-}"
shift 2
;;
-h|--help)
usage
exit 0
;;
--)
shift
break
;;
*)
if [[ -z "$PROMPT" ]]; then
PROMPT="$1"
else
PROMPT="$PROMPT $1"
fi
shift
;;
esac
done
if [[ $# -gt 0 ]]; then
if [[ -z "$PROMPT" ]]; then
PROMPT="$*"
else
PROMPT="$PROMPT $*"
fi
fi
if [[ -z "$PROMPT" ]]; then
usage
exit 1
fi
if [[ "$ENGINE" != "codex" && "$ENGINE" != "claude" ]]; then
echo "Error: --engine must be codex or claude" >&2
exit 1
fi
validate_positive_int "$STATUS_PING_SECONDS" "CODING_AGENT_STATUS_PING_SECONDS"
validate_positive_int "$LONG_RUN_THRESHOLD_SECONDS" "CODING_AGENT_LONG_RUN_THRESHOLD_SECONDS"
REPO_PATH="$(cd "$REPO_PATH" && pwd)"
if ! git -C "$REPO_PATH" rev-parse --git-dir >/dev/null 2>&1; then
echo "Error: --repo must point to a git repository" >&2
exit 1
fi
if [[ -z "$BASE_BRANCH" ]]; then
BASE_BRANCH="$(git -C "$REPO_PATH" symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')"
fi
if [[ -z "$BASE_BRANCH" ]]; then
BASE_BRANCH="main"
fi
CURRENT_BRANCH="$(git -C "$REPO_PATH" rev-parse --abbrev-ref HEAD 2>/dev/null || echo unknown)"
HEAD_SHA="$(git -C "$REPO_PATH" rev-parse HEAD 2>/dev/null || echo unknown)"
REPO_REMOTE="$(git -C "$REPO_PATH" remote get-url origin 2>/dev/null || echo unknown)"
PLAN_DIR="$REPO_PATH/.ai/plans"
FAILED_DIR="$PLAN_DIR/.failed"
mkdir -p "$PLAN_DIR" "$FAILED_DIR"
TIMESTAMP="$(date +"%Y-%m-%d-%H%M%S")"
CREATED_AT="$(date -Iseconds)"
slugify() {
echo "$1" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//' | cut -c1-40
}
SLUG="$(slugify "$PROMPT")"
if [[ -z "$SLUG" ]]; then
SLUG="plan"
fi
PLAN_FILENAME="${TIMESTAMP}-${SLUG}.md"
PLAN_PATH="$PLAN_DIR/$PLAN_FILENAME"
FAILED_PATH="$FAILED_DIR/${TIMESTAMP}-${SLUG}.raw.md"
PLAN_ID="${PLAN_FILENAME%.md}"
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT
RAW_OUTPUT_FILE="$TMP_DIR/raw.md"
SYSTEM_PROMPT="$TMP_DIR/system_prompt.txt"
cat "$SYSTEM_PROMPT_FILE" > "$SYSTEM_PROMPT"
cat >> "$SYSTEM_PROMPT" <<EOF
TASK CONTEXT:
- Repository: $REPO_PATH
- Base branch: $BASE_BRANCH
- Current branch: $CURRENT_BRANCH
- Head SHA: $HEAD_SHA
USER REQUEST:
$PROMPT
EOF
prompt_payload="$(cat "$SYSTEM_PROMPT")"
if [[ "$ENGINE" == "codex" ]]; then
run_cmd=(codex exec --sandbox read-only --ephemeral)
if [[ -n "$MODEL" ]]; then
run_cmd+=(--model "$MODEL")
fi
run_cmd+=(-- "$prompt_payload")
else
if ! claude_bin="$(resolve_claude_bin)"; then
echo "Error: Claude CLI not found" >&2
exit 1
fi
run_cmd=("$claude_bin" -p --permission-mode plan --no-session-persistence)
if [[ -n "$MODEL" ]]; then
run_cmd+=(--model "$MODEL")
fi
run_cmd+=("$prompt_payload")
fi
set +e
run_command_with_status "$RAW_OUTPUT_FILE" "${run_cmd[@]}"
run_rc=$?
set -e
if [[ "$run_rc" != "0" ]]; then
if [[ "$run_rc" == "130" || "$run_rc" == "143" || "$run_rc" == "124" || "$run_rc" == "137" ]]; then
echo "⚠️ code-plan interrupted. Re-run the same command to continue." >&2
else
echo "❌ code-plan failed (exit $run_rc)." >&2
fi
exit "$run_rc"
fi
validate_headings() {
local file="$1"
local -a headings=(
"# Plan:"
"## Fast-Path"
"## 1. Problem statement"
"## 2. Current state evidence"
"## 3. Proposed approach"
"## 4. Step-by-step change list"
"## 5. Risks + rollback"
"## 6. Test plan"
"## 7. Out-of-scope"
"## 8. Approval prompt"
)
local prev=0
local found
for heading in "${headings[@]}"; do
found="$(grep -nF "$heading" "$file" | head -1 | cut -d: -f1 || true)"
if [[ -z "$found" ]]; then
echo "missing heading: $heading" >&2
return 1
fi
if (( found <= prev )); then
echo "heading out of order: $heading" >&2
return 1
fi
prev=$found
done
return 0
}
if ! validate_headings "$RAW_OUTPUT_FILE"; then
cp "$RAW_OUTPUT_FILE" "$FAILED_PATH"
echo "❌ Plan validation failed. Raw output saved to: $FAILED_PATH" >&2
exit 1
fi
{
echo "---"
echo "id: $PLAN_ID"
echo "status: PENDING"
echo "created_at: $CREATED_AT"
echo "repo_path: $REPO_PATH"
echo "repo_remote: $REPO_REMOTE"
echo "base_branch: $BASE_BRANCH"
echo "current_branch: $CURRENT_BRANCH"
echo "head_sha: $HEAD_SHA"
echo "engine: $ENGINE"
echo "model: ${MODEL:-default}"
echo "invocation: code-plan --engine $ENGINE${MODEL:+ --model $MODEL} --repo $REPO_PATH --base $BASE_BRANCH"
echo "approved_by:"
echo "approved_at:"
echo "---"
cat "$RAW_OUTPUT_FILE"
} > "$PLAN_PATH"
echo "✅ Plan generated: $PLAN_PATH"
echo "Next: code-implement --plan $PLAN_PATH"
#!/usr/bin/env bash
# doc-drift-check - verify documented Codex commands/flags still exist
set -euo pipefail
# Ensure standard tools are available on NixOS
export PATH="$PATH:/run/current-system/sw/bin"
if ! command -v codex >/dev/null 2>&1; then
if [[ "${CI:-}" == "true" || "${GITHUB_ACTIONS:-}" == "true" ]]; then
echo "[skip] codex not found in PATH; skipping doc drift checks in CI" >&2
exit 0
fi
echo "Error: codex not found in PATH" >&2
exit 1
fi
assert_contains() {
local haystack="$1"
local needle="$2"
local label="$3"
if ! grep -Fq -- "$needle" <<<"$haystack"; then
echo "[fail] missing '${needle}' in ${label}" >&2
return 1
fi
echo "[ok] ${label}: ${needle}" >&2
}
root_help="$(codex --help)"
exec_help="$(codex exec --help)"
review_help="$(codex review --help)"
resume_help="$(codex exec resume --help)"
mcp_help="$(codex mcp --help)"
assert_contains "$root_help" "exec" "codex --help"
assert_contains "$root_help" "review" "codex --help"
assert_contains "$root_help" "mcp" "codex --help"
assert_contains "$root_help" "mcp-server" "codex --help"
assert_contains "$root_help" "resume" "codex --help"
assert_contains "$exec_help" "--json" "codex exec --help"
assert_contains "$exec_help" "--output-schema" "codex exec --help"
assert_contains "$exec_help" "--output-last-message" "codex exec --help"
assert_contains "$exec_help" "--skip-git-repo-check" "codex exec --help"
assert_contains "$exec_help" "--full-auto" "codex exec --help"
assert_contains "$exec_help" "--dangerously-bypass-approvals-and-sandbox" "codex exec --help"
assert_contains "$review_help" "--base" "codex review --help"
assert_contains "$resume_help" "--last" "codex exec resume --help"
assert_contains "$mcp_help" "add" "codex mcp --help"
echo "Codex doc drift checks passed." >&2
#!/usr/bin/env bash
# doctor - preflight checks for OpenClaw coding skill wrappers
set -euo pipefail
# Ensure standard tools are available on NixOS
export PATH="$PATH:/run/current-system/sw/bin"
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck disable=SC1091
source "$SCRIPT_DIR/lib/resolve-cli.sh"
failures=0
check_cmd() {
local name="$1"
local remediation="$2"
if command -v "$name" &>/dev/null; then
printf '[ok] %s: %s\n' "$name" "$(command -v "$name")"
else
printf '[fail] %s: not found\n' "$name" >&2
printf ' Fix: %s\n' "$remediation" >&2
failures=$((failures + 1))
fi
}
printf 'OpenClaw wrapper preflight\n'
printf '==========================\n'
check_cmd "codex" "npm install -g @openai/codex"
check_cmd "gh" "brew install gh"
check_cmd "timeout" "brew install coreutils && mkdir -p \"$HOME/.local/bin\" && ln -sf \"\$(brew --prefix coreutils)/bin/gtimeout\" \"$HOME/.local/bin/timeout\""
if claude_bin="$(resolve_claude_bin)"; then
printf '[ok] claude: %s\n' "$claude_bin"
else
if [[ -n "${CODING_AGENT_CLAUDE_BIN:-}" ]]; then
printf '[fail] claude: CODING_AGENT_CLAUDE_BIN is set but not executable: %s\n' "${CODING_AGENT_CLAUDE_BIN}" >&2
printf ' Fix: unset CODING_AGENT_CLAUDE_BIN or point it to a valid Claude binary\n' >&2
else
printf '[fail] claude: not found (checked CODING_AGENT_CLAUDE_BIN, ~/.claude/local/claude, then PATH)\n' >&2
printf ' Fix (PATH install): npm install -g @anthropic-ai/claude-code\n' >&2
printf ' Fix (local binary): install/use ~/.claude/local/claude\n' >&2
fi
failures=$((failures + 1))
fi
if acpx_bin="$(resolve_acpx_bin)"; then
printf '[ok] acpx: %s\n' "$acpx_bin"
else
if [[ -n "${CODING_AGENT_ACPX_CMD:-}" ]]; then
printf '[warn] acpx: CODING_AGENT_ACPX_CMD is set but not executable: %s\n' "${CODING_AGENT_ACPX_CMD}" >&2
printf ' Fallback: wrappers will use direct CLI chain when ACP is unavailable\n' >&2
else
printf '[warn] acpx: not found (checked CODING_AGENT_ACPX_CMD, then PATH)\n' >&2
printf ' Fallback: wrappers will use direct CLI chain when ACP is unavailable\n' >&2
fi
fi
printf '[info] implementation mode default: %s (set CODING_AGENT_IMPL_MODE=direct|tmux|auto to override)\n' "${CODING_AGENT_IMPL_MODE:-direct}"
printf '[info] ACP-first routing: %s (set CODING_AGENT_ACP_ENABLE=0 to skip ACP attempt)\n' "${CODING_AGENT_ACP_ENABLE:-1}"
printf '[info] ACP agent alias: %s (set CODING_AGENT_ACP_AGENT to override)\n' "${CODING_AGENT_ACP_AGENT:-codex}"
verbose_mode="off"
case "${CODING_AGENT_VERBOSE:-}" in
1|[Tt][Rr][Uu][Ee]|[Oo][Nn]|[Yy][Ee][Ss]|[Vv][Ee][Rr][Bb][Oo][Ss][Ee])
verbose_mode="on"
;;
esac
printf '[info] progress verbosity: %s (set CODING_AGENT_VERBOSE=1 to enable Now/Why/Next updates)\n' "$verbose_mode"
if [[ "$failures" -gt 0 ]]; then
printf '\nPreflight failed with %s issue(s).\n' "$failures" >&2
exit 1
fi
printf '\nPreflight passed.\n'
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/code-plan" "$@"
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
exec "$SCRIPT_DIR/code-plan-review" "$@"
TODOs
PLAN_REVIEW_LIVE_ALLOW_NON_TTY deprecation check
- What: Evaluate deprecating
PLAN_REVIEW_LIVE_ALLOW_NON_TTYafter one release cycle. - Why:
plan-review-livenow supports explicit non-TTY resolution inputs (--resolve-fileor--decisions/--blocking) that are safer and more auditable. - Context: Added to close issue #30 (chat/non-TTY dead-end for
plan-review-live). - Depends on/blocked by: One stable release cycle of smoke + real chat automation runs with the new non-TTY apply path.
0.1.0