TL;DR
Route tasks by complexity: complex -> Thinking Partner + Devil's Advocate, teaching -> Teaching Mode + explain_code.py, simple -> direct execution. Map intent to workflow (build/fix/review/debug/docs). Use BMAD 4-phase for complex. Always end with Phase X quality gate.
Workflow Autopilot
Activation
- Activate after intent analysis is confirmed.
- Activate on explicit
$codex-workflow-autopilot or $route.
- Activate teaching mode on
$teach, "explain", or "walk me through".
- Activate Scrum overlay on backlog, story, sprint, review, retrospective, release-readiness, or shorthand commands such as
$sprint-plan, $story-ready-check, $retro, and $release-readiness.
- Activate reasoning rigor on
$codex-reasoning-rigor, $rigor, "don't be generic", "go deeper", "make it specific", or "use the repo, not generic advice".
- Activate on alias triggers:
$plan, $debug, $create, $prototype, $review, $deploy, $handoff, $refactor.
- When activated via alias, load the corresponding
.workflows/<name>.md file before executing the flow.
- Activate brainstorm mode on
$brainstorm, "brainstorm", "think through options", or "explore approaches".
- Activate review-feedback routing on
$review-feedback, "address review feedback", or "respond to code review".
- Route "prototype", "MVP", "fullstack", "from scratch", or "build whole app" to
$prototype and require codex-spec-driven-development before implementation.
- Activate project pulse on
$today, $pulse, $daily, $status, $brief, "hôm nay thế nào?", "what's next?", "what should I work on?", or "project status". Route to codex-project-pulse.
Behavioral Protocol Decision Tree
Agent context loaded?
|- Yes -> apply agent behavioral rules + file_ownership boundaries
| `- Then route to the matching workflow mode or alias file
|
`- No -> fallback to existing keyword-based mode detection
|
`- Task complexity?
|- Complex (architecture/design/multi-file) -> activate Thinking Partner mode
| `- Before presenting solution -> activate Devil's Advocate mode
|
|- Teaching request -> activate Teaching Mode + explain_code.py
|
`- Simple (single file fix) -> direct execution
Behavioral Modes
| Signals |
Mode |
Behavior |
| what if, ideas, options |
brainstorm |
ask clarifying questions and present alternatives, no code |
| think with me, compare options, help me decide |
thinking-partner |
co-think with tradeoff-first framing and explicit decision criteria |
| build, create, implement |
implement |
execute quickly with production-focused output, enforce TDD |
| prototype, MVP, fullstack, from scratch |
prototype |
run $hook -> $init-profile if needed -> $genome/$init-docs -> $spec -> $plan -> implementation -> $check-full |
| test first, TDD, red-green, failing test |
tdd |
enforce RED-GREEN-REFACTOR cycle via $tdd, no production code without failing test |
| error, bug, broken |
debug |
4-phase systematic debugging via $root-cause: root cause → pattern → hypothesis → fix |
| review, audit, check |
review |
inspect and report findings by severity |
| challenge this, poke holes, red team, counterargument |
devils-advocate |
stress-test assumptions, expose risks, and propose mitigations |
| explain, teach, learn |
teach |
explain progressively with examples |
| deploy, release, ship |
ship |
prioritize stability and complete checks |
Scrum Overlay Trigger
Trigger Scrum overlay when the request mentions:
- backlog, user story, acceptance criteria, refinement
- sprint planning, sprint backlog, sprint goal, daily scrum
- sprint review, retrospective, release readiness
- product owner, scrum master, cross-functional handoff
- Scrum shorthand aliases such as
$scrum-install, $scrum-update, $sprint-plan, $story-ready-check, $story-delivery, $retro, and $release-readiness
Load and apply: references/workflow-scrum.md.
Keep the routing contract in sync with references/workflow-routing-contract.json.
Rules:
- keep the base workflow (
build, fix, debug, review, or deploy) for the actual engineering work
- add a Scrum coordination layer when the request depends on ceremony output or multi-role handoffs
- recommend
codex-scrum-subagents when the project needs a local .agent kit for repeatable role briefs and workflows
- if a story is not ready, route back to refinement instead of coding immediately
Reasoning Rigor Trigger
Trigger this overlay when the user asks for:
- deeper thinking or stronger tradeoffs
- less generic output
- more evidence, monitoring, or explicit risks
- repo-grounded recommendations instead of generic best practices
Load and apply: codex-reasoning-rigor.
Rules:
- force a task contract before solutioning
- compare at least 2 options when tradeoffs are non-trivial
- add evidence, risks, and next-step contract to the output
- recommend
$output-guard before finalizing high-stakes written deliverables
Thinking-Partner Trigger
Trigger this mode when user asks for collaborative reasoning rather than immediate implementation.
- Signal examples: "think with me", "compare options", "which approach is better", "help me decide".
- Load and apply:
references/thinking-partner-mode.md.
- Ask focused clarifying questions before proposing workflow.
- Present option matrix with tradeoffs, risks, and recommended path.
- Convert selected path back to workflow steps and exit criteria.
Devil's Advocate Trigger
Trigger this mode when user asks for challenge, risk probing, or plan hardening.
- Signal examples: "be critical", "find blind spots", "red team this plan", "play devil's advocate".
- Load and apply:
references/devils-advocate-mode.md.
- Attack assumptions explicitly and rank findings by impact/likelihood.
- Provide mitigation actions and clear stop/ship criteria.
- Return to normal workflow mode only after key risks are addressed or explicitly accepted.
Teaching Mode Trigger
Trigger this mode when user asks to understand project code, not to modify it.
- Signal examples:
$teach, "explain this", "teach me", "how does this work", "walk me through".
- Load and apply:
references/teaching-mode-spec.md.
- Prefer project-specific explanation over generic language/framework theory.
- Use
scripts/explain_code.py as optional context helper for functions/imports/imported-by mapping.
- Output in four layers: what, how, why, connections, then gotchas.
- Keep scope tight to user request (function/file/module) and avoid unnecessary full-file dumps.
Intent to Workflow
| Intent |
Steps |
Exit Criteria |
| build |
analyze → plan ($plan) → isolate ($worktree) → TDD implement ($tdd) → test → gate |
tests pass, TDD verified, gate pass |
| prototype |
preflight ($hook) -> profile/context/docs -> spec ($spec) -> plan ($plan) -> TDD implementation -> role-doc/knowledge update -> full gate |
spec exists, acceptance criteria pass, full gate pass or advisory warnings listed |
| fix |
systematic debug ($root-cause) → root-cause → regression test ($tdd) → fix → gate |
root cause found, regression test pass, gate pass |
| review |
inspect → categorize findings → recommend actions |
findings documented with severity |
| debug |
systematic debug ($root-cause) → Phase 1-4 → test → gate |
verified fix with evidence, gate pass |
| docs |
scope change → update docs → verify links/accuracy → gate |
docs updated and verified |
Scrum Ceremony Routing
| Scrum Signal |
Suggested Ceremony |
Base Workflow |
Recommended Roles |
| vague backlog item, user story, acceptance criteria |
backlog refinement |
build |
product-owner -> scrum-master |
| sprint planning, sprint goal, forecast |
sprint planning |
build |
scrum-master -> product-owner -> delivery leads |
| blocker, dependency, daily sync |
daily scrum |
debug |
scrum-master |
| ready story in sprint |
story delivery |
build or fix |
scrum-orchestrator + delivery roles + qa-engineer |
| sprint demo, stakeholder feedback |
sprint review |
review |
product-owner + scrum-master + qa-engineer |
| process issue, improvement experiment |
retrospective |
review |
scrum-master + squad |
| ship decision, rollback, release gate |
release readiness |
deploy |
scrum-master + qa-engineer + security-engineer + devops-engineer |
BMAD for Complex Requests
Use BMAD when intent analysis marks complexity: complex.
Phase 1: Analysis (no code)
- confirm requirements and constraints
- inspect existing patterns
- capture key decisions
Phase 2: Planning (no code)
- create plan via
$codex-plan-writer or $plan
- define task-level input/output/verify
Checkpoint: wait for explicit user approval before Phase 3.
Phase 3: Solutioning (no code)
- finalize architecture and data flow decisions
- identify cross-file impacts
Phase 4: Implementation (code)
- For complex tasks: Set up isolated workspace via
$worktree
- For plan with independent tasks: Use subagent execution via
$sdd
- For all code changes: Follow TDD cycle via
$tdd
- implement task by task
- run tests/docs as workflow requires
Phase X: Verification (always last)
- Run
$codex-execution-quality-gate or $gate.
- If gate fails, fix blockers and rerun.
- Do not declare completion before gate decision.
- Use
$finish to handle branch completion if using worktree.
Reference Files
references/workflow-routing-contract.json: machine-checkable routing contract for modes, overlays, and output fields.
references/thinking-partner-mode.md: use only when collaborative option analysis is requested.
references/devils-advocate-mode.md: use only when explicit challenge/risk probing is requested.
references/teaching-mode-spec.md: use when user asks for code walkthrough, explanation, or teaching.
references/workflow-scrum.md: use when the request maps to Scrum ceremonies, story readiness, or release readiness.
references/workflow-create.md: execution template for new feature workflows.
../.workflows/prototype.md: alias workflow for MVP/fullstack prototype execution.
references/workflow-debug.md: execution template for debugging workflows.
references/workflow-review.md: execution template for review workflows.
references/workflow-refactor.md: execution template for refactoring workflows.
references/workflow-deploy.md: execution template for deployment workflows.
references/workflow-handoff.md: execution template for session handoff workflows.
references/workflow-plan.md: execution template for planning and BMAD Phase 1-2 workflows.
../.workflows/plan.md: alias workflow for planning and BMAD Phase 1-2.
../.workflows/debug.md: alias workflow for 4-phase debugging.
../.workflows/create.md: alias workflow for build-mode execution.
../.workflows/review.md: alias workflow for review plus written-output quality checks.
../.workflows/deploy.md: alias workflow for ship preparation and full gate.
../.workflows/handoff.md: alias workflow for session transfer and summary generation.
../.workflows/refactor.md: alias workflow for restructuring and simplifying code.
Helper Script
scripts/explain_code.py: optional context helper for functions, imports, and imported-by mapping.
- See
skills/.system/REGISTRY.md for full script paths.
Script Invocation Discipline
- Always run
--help before invoking a script.
- Treat scripts as black-box helpers and prefer direct execution over source inspection.
- Read script source only when customization or bug fixing is required.
Overrides
- "skip test": remove test step and warn quality confidence is reduced.
- "no docs": remove docs step and warn maintainability confidence is reduced.
- "just do it": default to build workflow and still show brief step plan.
- "skip plan": allow for simple scope; for complex scope warn and reconfirm.
Scope Heuristic
- small: 1-3 files, single concern
- medium: 4-10 files, multiple concerns
- large: 10+ files or architectural impact
Output Contract
Return fenced JSON in conversation:
{
"mode": "brainstorm | thinking-partner | implement | tdd | debug | review | devils-advocate | teach | ship",
"workflow_type": "build | fix | review | debug | docs | refactor | deploy | handoff",
"steps": ["step1", "step2"],
"exit_criteria": ["criterion1"],
"estimated_scope": "small | medium | large",
"phase": "analysis | planning | solutioning | implementation | verification",
"coordination_overlay": "none | scrum",
"ceremony": "none | backlog-refinement | sprint-planning | daily-scrum | story-delivery | sprint-review | retrospective | release-readiness"
}
Primary execution remains sequential by default. Native Codex custom agents can participate when they are installed and explicitly selected.
1---2name: codex-workflow-autopilot3description: Use after intent is known to route build, fix, review, debug, docs, or Scrum requests into ordered workflow steps with exit criteria.4---56## TL;DR7Route tasks by complexity: complex -> Thinking Partner + Devil's Advocate, teaching -> Teaching Mode + explain_code.py, simple -> direct execution. Map intent to workflow (build/fix/review/debug/docs). Use BMAD 4-phase for complex. Always end with Phase X quality gate.89# Workflow Autopilot1011## Activation12131. Activate after intent analysis is confirmed.142. Activate on explicit `$codex-workflow-autopilot` or `$route`.153. Activate teaching mode on `$teach`, "explain", or "walk me through".164. Activate Scrum overlay on backlog, story, sprint, review, retrospective, release-readiness, or shorthand commands such as `$sprint-plan`, `$story-ready-check`, `$retro`, and `$release-readiness`.175. Activate reasoning rigor on `$codex-reasoning-rigor`, `$rigor`, "don't be generic", "go deeper", "make it specific", or "use the repo, not generic advice".186. Activate on alias triggers: `$plan`, `$debug`, `$create`, `$prototype`, `$review`, `$deploy`, `$handoff`, `$refactor`.197. When activated via alias, load the corresponding `.workflows/<name>.md` file before executing the flow.208. Activate brainstorm mode on `$brainstorm`, "brainstorm", "think through options", or "explore approaches".219. Activate review-feedback routing on `$review-feedback`, "address review feedback", or "respond to code review".2210. Route "prototype", "MVP", "fullstack", "from scratch", or "build whole app" to `$prototype` and require `codex-spec-driven-development` before implementation.2311. Activate project pulse on `$today`, `$pulse`, `$daily`, `$status`, `$brief`, "hôm nay thế nào?", "what's next?", "what should I work on?", or "project status". Route to `codex-project-pulse`.2425## Behavioral Protocol Decision Tree2627```28Agent context loaded?29 |- Yes -> apply agent behavioral rules + file_ownership boundaries30 | `- Then route to the matching workflow mode or alias file31 |32 `- No -> fallback to existing keyword-based mode detection33 |34 `- Task complexity?35 |- Complex (architecture/design/multi-file) -> activate Thinking Partner mode36 | `- Before presenting solution -> activate Devil's Advocate mode37 |38 |- Teaching request -> activate Teaching Mode + explain_code.py39 |40 `- Simple (single file fix) -> direct execution41```4243## Behavioral Modes4445| Signals | Mode | Behavior |46| --- | --- | --- |47| what if, ideas, options | brainstorm | ask clarifying questions and present alternatives, no code |48| think with me, compare options, help me decide | thinking-partner | co-think with tradeoff-first framing and explicit decision criteria |49| build, create, implement | implement | execute quickly with production-focused output, enforce TDD |50| prototype, MVP, fullstack, from scratch | prototype | run `$hook` -> `$init-profile` if needed -> `$genome`/`$init-docs` -> `$spec` -> `$plan` -> implementation -> `$check-full` |51| test first, TDD, red-green, failing test | tdd | enforce RED-GREEN-REFACTOR cycle via `$tdd`, no production code without failing test |52| error, bug, broken | debug | 4-phase systematic debugging via `$root-cause`: root cause → pattern → hypothesis → fix |53| review, audit, check | review | inspect and report findings by severity |54| challenge this, poke holes, red team, counterargument | devils-advocate | stress-test assumptions, expose risks, and propose mitigations |55| explain, teach, learn | teach | explain progressively with examples |56| deploy, release, ship | ship | prioritize stability and complete checks |5758## Scrum Overlay Trigger5960Trigger Scrum overlay when the request mentions:6162- backlog, user story, acceptance criteria, refinement63- sprint planning, sprint backlog, sprint goal, daily scrum64- sprint review, retrospective, release readiness65- product owner, scrum master, cross-functional handoff66- Scrum shorthand aliases such as `$scrum-install`, `$scrum-update`, `$sprint-plan`, `$story-ready-check`, `$story-delivery`, `$retro`, and `$release-readiness`6768Load and apply: `references/workflow-scrum.md`.69Keep the routing contract in sync with `references/workflow-routing-contract.json`.7071Rules:7273- keep the base workflow (`build`, `fix`, `debug`, `review`, or `deploy`) for the actual engineering work74- add a Scrum coordination layer when the request depends on ceremony output or multi-role handoffs75- recommend `codex-scrum-subagents` when the project needs a local `.agent` kit for repeatable role briefs and workflows76- if a story is not ready, route back to refinement instead of coding immediately7778## Reasoning Rigor Trigger7980Trigger this overlay when the user asks for:8182- deeper thinking or stronger tradeoffs83- less generic output84- more evidence, monitoring, or explicit risks85- repo-grounded recommendations instead of generic best practices8687Load and apply: `codex-reasoning-rigor`.8889Rules:9091- force a task contract before solutioning92- compare at least 2 options when tradeoffs are non-trivial93- add evidence, risks, and next-step contract to the output94- recommend `$output-guard` before finalizing high-stakes written deliverables9596## Thinking-Partner Trigger9798Trigger this mode when user asks for collaborative reasoning rather than immediate implementation.99100- Signal examples: "think with me", "compare options", "which approach is better", "help me decide".101- Load and apply: `references/thinking-partner-mode.md`.102- Ask focused clarifying questions before proposing workflow.103- Present option matrix with tradeoffs, risks, and recommended path.104- Convert selected path back to workflow steps and exit criteria.105106## Devil's Advocate Trigger107108Trigger this mode when user asks for challenge, risk probing, or plan hardening.109110- Signal examples: "be critical", "find blind spots", "red team this plan", "play devil's advocate".111- Load and apply: `references/devils-advocate-mode.md`.112- Attack assumptions explicitly and rank findings by impact/likelihood.113- Provide mitigation actions and clear stop/ship criteria.114- Return to normal workflow mode only after key risks are addressed or explicitly accepted.115116## Teaching Mode Trigger117118Trigger this mode when user asks to understand project code, not to modify it.119120- Signal examples: `$teach`, "explain this", "teach me", "how does this work", "walk me through".121- Load and apply: `references/teaching-mode-spec.md`.122- Prefer project-specific explanation over generic language/framework theory.123- Use `scripts/explain_code.py` as optional context helper for functions/imports/imported-by mapping.124- Output in four layers: what, how, why, connections, then gotchas.125- Keep scope tight to user request (function/file/module) and avoid unnecessary full-file dumps.126127## Intent to Workflow128129| Intent | Steps | Exit Criteria |130| --- | --- | --- |131| build | analyze → plan ($plan) → isolate ($worktree) → TDD implement ($tdd) → test → gate | tests pass, TDD verified, gate pass |132| prototype | preflight ($hook) -> profile/context/docs -> spec ($spec) -> plan ($plan) -> TDD implementation -> role-doc/knowledge update -> full gate | spec exists, acceptance criteria pass, full gate pass or advisory warnings listed |133| fix | systematic debug ($root-cause) → root-cause → regression test ($tdd) → fix → gate | root cause found, regression test pass, gate pass |134| review | inspect → categorize findings → recommend actions | findings documented with severity |135| debug | systematic debug ($root-cause) → Phase 1-4 → test → gate | verified fix with evidence, gate pass |136| docs | scope change → update docs → verify links/accuracy → gate | docs updated and verified |137138## Scrum Ceremony Routing139140| Scrum Signal | Suggested Ceremony | Base Workflow | Recommended Roles |141| --- | --- | --- | --- |142| vague backlog item, user story, acceptance criteria | backlog refinement | build | product-owner -> scrum-master |143| sprint planning, sprint goal, forecast | sprint planning | build | scrum-master -> product-owner -> delivery leads |144| blocker, dependency, daily sync | daily scrum | debug | scrum-master |145| ready story in sprint | story delivery | build or fix | scrum-orchestrator + delivery roles + qa-engineer |146| sprint demo, stakeholder feedback | sprint review | review | product-owner + scrum-master + qa-engineer |147| process issue, improvement experiment | retrospective | review | scrum-master + squad |148| ship decision, rollback, release gate | release readiness | deploy | scrum-master + qa-engineer + security-engineer + devops-engineer |149150## BMAD for Complex Requests151152Use BMAD when intent analysis marks `complexity: complex`.153154### Phase 1: Analysis (no code)155156- confirm requirements and constraints157- inspect existing patterns158- capture key decisions159160### Phase 2: Planning (no code)161162- create plan via `$codex-plan-writer` or `$plan`163- define task-level input/output/verify164165Checkpoint: wait for explicit user approval before Phase 3.166167### Phase 3: Solutioning (no code)168169- finalize architecture and data flow decisions170- identify cross-file impacts171172### Phase 4: Implementation (code)173174- **For complex tasks:** Set up isolated workspace via `$worktree`175- **For plan with independent tasks:** Use subagent execution via `$sdd`176- **For all code changes:** Follow TDD cycle via `$tdd`177- implement task by task178- run tests/docs as workflow requires179180### Phase X: Verification (always last)1811821. Run `$codex-execution-quality-gate` or `$gate`.1832. If gate fails, fix blockers and rerun.1843. Do not declare completion before gate decision.1854. Use `$finish` to handle branch completion if using worktree.186187## Reference Files188189- `references/workflow-routing-contract.json`: machine-checkable routing contract for modes, overlays, and output fields.190- `references/thinking-partner-mode.md`: use only when collaborative option analysis is requested.191- `references/devils-advocate-mode.md`: use only when explicit challenge/risk probing is requested.192- `references/teaching-mode-spec.md`: use when user asks for code walkthrough, explanation, or teaching.193- `references/workflow-scrum.md`: use when the request maps to Scrum ceremonies, story readiness, or release readiness.194- `references/workflow-create.md`: execution template for new feature workflows.195- `../.workflows/prototype.md`: alias workflow for MVP/fullstack prototype execution.196- `references/workflow-debug.md`: execution template for debugging workflows.197- `references/workflow-review.md`: execution template for review workflows.198- `references/workflow-refactor.md`: execution template for refactoring workflows.199- `references/workflow-deploy.md`: execution template for deployment workflows.200- `references/workflow-handoff.md`: execution template for session handoff workflows.201- `references/workflow-plan.md`: execution template for planning and BMAD Phase 1-2 workflows.202- `../.workflows/plan.md`: alias workflow for planning and BMAD Phase 1-2.203- `../.workflows/debug.md`: alias workflow for 4-phase debugging.204- `../.workflows/create.md`: alias workflow for build-mode execution.205- `../.workflows/review.md`: alias workflow for review plus written-output quality checks.206- `../.workflows/deploy.md`: alias workflow for ship preparation and full gate.207- `../.workflows/handoff.md`: alias workflow for session transfer and summary generation.208- `../.workflows/refactor.md`: alias workflow for restructuring and simplifying code.209210## Helper Script211212- `scripts/explain_code.py`: optional context helper for functions, imports, and imported-by mapping.213- See `skills/.system/REGISTRY.md` for full script paths.214215## Script Invocation Discipline2162171. Always run `--help` before invoking a script.2182. Treat scripts as black-box helpers and prefer direct execution over source inspection.2193. Read script source only when customization or bug fixing is required.220221## Overrides222223- "skip test": remove test step and warn quality confidence is reduced.224- "no docs": remove docs step and warn maintainability confidence is reduced.225- "just do it": default to build workflow and still show brief step plan.226- "skip plan": allow for simple scope; for complex scope warn and reconfirm.227228## Scope Heuristic229230- small: 1-3 files, single concern231- medium: 4-10 files, multiple concerns232- large: 10+ files or architectural impact233234## Output Contract235236Return fenced JSON in conversation:237238```json239{240 "mode": "brainstorm | thinking-partner | implement | tdd | debug | review | devils-advocate | teach | ship",241 "workflow_type": "build | fix | review | debug | docs | refactor | deploy | handoff",242 "steps": ["step1", "step2"],243 "exit_criteria": ["criterion1"],244 "estimated_scope": "small | medium | large",245 "phase": "analysis | planning | solutioning | implementation | verification",246 "coordination_overlay": "none | scrum",247 "ceremony": "none | backlog-refinement | sprint-planning | daily-scrum | story-delivery | sprint-review | retrospective | release-readiness"248}249```250251Primary execution remains sequential by default. Native Codex custom agents can participate when they are installed and explicitly selected.