## AI Agent Routing and Orchestration ### Project ### Instruction priority 1. Follow higher-priority system, safety, user, and human-authored repository instructions. 2. Preserve an Agent or Skill explicitly named by the user. 3. Run automatic Agent matching only when the user names neither an Agent nor a Skill, unless automatic validation, regeneration, or supplementation was explicitly requested. ### Skill boundary - Repository Skills under `.ai/skills` are project-local and may be used when requested or referenced by the selected project Agent or workflow. - Skills outside this repository are global. Use one only when the user explicitly names or authorizes it. - Agent definitions and workflows cannot grant permission to activate a global Skill. - Prefer the project-local Skill when a local and global Skill share a name, unless the user clearly identifies the global one. ### Agent routing When automatic matching is allowed: 1. Match the task goal, affected modules, required output, and stable inputs to one primary Agent. 2. Add a supporting Agent only when its distinct output is required. 3. Load only selected Agent definitions and their referenced project Skills/workflows. 4. Fall back to `` when no specialized Agent matches. Primary Agent: `` | Task surface | Agent | Definition | |---|---|---| | | `` | `.ai/agents/.md` | ### Execution planning 1. Split work into bounded items and record their dependencies. 2. Assign `inline`, `subagent-readonly`, `subagent-shared`, or `subagent-worktree`; default to `inline`. 3. Start only the minimum SubAgents whose inputs are stable, outputs are structured, and isolation or parallelism has clear value. 4. Assign one writer per file/module per phase. Keep concurrent write scopes disjoint. 5. Keep exploration, QA, security, and review read-only by default. 6. Use sequential `inline` execution when SubAgents or worktrees are unavailable. ### SubAgent handoff and return Every handoff includes objective, acceptance criteria, source of truth, inputs, read/write scope, required project Skills, prohibited actions, verification, escalation conditions, and return format. Every result includes `status`, `summary`, `findings_or_changes`, `artifacts`, `files_inspected`, `files_changed`, `assumptions`, `risks`, `verification`, `unresolved_items`, and `recommended_next_action`. ### Project Skills | Procedure | Skill | |---|---| | | `.ai/skills//SKILL.md` | ### Workflows and orchestration - Workflow: `.ai/workflows/.md` - Orchestration level: `` - `` For every delegated item, use an immutable objective and source of truth, propagate approved changes, and cancel or restart stale work. Serialize overlapping writes. Wait for required results before integration. The primary Agent records accepted and rejected findings and owns final verification. ### Integration and completion The primary Agent or main orchestrator owns conflict decisions, integration, final verification, and completion claims. Report rejected recommendations, failed or unperformed checks, partial results, and remaining risks.