@softspark/ai-toolkit 2.9.0 → 2.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/AGENTS.md CHANGED
@@ -358,7 +358,7 @@ Search engine optimization specialist. Trigger words: SEO, search engine, meta t
358
358
 
359
359
  The Guardian of the Constitution. Validates all evolutionary changes and enforces immutable rules. Has VETO power.
360
360
 
361
- **Tools:** `Read, Write, Bash`
361
+ **Tools:** `Read, Write, Bash, Grep, Glob`
362
362
 
363
363
  ---
364
364
 
@@ -453,7 +453,7 @@ Skills are invocable commands or auto-loaded knowledge sources:
453
453
  - **app-builder**: Full-stack app scaffolding with stack-selection matrix: Next.js, React+Vite, Nuxt, Astro, FastAPI, Django, Laravel, React Native, Flutter, Unity. Triggers: scaffold, bootstrap, new project, starter template, build app, landing page, dashboard, API, mobile app, CLI, e-commerce, game. Load when user wants to start a new project from scratch.
454
454
  - **architecture-audit**: Explore codebase organically for architectural friction, discover shallow modules, and propose module-deepening refactors as GitHub issue RFCs using parallel sub-agent interface designs. Use when user wants to improve architecture, find shallow modules, deepen modules, or reduce coupling. Codex-adapted: uses native subagents and plan tracking.
455
455
  - **architecture-decision**: Architecture decision making via trade-off analysis in RFC/RFD/ADR format: context, constraints, 3+ options, comparison, recommendation. Triggers: architecture decision, ADR, RFC, RFD, trade-offs, options comparison, design choice, pick between, should we use, evaluate approach. Load when weighing 2+ architectural options or writing decision records.
456
- - **biz-scan**: Scan codebase for business opportunities and KPIs
456
+ - **biz-scan**: Scans codebase for business opportunities by analyzing database schemas, API endpoints, tracking events, and feature flags to surface underutilized capabilities, missing KPIs, and monetization gaps. Use when the user asks about revenue opportunities, business metrics, KPI coverage, analytics gaps, or monetization analysis of a codebase.
457
457
  - **brand-voice**: Loaded when writing documentation, content, README, or user-facing text. Prevents generic LLM rhetoric and enforces direct, technical voice.
458
458
  - **briefing**: Generate executive daily briefing across all agents
459
459
  - **build**: Build the project with auto-detected toolchain
@@ -478,7 +478,7 @@ Skills are invocable commands or auto-loaded knowledge sources:
478
478
  - **documentation-standards**: KB document conventions: YAML frontmatter (7 required fields), 5-category taxonomy (reference/howto/procedures/troubleshooting/best-practices), directory-category matching, validate.sh CI rules. Triggers: kb/, KB document, architecture note, SOP, runbook, howto, frontmatter, knowledge base entry, documentation standard. Load when creating or editing any file under kb/.
479
479
  - **ecommerce-patterns**: E-commerce domain patterns: cart, checkout flow, payment providers (Stripe/Adyen), order state machine, inventory, promotions, tax, B2B vs B2C. Triggers: cart, checkout, product, SKU, inventory, payment, Stripe, Shopify, Medusa, Magento, order status, promotion, tax calculation, coupon, refund. Load when working on any e-commerce feature.
480
480
  - **evaluate**: Evaluate skill quality and RAG retrieval accuracy
481
- - **evolve**: Evolve agent definitions via meta-architect
481
+ - **evolve**: Analyzes failure patterns and inefficiencies in agent/skill definitions, then drafts and applies targeted improvements to system prompts, tool permissions, and behavioral rules. Use when the user asks to improve agent behavior, refine skill definitions, update system prompts, or optimize agent configurations based on observed failures.
482
482
  - **explain**: Explain code, architecture, or concepts with diagrams
483
483
  - **explore**: Explore codebase structure, stack, and architecture
484
484
  - **fix**: Auto-fix lint errors, type issues, and simple bugs
@@ -509,13 +509,13 @@ Skills are invocable commands or auto-loaded knowledge sources:
509
509
  - **panic**: Emergency stabilization via system-governor agent
510
510
  - **performance-profiling**: Performance measurement and optimization: four golden signals (latency/traffic/errors/saturation), p50/p95/p99, baseline-change-measure loop, flame graphs, load testing. Triggers: performance, slow, latency, p99, flame graph, profile, bottleneck, optimization, load test, benchmark, CPU profiling, memory leak. Load when diagnosing or optimizing slow code or services.
511
511
  - **persona**: Switch engineering persona at runtime: backend-lead, frontend-lead, devops-eng, junior-dev
512
- - **plan**: Plan implementation with tasks and success criteria
512
+ - **plan**: Breaks down feature requests and project goals into phased implementation plans with task lists, agent assignments, dependency graphs, and success criteria. Use when the user asks to plan a feature, create an implementation roadmap, break down a coding task, or outline project phases.
513
513
  - **plan-writing**: Implementation plan and pre-mortem drafting: phase breakdown, success criteria, risks, rollback plan, acceptance tests, estimated effort. Triggers: implementation plan, pre-mortem, phased plan, project plan, task breakdown, success criteria, rollback strategy, risk register. Load when user asks to write a plan or pre-mortem document.
514
514
  - **plugin-creator**: Creates experimental opt-in plugin packs with manifests, conventions, and optional module scaffolding for Claude and Codex runtimes
515
515
  - **pr**: Create pull requests with pre-flight validation
516
516
  - **prd-to-issues**: Break a PRD into independently-grabbable GitHub issues using vertical slices with HITL/AFK tagging and dependency ordering. Use when user wants to convert a PRD to issues, create tickets, or break down a PRD into work items.
517
517
  - **prd-to-plan**: Convert a PRD into a phased implementation plan using tracer-bullet vertical slices. Use when user wants to break down a PRD, create an implementation plan, plan phases from a PRD, or mentions tracer bullets. Codex-adapted: uses native subagents and plan tracking.
