$npx -y skills add softspark/ai-toolkit --skill evolveAnalyzes agent/skill failures, drafts prompt/permission fixes. Triggers: improve agent, refine skill, system prompt, optimize agent.
| 1 | # Evolve Command |
| 2 | |
| 3 | $ARGUMENTS |
| 4 | |
| 5 | Triggers the Meta-Architect to improve agent and skill definitions based on observed patterns. |
| 6 | |
| 7 | ## Usage |
| 8 | |
| 9 | ```bash |
| 10 | /evolve [source] |
| 11 | # /evolve learnings : analyze kb/learnings/ for recurring failure patterns |
| 12 | # /evolve last-failure : analyze the most recent error log |
| 13 | # /evolve agents : audit all agent definitions for gaps |
| 14 | ``` |
| 15 | |
| 16 | ## Protocol |
| 17 | |
| 18 | ### 1. Analyze |
| 19 | |
| 20 | Read the input source and extract actionable patterns: |
| 21 | |
| 22 | - **learnings**: grep `kb/learnings/` for entries tagged `failure`, `retry`, `timeout`, or `inefficiency` |
| 23 | - **last-failure**: read the most recent file in `kb/learnings/` and identify root cause |
| 24 | - **agents**: scan all `.md` files in `app/agents/` for missing tools, vague prompts, or mismatched model tiers |
| 25 | |
| 26 | ### 2. Design |
| 27 | |
| 28 | Draft changes targeting the identified patterns: |
| 29 | |
| 30 | | Target | File Location | Change Type | |
| 31 | |--------|--------------|-------------| |
| 32 | | Agent definitions | `app/agents/*.md` | Frontmatter (tools, model), system prompt text | |
| 33 | | Skill definitions | `app/skills/*/SKILL.md` | Description, workflow steps, allowed-tools | |
| 34 | | Rules | `app/rules/` | New or updated rule files | |
| 35 | |
| 36 | Show the proposed diff to the user before applying. |
| 37 | |
| 38 | ### 3. Implement |
| 39 | |
| 40 | Apply approved changes. After each edit: |
| 41 | |
| 42 | - Run `python3 scripts/validate.py` to confirm structural integrity |
| 43 | - Verify YAML frontmatter parses without errors |
| 44 | - Confirm no forbidden patterns (eval, exec, shell=True) |
| 45 | |
| 46 | ### 4. Report |
| 47 | |
| 48 | Create a summary documenting what evolved: |
| 49 | |
| 50 | ```markdown |
| 51 | ## Evolution Report |
| 52 | - **Source**: [learnings | last-failure | agents] |
| 53 | - **Pattern found**: [description of failure/inefficiency] |
| 54 | - **Changes applied**: |
| 55 | - `app/agents/[name].md`: [what changed and why] |
| 56 | - **Validation**: passed / failed |
| 57 | ``` |
| 58 | |
| 59 | ## Rules |
| 60 | |
| 61 | - **MUST** delegate file edits to the `meta-architect` agent — this command is the trigger, the agent owns the changes |
| 62 | - **MUST** have a concrete failure signal (recurring error, named incident, repeated correction) before evolving — do not mutate based on vibes |
| 63 | - **NEVER** evolve an agent based on a **single** failure instance — evolution is pattern-matching, not reaction |
| 64 | - **NEVER** touch `.claude/agents/*` files directly from this skill; `meta-architect` is the only agent with that authority |
| 65 | - **CRITICAL**: every evolution names the trigger, the change, and the expected measurable shift (e.g., "reduces false routing of `/debug` to `/fix`") |
| 66 | - **MANDATORY**: run `scripts/validate.py --strict` after every applied change; roll back if the score drops |
| 67 | |
| 68 | ## Gotchas |
| 69 | |
| 70 | - Small changes to an agent's description can silently re-route a dozen adjacent queries. After an evolution, run the skill router against a saved set of representative queries to confirm no drift. |
| 71 | - `kb/learnings/` entries without a `status: final` frontmatter field are often drafts — aggregating them treats speculative observations as validated patterns. Filter by status before mining. |
| 72 | - "Last-failure" often points at the **symptom**, not the root cause. A route-to-wrong-agent failure may actually be a description-field ambiguity; fix the description, not the router. |
| 73 | - Changes to agent frontmatter fields (`tools`, `model`) propagate to the installed global config only after `ai-toolkit update`. A locally-evolved agent still runs old behavior until the user reinstalls. |
| 74 | - Evolution in isolation invites regression. Keep a changelog (`kb/learnings/` entries or `CHANGELOG.md`) so future sessions can see what was tried and reverted. |
| 75 | |
| 76 | ## When NOT to Use |
| 77 | |
| 78 | - For a specific, known agent edit — call `meta-architect` directly |
| 79 | - For fixing a failing test — use `/fix` or `/debug` |
| 80 | - For auditing **current** skill/agent quality — use `scripts/evaluate_skills.py` and `scripts/audit_skills.py --ci` |
| 81 | - For creating a **new** agent — use `/agent-creator` |
| 82 | - When no recurring pattern exists (single data point) — wait and observe; do not over-fit to noise |