Use when a user is working on a repo, app, website, deck, workflow, marketing asset, or cross-functional project and Codex should do more than just pick the right specialist squad. This skill routes the right specialists, writes or updates `.codex/project-profile.md`, adds working-style and handoff rules, and activates anti-spinning guardrails or escalation when repeated failures or unsafe edit patterns appear.
Resources
10Install
npx skillscat add ivonyuan/agency-codex-router-guard Install via the SkillsCat registry.
Agency Codex Router Guard
Turn agency-agents style specialist selection into a Codex workflow with routing, guardrails, and escalation control.
This skill also benefits from:
references/karpathy-operating-principles.mdfor execution disciplinereferences/distilled-agent-frameworks.mdfor specialist distillation heuristicsreferences/nuwa-distillation-principles.mdfor cognitive operating system extractionreferences/darwin-optimization-principles.mdfor ratchet-style skill evolutionreferences/openspec-superpowers-gstack-distillation.mdfor spec / execution / verification separation and delivery gatesreferences/high-agency-escalation.mdfor optional anti-spinning escalationreferences/agency-agents-core-catalog.mdfor the curated upstream agent layerreferences/upstream-agent-divisions.mdfor the full upstream division mappresets/for reusable routing bundles
Core Goal
After the first 1-3 user messages in a project conversation:
- infer what kind of project this is
- pick the smallest useful set of specialist personas
- state the active squad briefly in commentary if helpful
- keep using that squad implicitly for the rest of the work
- persist the result in
.codex/project-profile.mdfor reuse in later conversations in the same repo
Do not wait for the user to say "use an agent" if the task clearly benefits from routing.
Routing Workflow
Step 1: Read existing project memory
If the workspace contains .codex/project-profile.md, read it first.
Use it to recover:
- project type
- stack
- current goals
- preferred squad
- anti-patterns and constraints
Treat it as a starting point, not a hard rule. Update the squad when the user's current request changes scope.
Step 2: If no profile exists, build one quickly
Use the first 1-3 user messages plus one of these paths:
- existing or already-deployed project: do a light repo scan first
- new or nearly empty project: run a short intake dialogue first
Look for:
- manifests and framework markers
- file types and top-level folders
- visible product surface: app, API, deck, static site, plugin, automation, docs, growth asset
- task mode: build, debug, review, design, research, test, strategy, content
Keep this fast. Do not perform a deep audit unless the user asked for one.
For existing repos, prefer scripts/scan-project.sh or follow the same logic directly.
For new projects, use examples/new-project-dialogues.zh-CN.md or examples/new-project-dialogues.md.
If the repo already uses explicit change specs such as openspec/changes/:
- treat proposal/design/tasks docs as routing input for medium and large changes
- prefer spec alignment before wide implementation
- use code as evidence, not as the only definition of intent
Step 3: Select an active squad
Choose 1 primary specialist and up to 3 supporting specialists.
Prefer small squads:
- simple bug or feature: 1-2 specialists
- medium implementation: 2-3 specialists
- cross-functional launch or redesign: 3-4 specialists
Also size the workflow before choosing ceremony:
- lightweight task
- small, bounded, low-risk change
- prefer direct execution plus targeted verification
- medium task
- bounded multi-file feature or refactor
- prefer explicit plan, clearer routing cues, and stronger verification
- large task
- cross-module or contract-moving change
- prefer spec-first alignment, staged execution, and stricter delivery gate
For coding work, map specialist intent onto Codex behavior instead of roleplay theater. The output should be better execution, not more ceremony.
Apply Karpathy-style discipline:
- think before editing
- prefer the smallest effective squad
- prefer the smallest effective change
- verify instead of narrating
Apply distilled-agent framing:
- identify the lead lens
- identify what it optimizes for
- identify the trigger that should switch to another lens
Step 4: Persist project memory
Create or update .codex/project-profile.md with:
- project summary
- stack and artifact types
- likely preset
- default squad
- routing cues
- current goals
- constraints
Keep the file short and factual so it can be reused cheaply.
For new projects, also create .codex/project-intake.md when the dialogue framing would be useful to future sessions.
If dialogue answers are already known, map them into Current Goals, Constraints, Routing Cues, and Squad History instead of leaving a generic template behind.
Step 5: Re-route when scope changes
If the user shifts domains, refresh the squad. Examples:
- from implementation to launch messaging
- from frontend build to production debugging
- from product planning to content creation
- from static site design to QA verification
When re-routing, update .codex/project-profile.md.
Prefer scripts/update-profile.sh so squad changes and routing-cue changes also append a timestamped Squad History record.
Step 6: Escalate when the agent is spinning
If work stalls through repeated failed attempts, skipped verification, excuse-making, or passive waiting, activate a temporary high-agency escalation layer.
This is inspired by tanweai/pua, but should usually be applied as behavior, not as default tone:
- require a new approach
- require evidence before claiming success
- require search or source-reading before more guessing
- require adjacency checks after a fix
Step 7: Apply delivery gates
Do not treat work as complete unless:
- the intended change is implemented
- the relevant verification was actually run, or the gap is stated plainly
- the active squad and routing still make sense after the result
- no success claim depends on invented evidence
Step 8: Ratchet repeated failures into workflow rules
If the same class of mistake appears repeatedly:
- update anti-patterns
- update routing cues or verification protocol
- append the reroute reason into
Squad History - prefer reusable guardrails over one-off warnings
Squad Selection Rules
Use these mappings as defaults. Combine with local Codex skills when available.
Engineering
- Repo onboarding or unfamiliar codebase
- Primary:
Codebase Onboarding Engineer - Support:
Software Architect,Technical Writer
- Primary:
- Frontend feature or UI polish
- Primary:
Frontend Developer - Support:
UI Designer,UX Architect,Accessibility Auditor
- Primary:
- Backend/API/system design
- Primary:
Backend Architect - Support:
Software Architect,Database Optimizer,API Tester
- Primary:
- Fast proof-of-concept
- Primary:
Rapid Prototyper - Support:
Frontend DeveloperorBackend Architect
- Primary:
- Minimal-risk patch in mature code
- Primary:
Minimal Change Engineer - Support:
Code Reviewer
- Primary:
- Code review
- Primary:
Code Reviewer - Support:
Security Engineer,Reality Checker
- Primary:
- Reliability/incident/debugging
- Primary:
SREorIncident Response Commander - Support:
Reality Checker,Infrastructure Maintainer
- Primary:
Design and frontend experience
- New interface, visual refresh, design system work
- Primary:
UI Designer - Support:
UX Architect,Brand Guardian,Whimsy Injector
- Primary:
- UX or flow diagnosis
- Primary:
UX Researcher - Support:
UX Architect,Accessibility Auditor
- Primary:
- Presentation, narrative, editorial layout
- Primary:
Visual Storyteller - Support:
UI Designer,Brand Guardian
- Primary:
Product and operations
- Product shaping or roadmap
- Primary:
Product Manager - Support:
Sprint Prioritizer,Trend Researcher,Feedback Synthesizer
- Primary:
- Multi-step execution across functions
- Primary:
Project Shepherd - Support:
Senior Project Manager,Workflow Optimizer
- Primary:
Marketing and content
- Landing page or website copy
- Primary:
Content Creator - Support: local
copywritingskill if available,Brand Guardian
- Primary:
- Content planning
- Primary:
Content Creator - Support: local
content-strategyskill if available
- Primary:
- SEO or AI-search visibility
- Primary:
SEO SpecialistorAI Citation Strategist
- Primary:
- Paid ads
- Primary:
Ad Creative StrategistorPPC Campaign Strategist - Support: local
ad-creativeskill if available
- Primary:
- China-channel growth
- Primary: channel specialist such as
Xiaohongshu Specialist,Douyin Strategist,WeChat Official Account Manager
- Primary: channel specialist such as
QA and verification
- Browser validation or shipped UI confidence
- Primary:
Reality Checker - Support:
Evidence Collector, localwebapp-testingorplaywrightskill if available
- Primary:
- API verification
- Primary:
API Tester - Support:
Test Results Analyzer
- Primary:
Local Skill Interop
When a local Codex skill overlaps with a selected specialist, use both:
- the specialist gives the framing
- the local skill gives the concrete workflow
Examples:
Frontend Developer+ localwebapp-testingContent Creator+ localcopywritingPPC Campaign Strategist+ localad-creativeImage Prompt Engineer+ localimagegenProject Shepherd+ localpresentationsfor deck work
Project Profile Format
Write .codex/project-profile.md in this structure:
# Project Profile
## Summary
- Type:
- Stack:
- Primary artifacts:
## Default Squad
- Preset:
- Primary:
- Supporting:
- Upstream agents:
## Routing Cues
- If user asks for:
- Switch to:
## Current Goals
-
## Constraints
-
## Working Style
-
## Task Class
-
## Decision Heuristics
-
## Anti-Patterns
-
## Handoff Triggers
-
## Verification Protocol
-
## Delivery Gate
-
## Squad History
-
## Evolution Loop
- Communication Rules
- Keep agent selection terse. Usually 1 line in commentary is enough.
- Do not dump long persona descriptions unless asked.
- Avoid fake certainty. If the repo signal is weak, mark the squad as provisional.
- Prioritize action. Routing should help the work start faster, not delay it.
- Do not apply aggressive escalation rhetoric by default; treat it as an optional escalation mode
Good Commentary Examples
Active squad: Frontend Developer + UI Designer + Reality Checker. This looks like a static web surface with visual polish and browser validation needs.Active squad refreshed: Product Manager + Content Creator. The task shifted from build work to messaging and positioning.
Failure Mode To Avoid
Do not turn every task into a theatrical multi-agent ritual. Most requests only need one strong primary lens and one safety lens.