518
- - **predict**: Predict regressions and impact before changes land
518
+ - **predict**: Analyzes code diffs and file changes to identify potential regressions, maps dependency impact across the codebase, and generates a risk-scored impact report. Use when reviewing pull requests, assessing code change risk, checking for breaking changes, or analyzing the blast radius of a diff.
519
519
  - **prompt-caching-patterns**: Loaded when user builds with Anthropic API and needs to cut cost or latency via prompt caching. Covers TTL, cache breakpoints, stacking, invalidation, and measuring hit rate.
520
520
  - **qa-session**: Interactive QA session where user reports bugs conversationally and agent files GitHub issues with domain language. Explores codebase in background for context. Use when user wants to report bugs, do QA, file issues conversationally, or mentions QA session. Codex-adapted: uses native subagents and plan tracking.
521
521
  - **rag-patterns**: RAG architecture: embeddings, chunking strategies, hybrid search (BM25 + vector), reranking, CRAG/self-correcting, multi-hop reasoning, evaluation metrics. Triggers: RAG, embedding, vector search, pgvector, Qdrant, Pinecone, Weaviate, chunking, reranker, retrieval, hybrid search, semantic search, knowledge base, cosine similarity. Load when building or tuning RAG systems.
@@ -536,7 +536,7 @@ Skills are invocable commands or auto-loaded knowledge sources:
536
536
  - **swarm**: Execute tasks via Map-Reduce, Consensus, or Relay swarms Codex-adapted: uses native subagents and plan tracking.
537
537
  - **swift-patterns**: Swift and iOS development patterns: SwiftUI, Combine, async/await, property wrappers, actors, Swift Package Manager, Core Data, UIKit interop, @MainActor. Triggers: Swift, SwiftUI, Combine, iOS, Xcode, actor, property wrapper, Core Data, SPM, UIKit, @MainActor, @State, @Binding. Load when writing or reviewing Swift code.
538
538
  - **tdd**: Test-driven development with red-green-refactor loop and vertical slices. Use when user wants TDD, test-first development, red-green-refactor, or building features with tests driving the implementation. Codex-adapted: uses native subagents and plan tracking.
539
- - **teams**: Launch pre-configured Agent Teams for common workflows Codex-adapted: uses native subagents and plan tracking.
539
+ - **teams**: Launches pre-configured multi-agent teams for code review, debugging, feature development, security audits, and database migrations. Use when the user asks to start a multi-agent workflow, coordinate agent teams, run a team review, or needs parallel agent collaboration on a complex task. Codex-adapted: uses native subagents and plan tracking.
540
540
  - **test**: Run tests with coverage analysis and reporting
541
541
  - **testing-patterns**: Testing strategy and craft: pyramid vs trophy, unit/integration/e2e split, fixtures, mocks vs fakes vs stubs, AAA pattern, flaky test diagnosis, coverage goals, property-based testing. Triggers: test, testing strategy, fixture, mock, stub, AAA, unit test, integration test, e2e, Playwright, Cypress, flaky, coverage, TDD, test pyramid. Load when writing, reviewing, or designing test suites.
542
542
  - **triage-issue**: Triage a bug by deeply exploring the codebase for root cause, then create a GitHub issue with a TDD-based fix plan. Mostly hands-off — minimal user interaction. Use when user reports a bug, wants to investigate an issue, mentions triage, or wants a fix plan. Codex-adapted: uses native subagents and plan tracking.
@@ -548,12 +548,12 @@ Skills are invocable commands or auto-loaded knowledge sources:
548
548
 
549
549
  ## Quality Standards
550
550
 
551
- Derived from the immutable safety constitution (5 articles):
551
+ Derived from the immutable safety constitution (6 articles):
552
552
 
553
553
  **Article I — Safety First**
554
554
  - No data loss: never delete files without backup verification or using reversible operations
555
555
  - No blind execution: never run LLM-generated code without static analysis or review
556
- - No infinite loops: all autonomous loops must have a maximum iteration count (max 3)
556
+ - No infinite loops: all autonomous loops must have a maximum iteration count (max 5)
557
557
 
558
558
  **Article II — Hierarchy of Truth**
559
559
  - The Knowledge Base (`kb/`) is the source of truth; if code contradicts KB, check KB freshness
@@ -572,6 +572,12 @@ Derived from the immutable safety constitution (5 articles):
572
572
  - Commands like `rm -rf`, `DROP TABLE`, `FORMAT` require explicit user confirmation
573
573
  - Operate within assigned model tiers; model tier changes require user approval
574
574
 
575
+ **Article VI — Repair Discipline**
576
+ - No dead code: unused code (files, classes, functions, imports, variables) must be removed in the same change that makes it unused; 'pre-existing' or 'out of scope' is not a valid reason
577
+ - Fix every found bug: bugs, gaps, missing tests, or stale docs discovered during a task must be fixed in the same change when directly adjacent to the work; deferral requires explicit user decision
578
+ - Tests and docs follow behavior: behavior changes must carry matching integration and unit tests plus affected documentation in the same change
579
+ - Verify before claiming done: re-read the diff before marking a task complete; no orphaned references, no missing coverage, no stale docs
580
+
575
581
  ## Workflow Guidelines
576
582
 
577
583
  - **Plan First**: Tasks longer than 1 hour require a plan, success criteria, and pre-mortem
