aeo-optimization
AI Engine Optimization - semantic triples, page templates, content clusters for AI citations
Cross-agent task routing — Codex auto-review, Kimi delegation by complexity score (iCPG + Claude reasoning), iCPG + Mnemos mandatory for all agents
$ npx -y skills add alinaqi/claude-bootstrap --skill cross-agent-delegation --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/cross-agent-delegationContext preview
The summary Claude sees to decide when to auto-load this skill.
Cross-agent task routing — Codex auto-review, Kimi delegation by complexity score (iCPG + Claude reasoning), iCPG + Mnemos mandatory for all agents
name: cross-agent-delegation description: Cross-agent task routing — Codex auto-review, Kimi delegation by complexity score (iCPG + Claude reasoning), iCPG + Mnemos mandatory for all agents when-to-use: Always loaded when multiple AI CLI tools are available (Claude, Kimi, Codex) user-invocable: false effort: medium
Claude Code orchestrates task routing to Kimi and Codex. The user interacts with Claude only — delegation happens behind the scenes.
---
At session start, detect available tools:
command -v kimi &>/dev/null && HAS_KIMI=true || HAS_KIMI=false command -v codex &>/dev/null && HAS_CODEX=true || HAS_CODEX=false
---
When Codex is installed, a Stop hook reviews code after tests pass:
1. TDD loop check runs tests 2. `codex-auto-review.sh` runs Codex on the diff 3. Critical/High findings feed back to Claude (exit 2) 4. Clean reviews pass through (exit 0)
**Fully automatic.** No user or Claude action needed.
---
When Kimi is installed and the task complexity is bounded, Claude delegates directly — the user does not need to run anything.
File count is a poor proxy for delegation risk. A 1-file change to an authz path is harder than a 12-file rename. Score the task on five dimensions, each 0-2, sourced from iCPG signals plus Claude's semantic reasoning:
| Dimension | 0 (low) | 1 (medium) | 2 (high) | Source | |---|---|---|---|---| | **Cyclomatic / surface depth** | <10 LOC, no branches | 10-50 LOC, ≤3 branches | 50+ LOC or nested control flow | iCPG `query_graph` over function bodies | | **Fan-out (consumer blast radius)** | 0-2 callers | 3-10 callers | 11+ callers | iCPG `trace_path(<symbol>, mode=callers)` | | **Crosses a security boundary** (SEC-006, auth, PII, RLS, org-scope, billing, payments) | None | Tangential | Direct read or write | iCPG SEC-* / R-063 tags + grep for `org_id`, `user_id`, `auth`, `pii` | | **Concurrency / transactional** | Pure / sync | Async only | Locks, transactions, atomic claims, `FOR UPDATE`, `asyncio.Lock`, `session.begin` | iCPG concurrency flags + grep | | **Domain invariants required** | None / well-documented inline | Some implicit (need to read 1-2 files) | Heavy (cross-doc, ADR-bound, RFC-bound) | Claude reasoning + iCPG ADR linkage |
# Auto-collect signals icpg query blast <scope> --format json # fan-out, async flags, sec tags grep -rE "org_id|user_id|auth|pii" <file> # cheap sec heuristic if iCPG flags absent grep -rE "asyncio.Lock|FOR UPDATE|session.begin" <file> # concurrency heuristic
| Total score | Route | Rationale | |---|---|---| | **0-3** | Kimi solo | Bounded surface, no security/concurrency/cross-doc concerns | | **4-6** | Kimi → Codex auto-review (no user prompt) | Real risk, but not so high that we need full Claude context — Codex catches what Kimi might miss | | **7-10** | Claude handles directly | Cross-cutting / security-critical / concurrency-heavy — needs full context |
To skip iCPG-query cost on truly trivial work:
# If <2 files changed AND no SEC/auth/PII/concurrency keyword in diff, # → auto-Kimi without scoring. FILES=$(git diff --name-only | wc -l) HAS_RISK_KEYWORDS=$(git diff | grep -ciE "org_id|auth|pii|asyncio|FOR UPDATE|transaction|session\.begin" || true) if [ "$FILES" -lt 2 ] && [ "$HAS_RISK_KEYWORDS" -eq 0 ]; then AUTO_KIMI=true fi
This handles the trivial-rename / typo-fix case without paying the iCPG round-trip.
Claude writes a mnemos checkpoint, then runs Kimi headless:
# 1. Save current context to disk mnemos checkpoint --force # 2. Get context summary for Kimi CONTEXT=$(mnemos resume 2>/dev/null) # 3. Get constraints for target files CONSTRAINTS=$(icpg query constraints <target-file> 2>/dev/null) # 4. Run Kimi headless with full context kimi --print -y -w . -p " ## Context (from mnemos checkpoint) $CONTEXT ## Constraints (from iCPG) $CONSTRAINTS ## Task <specific task description> ## Rules - Run tests after changes - Record changes: icpg record --base main - Write checkpoint when done: mnemos checkpoint --force "
After Kimi finishes, Claude:
# Read what Kimi did mnemos resume # Kimi's checkpoint icpg status # Kimi's recorded symbols git diff # Kimi's file changes
---
Before ANY code change, Claude runs these (and includes results when delegating):
# 1. Duplicate check — already done? icpg query prior "<goal>" # 2. Constraints — what invariants apply? icpg query constraints <file-path> # 3. Risk — is this symbol fragile? icpg query risk <symbol-name>
icpg record --reason <id> --base main icpg drift check
---
mnemos add goal "<task description>"
mnemos checkpoint
mnemos checkpoint --force
The checkpoint is the bridge. Claude writes it, Kimi reads it:
# Claude saves state mnemos checkpoint --force # Kimi (or
Turn Claude Code into a self-reviewing, test-enforced engineering system that remembers context across sessions — then route work across 13 models from a single dashboard.
Repo: alinaqi/claude-bootstrap
AI Engine Optimization - semantic triples, page templates, content clusters for AI citations
Claude Code Agent Teams - default team-based development with strict TDD pipeline enforcement
Build AI agents with Pydantic AI (Python) and Claude SDK (Node.js)
Latest AI models reference - Claude, OpenAI, Gemini, Eleven Labs, Replicate
Android Kotlin development with Coroutines, Jetpack Compose, Hilt, and MockK testing