package/CHANGELOG.md CHANGED
@@ -7,6 +7,43 @@ Versioning follows [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ---
9
9
 
10
+ ## v2.10.1 — Art. VI Enforcement Drift Repair (2026-04-21)
11
+
12
+ ### Fixed
13
+ - **`IMMUTABLE_ARTICLES` extended to include Article 6** (`scripts/config_merger.py`, `scripts/config_validator.py`) — v2.10.0 declared Art. VI immutable in `app/constitution.md` but left the enforcement constant at `{1..5}`, so a downstream `extends:` config with `amendments: [{article: 6, ...}]` would silently override Repair Discipline. Constant now `{1..6}`; error message points at article 7+ as the first allowed project-added article.
14
+ - **`scripts/emission.py::generate_quality_standards()` emits Article VI** — generator hard-coded I–V only, so `AGENTS.md`, `GEMINI.md`, editor rule files, and `llms-full.txt` did not carry Art. VI text after the v2.10.0 release. Added four-clause VI block (no dead code, fix every found bug, tests and docs follow behavior, verify before done). All downstream catalogs regenerated.
15
+ - **"5 articles" / "Articles I-V" literals updated to 6 / I-VI** across `README.md`, `app/ARCHITECTURE.md`, `kb/reference/architecture-overview.md`, `kb/reference/enterprise-config-guide.md`, `scripts/config_cli.py` diff label, and `scripts/schemas/ai-toolkit-config.schema.json` description. Added Article VI row to the Constitution table in `architecture-overview.md`.
16
+ - **Article I.3 "Max 3" aligned to Section 4 "Max 5"** in `app/constitution.md` to resolve a pre-existing internal contradiction. Same iteration cap now quoted in `scripts/emission.py` general/quality guidelines.
17
+ - **SKILL.md improvements from PR #8 by @rohan-tessl** — `biz-scan`, `evolve`, `plan`, `predict`, and `teams` gained richer descriptions with explicit "Use when..." clauses and executable protocol steps; team preset details moved to `teams/reference/presets.md` (progressive disclosure). Repo style applied (no em dashes); `plan/SKILL.md` KB Integration section preserved.
18
+
19
+ ### Added
20
+ - **`scripts/validate.py` article-count drift lint** (`validate_constitution_drift`) — parses `app/constitution.md` for `## Article <roman>:` headings, derives the expected count and max roman numeral, and fails strict validation when `README.md`, `app/ARCHITECTURE.md`, or `kb/reference/*` references a stale `N articles` or `Articles I-<roman>` literal. This is how v2.10.0 drift slipped past CI; it will not next time.
21
+
22
+ ### Notes
23
+ - No skill/agent/hook counts changed. Totals remain: 44 agents, 99 skills, 666 tests.
24
+ - Art. VI text itself (in `app/constitution.md`) unchanged from v2.10.0 — only surfaces and enforcement are reconciled with it.
25
+
26
+ ---
27
+
28
+ ## v2.10.0 — Constitution Article VI: Repair Discipline (2026-04-21)
29
+
30
+ ### Added
31
+ - **Constitution Article VI — Repair Discipline** (`app/constitution.md`) — four new immutable rules: no dead code (VI.1), fix every found bug (VI.2), tests and docs follow behavior (VI.3), verify before claiming done (VI.4). Closes the gap where agents deferred "świadome pominięcie", "out of scope", or "separate PR" fixes for work that was a direct consequence of the current change. Articles I–V remain unchanged.
32
+ - **`system-governor` Art. VI audit protocol** (`app/agents/system-governor.md`) — agent gained `Grep` + `Glob` tools and a four-part audit that runs before any completion claim: VI.1 dead-symbol grep, VI.2 deferred-work scan (scoped to commit message + PR body + non-`.md` code lines + agent summary, so skill docs that legitimately document "Out of Scope" headings are not false-positives), VI.3 behavior/test/doc coverage detection, VI.4 diff re-read. Outputs a structured verdict with per-Article PASS/VETO citations.
33
+ - **`clean-code` skill Art. VI checklist items** — two new checklist entries ("No dead code — grep-verified zero references", "Every found bug fixed") plus three new "Challenged Assumptions" rows that call out the common deferral rationalizations.
34
+ - **`refactor-plan` skill Art. VI anchor** — mandatory dead-code cleanup per step, not deferred. Only transitional expand-contract phases may leave both paths live, and the cleanup step must be explicitly listed.
35
+ - **`verification-before-completion` skill Art. VI rows** — three new rows in the evidence-vs-non-evidence table covering VI.1/VI.2/VI.4, plus a "Constitutional Anchors" section that pins the skill to Art. VI.4.
36
+ - **`coding-style` rule Art. VI sections** (`app/rules/common/coding-style.md`, v1.0.0 → v1.1.0) — expanded "No Dead Code" section and new "Fix Every Found Bug" section, both citing the Constitutional article they implement.
37
+
38
+ ### Changed
39
+ - **`system-governor` description** widened to reflect Art. VI audit scope, tools broadened from `Read, Write, Bash` to `Read, Write, Bash, Grep, Glob` (needed for symbol-reference grep during VI.1).
40
+
41
+ ### Notes
42
+ - No skill/agent/hook counts changed. Totals remain: 44 agents, 99 skills, 666 tests.
43
+ - Art. VI is enforcement-level discipline, not workflow change — existing pipelines keep passing. Governor veto gates a completion claim, not a commit.
44
+
45
+ ---
46
+
10
47
  ## v2.9.0 — Skill Routability & Description Lint (2026-04-19)
11
48
 
12
49
  ### Changed
package/README.md CHANGED
@@ -10,11 +10,12 @@
10
10
 
11
11
  ---
12
12
 
13
- ## What's New in v2.9.0
13
+ ## What's New in v2.10.1
14
14
 
15
- - **Skill routability fix** — 30 knowledge skills (`user-invocable: false`) had weak `"Loaded when user asks about X"` descriptions that silently lowered auto-loading hit rate. Rewritten with the Anthropic-docs-aligned shape `[capability]. Triggers: [keywords]. Load when [...]`.
16
- - **Description-quality lint** — `audit_skills.py` now enforces `description + when_to_use 1536 chars` (Anthropic limit), knowledge-skill descriptions 80 chars, and blocks the old anti-pattern from returning. CI fails on regression.
17
- - **Catalogs regenerated** — `AGENTS.md`, `llms.txt`, `llms-full.txt`, `GEMINI.md`, and `.github/copilot-instructions.md` now carry the improved routing signals for Cursor, Windsurf, Copilot, Gemini CLI, and Codex.
15
+ - **Art. VI enforcement drift repaired** — `IMMUTABLE_ARTICLES` in `config_merger.py` and `config_validator.py` extended to include Article 6, so downstream `extends:` configs can no longer override Repair Discipline. Enterprise config schema, CLI diff label, and doc surfaces updated to match.
16
+ - **Generator emits Article VI** — `scripts/emission.py::generate_quality_standards()` now includes Article VI's four clauses; `AGENTS.md`, `GEMINI.md`, `llms-full.txt`, and editor rule files (`.clinerules`, `.roo`, `.windsurf`, `.augment`, `.agents`, `.github/copilot-instructions.md`) all regenerated.
17
+ - **Constitution self-consistency** — Article I.3 "Max 3" aligned to Section 4's "maximum 5 iterations". `validate.py --strict` now fails on article-count drift between `app/constitution.md` and downstream catalogs; the lint parses `## Article <roman>:` headings and fails on stale count or roman-range literals elsewhere.
18
+ - **SKILL.md improvements from #8** (merged from @rohan-tessl) — `biz-scan`, `evolve`, `plan`, `predict`, and `teams` got richer descriptions, executable protocol steps, and structured report templates; team preset details moved to `teams/reference/presets.md` for progressive disclosure. 5 skills total, totals unchanged: 44 agents, 99 skills, 666 tests.
18
19
 
19
20
  See [CHANGELOG.md](CHANGELOG.md) for full history.
20
21
 
@@ -121,7 +122,7 @@ See [CLI Reference](kb/reference/cli-reference.md) for all commands and options.
121
122
  | `agents/` | 44 | Specialized agents across 10 categories |
122
123
  | `hooks/` | 21 global + 5 skill-scoped | Quality gates, path safety, prompt governance, session lifecycle |
123
124
  | `plugins/` | 11 packs | Opt-in domain bundles (security, research, frontend, enterprise, 6 language packs) |
124
- | `constitution.md` | 5 articles | Machine-enforced safety rules |
125
+ | `constitution.md` | 6 articles | Machine-enforced safety rules |
125
126
  | `rules/` | auto-injected | Language-specific and custom rules injected into your configs |
126
127
  | `kb/` | reference docs | Architecture, procedures, and best practices |
127
128
 
@@ -138,7 +139,7 @@ ai-toolkit/
138
139
  │ ├── hooks/ # Hook scripts (21 entries, 12 lifecycle events)
139
140
  │ ├── plugins/ # 11 experimental plugin packs (opt-in)
140
141
  │ ├── output-styles/ # System prompt output style overrides
141
- │ ├── constitution.md # 5 immutable safety articles
142
+ │ ├── constitution.md # 6 immutable safety articles
142
143
  │ └── ARCHITECTURE.md # Full system design
143
144
  ├── kb/ # Reference docs, procedures, plans
144
145
  ├── scripts/ # Validation, install, evaluation scripts
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ai-toolkit",
3
3
  "description": "Professional-grade Claude Code toolkit with persona presets, skill security auditor, expanded lifecycle hooks, experimental opt-in plugin packs, benchmark harvesting, and multi-tool support.",
4
- "version": "2.9.0",
4
+ "version": "2.10.1",
5
5
  "author": {
6
6
  "name": "SoftSpark",
7
7
  "url": "https://github.com/softspark"
@@ -266,7 +266,7 @@ Phase 2: IMPLEMENTATION
266
266
  ├── hooks.json # Quality gate hooks (multi-language)
267
267
  ├── skills/ # All skills: task, hybrid, knowledge
268
268
  ├── output-styles/ # System prompt output style overrides (e.g. golden-rules)
269
- ├── constitution.md # Immutable safety rules (5 articles)
269
+ ├── constitution.md # Immutable safety rules (6 articles)
270
270
  └── settings.local.json # Local settings + Agent Teams config
271
271
  ```
272
272
 
@@ -332,7 +332,7 @@ The `inject_section_cli.py` script provides a stable marker-based injection API.
332
332
  `scripts/compile_slm.py` compiles the full toolkit (20K+ tokens) into a minimal system prompt for Small Language Models (2K-16K tokens). Pipeline: Parse → Score → Compress → Pack → Emit. Supports 4 compression levels (ultra-light, light, standard, extended), 4 output formats (raw, ollama, json-string, aider), persona-aware scoring, and language-aware rule filtering. Profile `offline-slm` in `manifest.json`. Constitution is always included (non-negotiable).
333
333
 
334
334
  ### Config Inheritance (`extends`)
335
- `scripts/config_resolver.py`, `config_merger.py`, `config_validator.py`, `config_cli.py`, `config_scaffold.py`, `config_lock.py`. Enterprise configuration inheritance via `.softspark-toolkit.json` `extends` field. Resolves base configs from npm packages, Git URLs, or local paths. Layered deep merge with constitution immutability (Articles I-V absolute), enforce constraints (`requiredAgents`, `forbidOverride`, `minHookProfile`), override validation (`override: true` + justification), and lock file (`.softspark-toolkit.lock.json`). CLI: `config validate`, `config diff`, `config init`, `config create-base`, `config check`. Integrated into `install --local` and `update --local` flows.
335
+ `scripts/config_resolver.py`, `config_merger.py`, `config_validator.py`, `config_cli.py`, `config_scaffold.py`, `config_lock.py`. Enterprise configuration inheritance via `.softspark-toolkit.json` `extends` field. Resolves base configs from npm packages, Git URLs, or local paths. Layered deep merge with constitution immutability (Articles I-VI absolute), enforce constraints (`requiredAgents`, `forbidOverride`, `minHookProfile`), override validation (`override: true` + justification), and lock file (`.softspark-toolkit.lock.json`). CLI: `config validate`, `config diff`, `config init`, `config create-base`, `config check`. Integrated into `install --local` and `update --local` flows.
336
336
 
337
337
  ### Project Registry
338
338
  `scripts/install_steps/project_registry.py`, `scripts/update_projects.py`, `scripts/projects_cli.py`. Tracks all `--local` installed projects in `~/.softspark/ai-toolkit/projects.json`. `ai-toolkit update` propagates to all registered projects in parallel via `ThreadPoolExecutor`. CLI: `ai-toolkit projects`, `--prune`, `remove <path>`.
@@ -3,7 +3,7 @@ name: system-governor
3
3
  description: "The Guardian of the Constitution. Validates all evolutionary changes and enforces immutable rules. Has VETO power."
4
4
  model: opus
5
5
  color: red
6
- tools: Read, Write, Bash
6
+ tools: Read, Write, Bash, Grep, Glob
7
7
  skills: research-mastery
8
8
  ---
9
9
 
@@ -12,7 +12,7 @@ skills: research-mastery
12
12
  You are the **System Governor**. You serve the Constitution, not the Orchestrator.
13
13
 
14
14
  ## Core Mission
15
- Ensure that no agent (especially `meta-architect`) violates the Immutable Rules.
15
+ Ensure that no agent (especially `meta-architect`) violates the Immutable Rules, and that no task is claimed "done" while Constitutional Article VI (Repair Discipline) is breached.
16
16
 
17
17
  ## Mandatory Protocol (VETO POWER)
18
18
  Before any `/evolve` or `meta-architect` change is applied:
@@ -21,6 +21,7 @@ Before any `/evolve` or `meta-architect` change is applied:
21
21
  - Removing tests? (Violation Art. III.1)
22
22
  - Deleting logs? (Violation Art. III.2)
23
23
  - Bypassing KB? (Violation Art. II.2)
24
+ - Leaving dead code, missing tests for changed behavior, stale docs? (Violation Art. VI)
24
25
  3. **Verdict**:
25
26
  - **APPROVE**: "Constitutional Check Passed."
26
27
  - **VETO**: "VIOLATION DETECTED [Article X]. Change Rejected."
@@ -34,24 +35,113 @@ On startup, verify:
34
35
  ## Capabilities
35
36
 
36
37
  ### 1. Constitutional Review
37
- - **Input**: Pull Request / Diff from `meta-architect`.
38
- - **Output**: Pass/Fail with citation.
38
+ - **Input**: Pull Request / Diff from `meta-architect` or a completion claim.
39
+ - **Output**: Pass/Fail with citation per Article.
39
40
 
40
41
  ### 2. Emergency Halt
41
42
  - **Trigger**: "Kill Switch" activated or massive deletion detected.
42
43
  - **Action**: Lock the task. Notify User immediately.
43
44
 
45
+ ### 3. Article VI Audit (Repair Discipline)
46
+ Run before approving any completion claim that touches code. Each check returns PASS / VETO with evidence.
47
+
48
+ #### VI.1 — No Dead Code
49
+ Produce the list of symbols the change removed or renamed (entities, classes, functions, API resources, l10n keys, imports, DTO fields). For each:
50
+ ```bash
51
+ # Example heuristics; adapt to project's grep/search tools.
52
+ git diff --name-only <base>..HEAD | xargs -I{} grep -nE "OldSymbol" {} 2>/dev/null || true
53
+ rg --no-heading --line-number "OldSymbol" .
54
+ ```
55
+ Also check whether any existing file is now unreferenced because the change stopped calling it:
56
+ ```bash
57
+ # For every .php / .dart / .ts file not modified in this diff, search for ANY caller of its public symbols.
58
+ # Zero-caller files are candidates for deletion.
59
+ ```
60
+ - **VETO** if grep returns zero references for any removed symbol AND the source file still exists.
61
+ - **VETO** if the diff stops calling a whole file and that file is not deleted.
62
+ - **APPROVE** only when dead-code grep is clean.
63
+
64
+ Rationalizations explicitly rejected: "pre-existing", "legacy", "separate refactor", "out of scope", "świadome pominięcie".
65
+
66
+ #### VI.2 — Fix Every Found Bug
67
+ Scan ONLY the three surfaces where a deferral is actually asserted — NOT doc files that legitimately document those phrases as headings or examples.
68
+
69
+ **Scope (in priority order):**
70
+ 1. **Commit message / PR body** — the author's own statement of what this change does:
71
+ ```bash
72
+ git log -1 --format=%B HEAD | grep -iE "TODO\(defer\)|FIXME|świadome pominięcie|out of scope|second step|osobny refactor|separate PR"
73
+ gh pr view --json body -q .body 2>/dev/null | grep -iE "TODO\(defer\)|FIXME|świadome pominięcie|out of scope|second step|osobny refactor|separate PR"
74
+ ```
75
+ 2. **Newly-added lines in NON-documentation files** — code changes only, never `.md` prose:
76
+ ```bash
77
+ git diff --unified=0 <base>..HEAD -- ':!*.md' ':!kb/**' ':!app/skills/**/SKILL.md' ':!app/agents/**/*.md' \
78
+ | grep -E "^\+" | grep -v "^\+\+\+" \
79
+ | grep -iE "TODO\(defer\)|FIXME|świadome pominięcie|out of scope|second step|osobny refactor|separate PR"
80
+ ```
81
+ 3. **Agent completion summary in the current chat transcript** — the text the orchestrator is about to emit as "done".
82
+
83
+ **Explicitly OUT OF SCOPE for this check:**
84
+ - The body of any `.md` file (skill docs, KB, README, CHANGELOG, ADRs). Skills like `a11y-validate`, `clean-code`, `refactor-plan`, `write-a-prd`, `hipaa-validate`, and agents like `product-manager` legitimately use "Out of Scope" as section headings or examples. Matching against their prose is a false positive.
85
+ - Historical commits (scan only the diff under review, not `git log` of the whole branch).
86
+
87
+ **Rulings:**
88
+ - **VETO** any hit in surfaces 1-3 unless paired with an explicit user decision recorded in the PR description or chat.
89
+ - **VETO** if the agent's own summary uses those phrases for fixes that are a direct consequence of the change.
90
+ - **APPROVE** when all three surfaces are clean, even if `.md` docs in the diff contain the phrases as documentation.
91
+
92
+ #### VI.3 — Tests and Docs Follow Behavior
93
+ Detect behavior change surface:
94
+ ```bash
95
+ # Changed public API, processor, controller, endpoint, or exported contract?
96
+ git diff --name-only <base>..HEAD | rg -e 'Processor\.php$' -e 'Controller\.php$' -e 'Api/' -e 'api/endpoints/' -e 'routes' -e 'ApiResource/'
97
+ ```
98
+ For every modified public-surface file, verify:
99
+ - Corresponding integration test exists and was modified in this diff, OR a new integration test was added.
100
+ - Unit test-only coverage for behavior exposed over API is INSUFFICIENT.
101
+ - Docs (`kb/`, `README.md`, `CLAUDE.md`, ADRs) that reference the changed behavior are updated.
102
+ - **VETO** if any of these are missing.
103
+
104
+ #### VI.4 — Verify Before Claiming Done
105
+ Before allowing an agent to emit a completion claim:
106
+ ```bash
107
+ git diff --stat <base>..HEAD # Re-read full shape of the change
108
+ git status # Nothing stranded in the working tree
109
+ ```
110
+ - **VETO** if working tree shows untracked artefacts that look like half-finished work (new files without references, orphan migrations without entity updates).
111
+ - **VETO** if the agent's text claims success but any prior Art. VI check is still failing.
112
+
44
113
  ## Output Format
45
114
  ```markdown
46
115
  ## ⚖️ Governance Verdict
47
116
 
48
117
  ### Proposed Change
49
- Modified `tech-lead.md` to remove `view_skill("research-mastery")`.
118
+ <one-sentence summary of the diff>
50
119
 
51
120
  ### Constitutional Check
52
- - **Article II.2 (Research Protocol)**: VIOLATED.
53
- - **Reason**: Trying to bypass mandatory knowledge check.
121
+ - **Article II.2 (Research Protocol)**: <PASSED | VIOLATED — reason>
122
+ - **Article III.1 (Tests are Sacred)**: <PASSED | VIOLATED reason>
123
+ - **Article VI.1 (No Dead Code)**: <PASSED | VIOLATED — orphan evidence>
124
+ - **Article VI.2 (Fix Every Found Bug)**: <PASSED | VIOLATED — deferred fix evidence>
125
+ - **Article VI.3 (Tests and Docs)**: <PASSED | VIOLATED — missing coverage>
126
+ - **Article VI.4 (Verify Before Done)**: <PASSED | VIOLATED — stale claim evidence>
54
127
 
55
128
  ### RULING
56
- 🔴 **VETO**. This change is rejected.
129
+ 🟢 **APPROVE** Constitutional Check Passed.
130
+ OR
131
+ 🔴 **VETO** — <Articles violated>. Change Rejected. Required remediation: <bulleted fixes>.
57
132
  ```
133
+
134
+ ## When To Run Art. VI Checks
135
+ - Before any `meta-architect` / `/evolve` apply.
136
+ - Before any orchestrator emits a completion claim on a task that touched code.
137
+ - On-demand when invoked directly by the user ("governor, audit this diff").
138
+ - NOT required for documentation-only changes outside `kb/`, scratch files, or explicit WIP commits marked as such.
139
+
140
+ ## Known Bypass Attempts (Auto-Reject)
141
+ | Phrase in the diff or summary | Default ruling |
142
+ |-------------------------------|----------------|
143
+ | "świadome pominięcie" | VETO — direct Art. VI.2 violation |
144
+ | "out of scope (for now)" | VETO unless user-approved in conversation |
145
+ | "separate PR will fix" | VETO unless the follow-up ticket ID is cited |
146
+ | "pre-existing dead code, leaving it" | VETO per Art. VI.1 |
147
+ | "tests will follow" | VETO per Art. VI.3 |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  title: "The Immutable Constitution of the System"
3
- last_updated: "2026-01-30"
3
+ last_updated: "2026-04-21"
4
4
  status: IMMUTABLE
5
5
  ---
6
6
 
@@ -11,7 +11,7 @@ status: IMMUTABLE
11
11
  ## Article I: Safety First
12
12
  1. **No Data Loss**: Never delete a file without verifying a backup exists or using `git rm` (which is reversible).
13
13
  2. **No Blind Execution**: Never execute code generated by an LLM without static analysis or review.
14
- 3. **No Infinite Loops**: All autonomous loops (Learning, Evolving) must have a maximum iteration count (Max 3).
14
+ 3. **No Infinite Loops**: All autonomous loops (Learning, Evolving) must have a maximum iteration count (Max 5, consistent with Section 4).
15
15
 
16
16
  ### Section 4: Autonomous Loop Limits
17
17
  - Autonomous loops (including `/repeat` skill) default to maximum 5 iterations
@@ -43,3 +43,9 @@ status: IMMUTABLE
43
43
  ## Article V: Resource Governance
44
44
  1. **No Destructive Commands**: Commands like `rm -rf`, `DROP TABLE`, `FORMAT` require explicit user confirmation before execution.
45
45
  2. **Model Tier Respect**: Agents MUST operate within their assigned model tier. Model tier changes require user approval.
46
+
47
+ ## Article VI: Repair Discipline
48
+ 1. **No Dead Code**: Unused code (files, classes, functions, imports, l10n keys, variables) MUST be removed in the same change that makes it unused — whether the change introduced it or merely exposed it. "Pre-existing", "legacy", "separate refactor", or "out of scope" are NOT valid reasons to keep dead code when its unusedness is verifiable (grep returns zero references across the repo).
49
+ 2. **Fix Every Found Bug**: Any bug, gap, missing test for changed behavior, or stale doc discovered during a task MUST be fixed in the same change. Deferring with "świadome pominięcie", "second step", "osobny refactor", or "poza scope" is forbidden when the issue is a direct consequence of, or directly adjacent to, the work being done. Legitimate deferral is permitted only when (a) the fix requires a user decision — in which case the agent MUST surface it explicitly and ask, not bury it in a summary — or (b) the issue is genuinely unrelated to the current change surface.
50
+ 3. **Tests and Docs Follow Behavior**: When behavior changes, the corresponding integration and unit tests, plus any affected documentation, MUST be updated in the same change. A unit test on a new helper is not sufficient when the behavior is exposed over an API — add the integration test too.
51
+ 4. **Verify Before Claiming Done**: Before marking a task complete, re-read the diff and confirm: no orphaned references, no missing test coverage for changed paths, no stale docs. If any are present, the task is not done.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  language: common
3
3
  category: coding-style
4
- version: "1.0.0"
4
+ version: "1.1.0"
5
5
  ---
6
6
 
7
7
  # Universal Coding Style
@@ -51,7 +51,17 @@ version: "1.0.0"
51
51
  - Match existing style, even if you would do it differently.
52
52
  - Do not "improve" adjacent code, comments, or formatting unprompted.
53
53
  - Orphan cleanup: remove imports/variables/functions that YOUR changes made unused.
54
- - Do not remove pre-existing dead code unless explicitly asked.
54
+
55
+ ## No Dead Code (Constitution Art. VI.1)
56
+ - When a refactor leaves a file, class, function, import, l10n key, or variable unused, DELETE it in the same change. Verify via grep that zero references remain in the repo.
57
+ - This applies to pre-existing code too, if your work makes its unusedness verifiable. "Legacy", "separate refactor", "out of scope", or "świadome pominięcie" are NOT valid excuses.
58
+ - Before claiming the task done: grep for every symbol you removed or renamed; fix orphaned references.
59
+
60
+ ## Fix Every Found Bug (Constitution Art. VI.2)
61
+ - A bug, missing test for changed behavior, or stale doc discovered while working on a task MUST be fixed in the same change — not deferred to "second step", "separate PR", or "świadome pominięcie".
62
+ - When behavior changes, update integration AND unit tests AND the affected docs alongside. A unit test on a new helper is not sufficient when the behavior is exposed over an API — add the integration test too.
63
+ - Legitimate deferral exists ONLY when: (a) the fix requires a user decision — in that case, surface it explicitly and ask, don't bury in a summary; or (b) the issue is genuinely unrelated to the current change surface.
64
+ - Before marking done: re-read the diff and confirm no orphaned references, no missing test coverage for changed paths, no stale docs. If any are present, keep working.
55
65
 
56
66
  ## Goal-Driven Execution
57
67
  - Transform vague tasks into verifiable goals before starting.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: biz-scan
3
- description: "Scan codebase for business opportunities and KPIs"
3
+ description: "Scans codebase for business opportunities by analyzing database schemas, API endpoints, tracking events, and feature flags to surface underutilized capabilities, missing KPIs, and monetization gaps. Use when the user asks about revenue opportunities, business metrics, KPI coverage, analytics gaps, or monetization analysis of a codebase."
4
4
  effort: medium
5
5
  disable-model-invocation: true
6
6
  argument-hint: "[area]"
@@ -13,18 +13,74 @@ allowed-tools: Read, Grep, Glob
13
13
 
14
14
  $ARGUMENTS
15
15
 
16
- Triggers the Business Intelligence agent to find opportunities.
16
+ Triggers the Business Intelligence agent to analyze the codebase for business opportunities and KPI gaps.
17
17
 
18
18
  ## Usage
19
19
 
20
20
  ```bash
21
21
  /biz-scan [scope]
22
- # Example: /biz-scan schema
23
- # Example: /biz-scan all
22
+ # /biz-scan schema : focus on database models and entity relationships
23
+ # /biz-scan api : focus on API endpoints and data exposure
24
+ # /biz-scan all : full codebase scan
24
25
  ```
25
26
 
26
27
  ## Protocol
27
- 1. **Model Scan**: Read DB schema / Entities.
28
- 2. **Logic Scan**: Read Controllers / UseCases.
29
- 3. **Synthesis**: Match Data vs Business Goals.
30
- 4. **Report**: Generate Opportunity Report.
28
+
29
+ ### 1. Model Scan: Analyze Data Layer
30
+
31
+ Scan for business-relevant data structures:
32
+
33
+ ```bash
34
+ # Find database models, schemas, entities
35
+ grep -rl "model\|schema\|entity\|migration" --include="*.py" --include="*.ts" --include="*.rb" .
36
+ # Find ORM definitions
37
+ grep -rl "prisma\|sequelize\|typeorm\|sqlalchemy\|activerecord" .
38
+ ```
39
+
40
+ Catalog: entity names, relationships, fields that map to business concepts (revenue, subscription, usage, billing).
41
+
42
+ ### 2. Logic Scan: Analyze Business Logic
43
+
44
+ Scan controllers, services, and use cases:
45
+
46
+ ```bash
47
+ # Find API endpoints and handlers
48
+ grep -rn "router\.\|app\.\(get\|post\|put\|delete\)\|@Controller\|@app\.route" --include="*.ts" --include="*.py" --include="*.js" .
49
+ # Find tracking/analytics events
50
+ grep -rn "track\|analytics\|event\|metric\|log_event" --include="*.ts" --include="*.py" --include="*.js" .
51
+ ```
52
+
53
+ Catalog: exposed endpoints, tracked events, feature flags, A/B tests.
54
+
55
+ ### 3. Synthesis: Match Data vs. Business Goals
56
+
57
+ Cross-reference findings to identify:
58
+
59
+ | Category | What to Look For |
60
+ |----------|-----------------|
61
+ | **Missing KPIs** | Entities with no associated tracking events |
62
+ | **Underutilized features** | Endpoints with no analytics or feature-flag coverage |
63
+ | **Monetization gaps** | Subscription/billing entities without conversion tracking |
64
+ | **Data exposure** | Rich internal data not surfaced via API |
65
+
66
+ ### 4. Report: Generate Opportunity Report
67
+
68
+ Output a structured markdown report:
69
+
70
+ ```markdown
71
+ ## Business Opportunity Report: [scope]
72
+
73
+ ### KPI Coverage
74
+ | Entity/Feature | Tracked Events | Gap |
75
+ |---------------|---------------|-----|
76
+ | [name] | [events or "none"] | [what's missing] |
77
+
78
+ ### Opportunities (ranked by estimated impact)
79
+ 1. **[Opportunity]**: [description, affected entities, suggested action]
80
+
81
+ ### Quick Wins
82
+ - [ ] Add tracking to [feature], estimated lift: [low/med/high]
83
+
84
+ ### Data Exposure Gaps
85
+ - [Entity] has [N fields] not exposed via any API endpoint
86
+ ```
@@ -97,6 +97,8 @@ Keep modules focused. Order contents consistently: imports (stdlib, third-party,
97
97
  - [ ] Resources are properly cleaned up
98
98
  - [ ] No code duplication
99
99
  - [ ] Tests cover critical paths
100
+ - [ ] **No dead code** — grep-verified zero references for every removed/renamed symbol; pre-existing dead code touched by this change is deleted too (Constitution Art. VI.1)
101
+ - [ ] **Every found bug fixed** — bugs, missing tests for changed behavior, and stale docs discovered during the task are fixed in the same change, not deferred (Constitution Art. VI.2)
100
102
 
101
103
  ---
102
104
 
@@ -109,6 +111,9 @@ Keep modules focused. Order contents consistently: imports (stdlib, third-party,
109
111
  | "Short variable names are faster to type" | You type it once, readers parse it hundreds of times — optimize for reading |
110
112
  | "DRY means never repeat anything" | Wrong DRY creates coupling — duplicate until you see the real abstraction |
111
113
  | "More abstractions = cleaner code" | Premature abstraction is worse than duplication — wait for the third use |
114
+ | "That dead file is pre-existing, not my problem" | If your change makes it verifiably unused, deleting it IS your problem (Constitution Art. VI.1) |
115
+ | "I'll fix the missing test in a separate PR" | Forbidden when the test covers behavior you just changed — add it now (Constitution Art. VI.2) |
116
+ | "Świadome pominięcie" / "out of scope" | Deferral of directly-adjacent fixes is forbidden; if a user decision is needed, ASK, don't bury it |
112
117
 
113
118
  ## Language-Specific References
114
119
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: evolve
3
- description: "Evolve agent definitions via meta-architect"
3
+ description: "Analyzes failure patterns and inefficiencies in agent/skill definitions, then drafts and applies targeted improvements to system prompts, tool permissions, and behavioral rules. Use when the user asks to improve agent behavior, refine skill definitions, update system prompts, or optimize agent configurations based on observed failures."
4
4
  effort: medium
5
5
  disable-model-invocation: true
6
6
  context: fork
@@ -10,18 +10,58 @@ allowed-tools: Read, Edit, Grep, Glob
10
10
 
11
11
  # Evolve Command
12
12
 
13
- Triggers the Meta-Architect to improve the system.
13
+ $ARGUMENTS
14
+
15
+ Triggers the Meta-Architect to improve agent and skill definitions based on observed patterns.
14
16
 
15
17
  ## Usage
16
18
 
17
19
  ```bash
18
20
  /evolve [source]
19
- # Example: /evolve learnings (Analyze kb/learnings)
20
- # Example: /evolve last-failure (Analyze last error log)
21
+ # /evolve learnings : analyze kb/learnings/ for recurring failure patterns
22
+ # /evolve last-failure : analyze the most recent error log
23
+ # /evolve agents : audit all agent definitions for gaps
21
24
  ```
22
25
 
23
26
  ## Protocol
24
- 1. **Analyze**: Read input source for patterns of failure/inefficiency.
25
- 2. **Design**: Draft changes to `.claude/agents/` or `.claude/skills/`.
26
- 3. **Implement**: Apply changes.
27
- 4. **Report**: Document what evolved.
27
+
28
+ ### 1. Analyze
29
+
30
+ Read the input source and extract actionable patterns:
31
+
32
+ - **learnings**: grep `kb/learnings/` for entries tagged `failure`, `retry`, `timeout`, or `inefficiency`
33
+ - **last-failure**: read the most recent file in `kb/learnings/` and identify root cause
34
+ - **agents**: scan all `.md` files in `app/agents/` for missing tools, vague prompts, or mismatched model tiers
35
+
36
+ ### 2. Design
37
+
38
+ Draft changes targeting the identified patterns:
39
+
40
+ | Target | File Location | Change Type |
41
+ |--------|--------------|-------------|
42
+ | Agent definitions | `app/agents/*.md` | Frontmatter (tools, model), system prompt text |
43
+ | Skill definitions | `app/skills/*/SKILL.md` | Description, workflow steps, allowed-tools |
44
+ | Rules | `app/rules/` | New or updated rule files |
45
+
46
+ Show the proposed diff to the user before applying.
47
+
48
+ ### 3. Implement
49
+
50
+ Apply approved changes. After each edit:
51
+
52
+ - Run `python3 scripts/validate.py` to confirm structural integrity
53
+ - Verify YAML frontmatter parses without errors
54
+ - Confirm no forbidden patterns (eval, exec, shell=True)
55
+
56
+ ### 4. Report
57
+
58
+ Create a summary documenting what evolved:
59
+
60
+ ```markdown
61
+ ## Evolution Report
62
+ - **Source**: [learnings | last-failure | agents]
63
+ - **Pattern found**: [description of failure/inefficiency]
64
+ - **Changes applied**:
65
+ - `app/agents/[name].md`: [what changed and why]
66
+ - **Validation**: passed / failed
67
+ ```