akili-specs 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.
@@ -212,6 +212,8 @@ When the file already exists, refine it in place instead of replacing establishe
212
212
 
213
213
  Create or enhance `docs/trd/trd.md` as the technical implementation blueprint.
214
214
 
215
+ **Required skill:** load `software-architect` before drafting the TRD and apply its Decision Spine throughout this step — capture NFRs as six-part quality-attribute scenarios with measurable responses, choose tactics, decide the robust-vs-lite tier and architecture style, bind design patterns to named problems, and document with C4 views plus ADRs.
216
+
215
217
  **Use skills when relevant** (stack skills — load only the ones matching the project's stack; the same set feeds the `## Skill Map` in Step 8D):
216
218
 
217
219
  - `nestjs-expert`
@@ -226,16 +228,18 @@ Create or enhance `docs/trd/trd.md` as the technical implementation blueprint.
226
228
  **Required structure:**
227
229
 
228
230
  1. System Overview
229
- 2. Domain Modules & Responsibilities
230
- 3. Data Model & Entities
231
- 4. API Surface & Contracts
232
- 5. Backend Workflows & Business Rules
233
- 6. Frontend Architecture & State Boundaries
234
- 7. Integration Points
235
- 8. Security & Authorization Model
236
- 9. Error Handling & Observability
237
- 10. Testing Strategy
238
- 11. Technical Constraints & Assumptions
231
+ 2. Architecture Overview & Decisions (C4 Context + Container with legends, style choice, robust-vs-lite tier decision, ADR index)
232
+ 3. Quality Attribute Scenarios (Non-Functional Requirements — six-part scenarios with measurable responses and chosen tactics; security, performance, scalability, and availability always evaluated)
233
+ 4. Domain Modules & Responsibilities
234
+ 5. Data Model & Entities
235
+ 6. API Surface & Contracts
236
+ 7. Backend Workflows & Business Rules
237
+ 8. Frontend Architecture & State Boundaries
238
+ 9. Integration Points
239
+ 10. Security & Authorization Model
240
+ 11. Error Handling & Observability
241
+ 12. Testing Strategy
242
+ 13. Technical Constraints & Assumptions
239
243
 
240
244
  ---
241
245
 
@@ -243,6 +247,8 @@ Create or enhance `docs/trd/trd.md` as the technical implementation blueprint.
243
247
 
244
248
  Create or enhance `docs/infrastructure.md` as the deployment and hosting blueprint.
245
249
 
250
+ The infrastructure shape derives from the TRD's robust-vs-lite tier decision (Step 5, `software-architect` skill) — never precedes it. Cite the tier decision and its ADR at the top of the document.
251
+
246
252
  **Required structure:**
247
253
 
248
254
  1. Target Environment (e.g., AWS, GCP, Vercel, On-prem)
@@ -57,6 +57,8 @@ If `.agents/` is missing, run `/akili-constitution` first to scaffold it. Do not
57
57
 
58
58
  The Leader does not write production code itself unless the rework loop is exhausted and the user has explicitly approved a fallback.
59
59
 
60
+ **Communication economy:** load the `caveman` skill and apply its Scope Contract to all transient output in this command — inter-agent messages (Leader ↔ Implementer/Reviewer briefs, reports, feedback relays) at `full`, user-visible progress lines at `lite`. It never applies to `execution.md` audit entries, PR descriptions, HITL summaries, Pivot blockers, or verbatim evidence (Reviewer FAIL reports pass unchanged — the Structured Feedback rule wins).
61
+
60
62
  ---
61
63
 
62
64
  ## Behavior
@@ -179,6 +179,8 @@ Wait for the user's response before moving on.
179
179
 
180
180
  Use `brainstorming` to explore trade-offs before writing.
181
181
 
182
+ If the feature is architecturally significant (a new module or service, a new integration or data flow, a persistence or communication-topology change, or any stated NFR impact), load `software-architect` and apply its Decision Spine: NFR scenarios with measurable responses, tactics, robust-vs-lite sizing, pattern selection bound to named problems, and ADR-style design decisions.
183
+
182
184
  If the work includes meaningful UI/UX impact, use this skill preference:
183
185
 
184
186
  - `ui-ux-pro-max` if available
@@ -57,6 +57,7 @@ If `.agents/tester.md` is missing, run `/akili-constitution` first to scaffold i
57
57
 
58
58
  - Give each Tester **only its slice**: its assigned suite, the specific requirements + Given/When/Then scenarios that suite must prove, and the project's test command. Never hand a Tester the full `requirements.md`/`design.md`/`tasks.md` unless a scenario genuinely needs it.
59
59
  - Each Tester's context is discarded when it finishes, so per-suite contexts never accumulate in one growing window.
60
+ - Load the `caveman` skill and apply its Scope Contract: Leader→Tester context slices and Tester structured reports use `full` compression; `test-report.md`, `PRODUCT_BUG` escalations to the user, and verbatim evidence (requirement and Given/When/Then scenario text quoted in slices, test output, `STATUS:` lines, error strings) are never compressed.
60
61
  - The Leader writes no tests itself unless the Deployment Rule below says to run inline, or a Tester exhausts its inner loop and the user approves a Leader fallback.
61
62
 
62
63
  **Deployment Rule (how many Testers to spawn):**
@@ -0,0 +1,72 @@
1
+ ---
2
+ name: caveman
3
+ description: "Trigger: token efficiency, 'less tokens', 'be brief', caveman mode, inter-agent communication in /akili-execute and /akili-test. Ultra-compressed communication style (~65% fewer output tokens, measured upstream) for TRANSIENT agent output only — technical substance stays, fluff dies. Never applies to persistent documents (cognitive-doc-design territory) or HITL approval gates."
4
+ license: MIT
5
+ metadata:
6
+ author: Julius Brussee
7
+ source: https://github.com/juliusbrussee/caveman
8
+ adapted-by: "Juan Carlos Cadavid — jcadavid.com"
9
+ adapted-for: "AKILI-SPECS"
10
+ binding: core
11
+ version: "1.0"
12
+ ---
13
+
14
+ # Caveman — Token-Economy Communication for Transient Agent Output
15
+
16
+ Respond terse like smart caveman. All technical substance stay. Only fluff die.
17
+
18
+ In AKILI, output-token waste is **MUDA** (see `kaizen`). This skill is the preventive tactic: it compresses the style of *transient* agent output — the chatter nobody rereads — while the documents humans live with stay under `cognitive-doc-design`.
19
+
20
+ ## Scope Contract (the AKILI boundary — read first)
21
+
22
+ | Output | Caveman? | Level |
23
+ |---|---|---|
24
+ | Inter-agent messages (Leader ↔ Implementer / Reviewer / Tester): task briefs, completion reports, status relays — the verbatim zones below always win (Reviewer/Tester reports relay unchanged) | **Yes** | `full` |
25
+ | Progress narration and status lines shown to the user mid-run | **Yes** | `lite` |
26
+ | Persistent artifacts: PRD, TRD, `requirements.md`, `design.md`, `tasks.md`, `execution.md` audit entries, `test-report.md`, PR descriptions, Kaizen log | **No** — `cognitive-doc-design` owns artifacts | off |
27
+ | HITL approval gates: option menus, blocker questions, end-of-task summaries the user decides on | **No** — decision quality > token savings | off |
28
+ | Security warnings, irreversible-action confirmations, Pivot Protocol blockers | **No** (upstream Auto-Clarity rule) | off |
29
+ | Verbatim evidence: requirement text and Given/When/Then acceptance criteria quoted in briefs/slices, error strings, Reviewer findings passed to rework, test output, code, commands | **Never compressed or paraphrased** | n/a |
30
+
31
+ One sentence to remember: *`cognitive-doc-design` owns artifacts; `caveman` owns transient agent output.*
32
+
33
+ ## Rules (upstream, preserved)
34
+
35
+ Drop: articles (a/an/the), filler (just/really/basically/actually/simply), pleasantries (sure/certainly/of course), hedging. Fragments OK. Short synonyms (big not extensive, fix not "implement a solution for"). No tool-call narration, no decorative tables/emoji, no dumping long raw error logs unless asked — quote shortest decisive line. Standard tech acronyms OK (DB/API/HTTP); **never invent abbreviations** (cfg/impl/req/res/fn) — tokenizer splits them same as full word: zero tokens saved, reader still decodes. No causal arrows (→) — own token, saves nothing. Technical terms exact. Code blocks unchanged. Errors quoted exact.
36
+
37
+ Preserve the user's dominant language — compress the style, not the language (Spanish user gets Spanish caveman). Keep technical terms, code, API names, CLI commands, commit-type keywords, and exact error strings verbatim.
38
+
39
+ No self-reference: never announce or name the style, no "caveman mode on".
40
+
41
+ Pattern: `[thing] [action] [reason]. [next step].`
42
+
43
+ - Not: "Sure! I'd be happy to help. The issue you're experiencing is likely caused by..."
44
+ - Yes: "Bug in auth middleware. Token expiry check use `<` not `<=`. Fix:"
45
+
46
+ ## Intensity Levels (upstream; AKILI uses `lite` and `full`)
47
+
48
+ | Level | What changes |
49
+ |---|---|
50
+ | **lite** | No filler/hedging. Keep articles + full sentences. Professional but tight |
51
+ | **full** | Drop articles, fragments OK, short synonyms. No tool-call narration, no decorative tables/emoji, no raw log dumps. Standard acronyms OK; no invented abbreviations |
52
+ | **ultra** | Strip conjunctions when unambiguous; one word when one word enough. Not used by AKILI defaults — allowed only if the user explicitly asks |
53
+ | wenyan-* | Classical-Chinese register variants from upstream; not used by AKILI |
54
+
55
+ Example — "Why React component re-render?"
56
+ - lite: "Your component re-renders because you create a new object reference each render. Wrap it in `useMemo`."
57
+ - full: "New object ref each render. Inline object prop = new ref = re-render. Wrap in `useMemo`."
58
+
59
+ ## Auto-Clarity (upstream, preserved and extended)
60
+
61
+ Drop caveman when: security warnings; irreversible-action confirmations; multi-step sequences where fragment order risks misread; compression itself creates ambiguity (`"migrate table drop column backup first"` — order unclear); the user asks to clarify or repeats a question. **AKILI extension:** every HITL pause is an Auto-Clarity zone by definition. Resume caveman after the clear part is done.
62
+
63
+ ## AKILI-SPECS Integration
64
+
65
+ | AKILI moment | This skill's job |
66
+ |---|---|
67
+ | `/akili-execute` | Leader→Implementer briefs, Implementer completion reports, Leader relay of Reviewer feedback: `full`. Progress lines: `lite`. `execution.md` audit entries, PR descriptions, HITL summaries and Pivot blockers: **off** |
68
+ | `/akili-test` | Leader→Tester context slices and Tester structured reports: `full`. `test-report.md` and PRODUCT_BUG escalations to the user: **off** |
69
+ | Every other command | Not loaded. Documents and user-facing methodology output are `cognitive-doc-design` territory |
70
+ | `kaizen` | Token savings from compressed inter-agent chatter are measurable MUDA reduction; a retrospective may cite them |
71
+
72
+ Adaptation rules: the Structured Feedback rule of `/akili-execute` wins over compression — Reviewer FAIL reports pass to the next Implementer **unchanged, never paraphrased**; a Tester's `STATUS:` lines and evidence quotes are verbatim zones; when in doubt whether output is transient or persistent, treat it as persistent (off).
@@ -32,6 +32,8 @@ Use it especially for:
32
32
 
33
33
  The AKILI templates in `docs/specs/general-setup/` win over the default Documentation Shape below — apply the Critical Patterns inside their structure.
34
34
 
35
+ **Boundary with `caveman`:** this skill owns *persistent artifacts* (documents humans reread — PRDs, TRDs, specs, reports, PR descriptions); `caveman` owns *transient agent output* (inter-agent messages, progress narration in `/akili-execute` and `/akili-test`). Never apply caveman compression to a document this skill governs, and never pad transient chatter with document structure.
36
+
35
37
  ## Critical Patterns
36
38
 
37
39
  | Pattern | Rule |
@@ -0,0 +1,109 @@
1
+ ---
2
+ name: software-architect
3
+ description: "Trigger: TRD creation, architecture design, non-functional requirements (NFR), quality attributes (security, performance, scalability, availability), architecture styles (hexagonal, clean architecture, microservices, serverless, modular monolith), design patterns (adapter, bridge, builder, GoF), C4 diagrams, ADRs, robust-vs-lite stack sizing. Senior software architect skill: capture NFRs as testable scenarios, choose tactics, size the architecture tier, select patterns, document with C4 + ADRs."
4
+ license: MIT
5
+ metadata:
6
+ author: Juan Carlos Cadavid — jcadavid.com
7
+ binding: core
8
+ version: "1.0"
9
+ inspired-by: "SEI quality-attribute scenarios & tactics (Bass/Clements/Kazman, Software Architecture in Practice), Documenting Software Architectures: Views and Beyond (Clements et al., SEI), the C4 model (Simon Brown), Refactoring.Guru design patterns catalog (Alexander Shvets), Clean Architecture (Robert C. Martin), Hexagonal/Ports & Adapters (Alistair Cockburn), Google Cloud agentic AI architecture guides"
10
+ ---
11
+
12
+ # Software Architect — The AKILI Architecture & NFR Skill
13
+
14
+ This skill makes the agent operate as a **senior software architect**: the role accountable for translating business needs into system structure, identifying non-functional requirements before they become production incidents, selecting technology deliberately, and leaving every decision documented and justified. Architecture is decided by evidence, never by fashion.
15
+
16
+ > Requirements without measures are wishes. Patterns without problems are decoration. Infrastructure without a tier decision is gambling.
17
+
18
+ This file is the **core + router**: the decision method every architecture task needs, plus a table telling you which `references/` file to load. Read the core, then load exactly the reference(s) the task requires — never all of them.
19
+
20
+ ## Activation Contract
21
+
22
+ Load this skill when:
23
+
24
+ - `/akili-constitution` reaches **Step 5 (TRD)** — the primary, automatic trigger. Step 6 (Infrastructure) inherits its tier decision.
25
+ - `/akili-specify` Phase 2 designs an **architecturally significant** feature: a new module or service, a new integration or data flow, a change to persistence or communication topology, or any stated NFR impact.
26
+ - The user asks for architecture review, NFR identification, technology/stack selection, or design-pattern guidance.
27
+
28
+ Not for trivial changes: `/akili-quick` work and single-component edits never need this skill.
29
+
30
+ ## The Decision Spine (the AKILI method)
31
+
32
+ Every architecture engagement walks the same five steps, in order. Each step's output feeds the next; skipping a step means a later decision has no justification.
33
+
34
+ | # | Step | Question it answers | Output |
35
+ |---|---|---|---|
36
+ | 1 | **Scenario** | What must the system *withstand*? | NFRs as six-part quality-attribute scenarios with **measurable responses** |
37
+ | 2 | **Tactic** | What design decision satisfies each scenario? | Named tactics per attribute (e.g. replication, encapsulation, caching, rate limiting) |
38
+ | 3 | **Tier & Style** | How much architecture do these tactics justify? | Robust-vs-lite tier decision + architecture style (hexagonal, clean, microservices…) |
39
+ | 4 | **Pattern** | Which proven structures implement the style? | Design patterns bound to named problems, with rejected alternatives |
40
+ | 5 | **View & Record** | How does everyone else understand it? | C4 diagrams (with legend), ADRs for hard-to-undo decisions, TRD sections |
41
+
42
+ The spine is traceable in both directions: every pattern points back to a tactic, every tactic to a scenario, every scenario to a business driver. A reviewer (or `judgment-day`) must be able to ask "why does this exist?" at any node and get an answer from the document, not from memory.
43
+
44
+ ## The Robust-vs-Lite Gate (Step 3 detail)
45
+
46
+ Default to **LITE**. Escalate to **ROBUST** only when a scenario's response measure cannot be met without it — and record the escalation as an ADR.
47
+
48
+ | Axis | LITE (default) | ROBUST (needs evidence) |
49
+ |---|---|---|
50
+ | Structure | Modular monolith, clean/hexagonal layering inside one deployable | Microservices / event-driven topology |
51
+ | Compute | Serverless or single managed runtime | Containers/orchestration, dedicated clusters |
52
+ | Data | One primary database + cache | Polyglot persistence, CQRS, event sourcing |
53
+ | Async | Direct calls + one queue where needed | Broker topology, sagas, streaming |
54
+ | AI | Single agent, managed LLM API | Multi-agent orchestration, self-hosted models |
55
+
56
+ Escalation triggers (any one, evidenced by a scenario): independent scaling of hot paths; team count > deployables; divergent availability targets per module; regulatory isolation; response measures a monolith demonstrably cannot meet. **"We might need it later" is not a trigger** — record it under Technical Constraints & Assumptions as a revisit condition instead. The tier decision is what `docs/infrastructure.md` (constitution Step 6) derives its shape from.
57
+
58
+ ## Routing — load the matching reference
59
+
60
+ | If the task involves… | Read |
61
+ |---|---|
62
+ | Capturing/refining NFRs, quality-attribute scenarios, tactics per attribute (availability, performance, security, modifiability, scalability, observability, cost) | `references/nfr-scenarios.md` |
63
+ | Choosing architecture style — hexagonal, clean, modular monolith, microservices, event-driven, serverless, CQRS — and the robust-vs-lite matrix, incl. Node.js/TypeScript layer mapping | `references/architecture-styles.md` |
64
+ | Selecting or justifying design patterns (22-pattern GoF-based catalog), SOLID/design principles, tactic→pattern bridge | `references/design-patterns.md` |
65
+ | Documenting: C4 levels, choosing views per stakeholder, view template, ADR template, interface specs | `references/views-documentation.md` |
66
+ | AI/LLM system architecture: agent patterns (single, ReAct, sequential, coordinator…), component decisions (framework, memory, tools, runtime), RAG/vector storage | `references/agentic-ai.md` |
67
+
68
+ A full TRD normally needs `nfr-scenarios.md` + `architecture-styles.md`, and `views-documentation.md` when drawing views; load `design-patterns.md` only when module design starts, and `agentic-ai.md` only when the system embeds LLM/agent behavior.
69
+
70
+ ## Hard Rules
71
+
72
+ 1. **No NFR without a measure.** Every quality-attribute scenario ends in a response measure a tester could verify (number, threshold, or observable condition). "The system must be fast/secure/scalable" never appears in a document this skill touched.
73
+ 2. **Minimum NFR sweep.** Always evaluate security, performance, scalability, and availability explicitly — plus modifiability, observability, and cost when the system will live longer than a prototype. Explicitly marking an attribute "not architecturally significant here" is valid output; silence is not.
74
+ 3. **No pattern without a named problem.** A design pattern enters the design only bound to the problem it solves and the tactic it implements; state the simpler alternative it beat.
75
+ 4. **Start lite, escalate with evidence** through the Robust-vs-Lite Gate; escalations become ADRs.
76
+ 5. **ADRs for the hard-to-undo.** Decisions that are expensive to reverse, took real evaluation effort, or will confuse future readers get an ADR (issue → decision → alternatives → argument → implications). Never defer rationale.
77
+ 6. **Every diagram has a legend.** C4 levels Context and Container are the default; Component only for complex containers; Code level almost never.
78
+ 7. **Respect the stack, then challenge it.** Read the project's declared stack and `## Skill Map` first; propose deviations (e.g. Go for a hot path, Python for ML) only through an ADR with a scenario as evidence.
79
+ 8. **Token frugality (MUDA).** Conceptual designs only — no implementation code in TRD/design documents. Load only the references the task needs. Reuse existing document sections instead of restating them.
80
+
81
+ ## Output Contract — where the spine lands in the TRD
82
+
83
+ | Spine output | TRD home (`docs/trd/trd.md`) |
84
+ |---|---|
85
+ | C4 Context + Container, style choice, tier decision | `Architecture Overview & Decisions` |
86
+ | Six-part scenarios + chosen tactics | `Quality Attribute Scenarios (Non-Functional Requirements)` |
87
+ | ADR log (compact table + per-ADR entries) | `Architecture Overview & Decisions` |
88
+ | Pattern selections with justification | `Domain Modules & Responsibilities` / feature `design.md` §Design Decisions |
89
+ | Security scenarios & tactics detail | `Security & Authorization Model` |
90
+ | Observability scenarios detail | `Error Handling & Observability` |
91
+ | Tier consequences for deployment | `docs/infrastructure.md` (Step 6 input) |
92
+
93
+ In `/akili-specify`, the same outputs land in `design.md`: Architecture Overview, Design Decisions (ADR-style), and requirement-linked NFR scenarios.
94
+
95
+ ## AKILI-SPECS Integration
96
+
97
+ | AKILI moment | This skill's job |
98
+ |---|---|
99
+ | `/akili-constitution` Step 5 (TRD) | Run the full Decision Spine; produce Architecture Overview & Decisions + Quality Attribute Scenarios sections; sweep the minimum NFR set against the PRD |
100
+ | `/akili-constitution` Step 6 (Infrastructure) | Hand over the tier decision — infrastructure shape derives from robust-vs-lite, never precedes it |
101
+ | `/akili-specify` Phase 2 (design.md) | Spine on feature scale: scenarios for the feature's NFR deltas, patterns for its module design, ADR-style Design Decisions |
102
+ | `judgment-day` review gate | The spine's traceability (scenario → tactic → pattern) is what the judges audit; keep every link explicit in the document |
103
+ | `/akili-execute` | Not loaded — implementers receive decisions through the TRD/design docs, not by re-running this skill |
104
+
105
+ Adaptation rules: PRD business goals are the only valid source of scenario stimuli (no invented requirements); the project `## Skill Map` and declared stack constrain style choices before preference does; scenario measures become test candidates for `/akili-test`'s non-functional checks.
106
+
107
+ ## References (attribution)
108
+
109
+ Method synthesized and authored by Juan Carlos Cadavid for AKILI-SPECS, standing on: SEI quality-attribute scenarios and tactics (Bass, Clements & Kazman — *Software Architecture in Practice*), *Documenting Software Architectures: Views and Beyond* (Clements et al.), the C4 model (Simon Brown), the Refactoring.Guru pattern catalog (Alexander Shvets), Clean Architecture (Robert C. Martin), Hexagonal Architecture (Alistair Cockburn), and Google Cloud's agentic AI architecture guides.
@@ -0,0 +1,59 @@
1
+ # Agentic AI Architecture — Patterns & Component Decisions
2
+
3
+ For systems embedding LLM/agent behavior. The Decision Spine applies unchanged: token cost, latency, and accuracy are **quality-attribute scenarios** like any other — write measures first, then pick the pattern. The Robust-vs-Lite gate is strictest here because agent complexity multiplies token spend.
4
+
5
+ ## Pattern Catalog — cheapest that meets the measure wins
6
+
7
+ ### Single-agent (LITE — the default)
8
+ | Pattern | Idea | Choose when |
9
+ |---|---|---|
10
+ | **Single Agent** | One model + tools + system prompt, end-to-end | Start here. Most assistant/automation features |
11
+ | **ReAct loop** | Think → act → observe until done | Dynamic environments, multi-step tool use; accuracy > latency |
12
+
13
+ ### Multi-agent (ROBUST — each needs a scenario)
14
+ | Pattern | Idea | Choose when | Cost profile |
15
+ |---|---|---|---|
16
+ | **Sequential** | Linear pipeline, output → input | Fixed repeatable stages (ingest → classify → draft) | Low |
17
+ | **Parallel** | Independent subagents, results synthesized | Decomposable subtasks; latency reduction | Medium |
18
+ | **Loop** | Repeat until exit condition | Iterative refinement; **hard termination guard required** | Runaway risk |
19
+ | **Review-Critique** | Generator + critic gate | High-accuracy output (audited code, compliance text) | +1 model call per cycle |
20
+ | **Coordinator** | Central agent routes to specialists dynamically | Adaptive triage; heterogeneous requests | High (routing calls) |
21
+ | **Hierarchical** | Recursive decomposition tree | Open-ended research-class problems | Very high |
22
+ | **Swarm** | Peer-to-peer agents, no orchestrator | Almost never justified in products | Highest |
23
+
24
+ ### Cross-cutting
25
+ - **Human-in-the-Loop** — approval pauses at defined points; mandatory for high-stakes/irreversible actions (a security tactic, not an option).
26
+ - **Custom logic orchestration** — deterministic code decides the flow, agents fill steps; prefer this over agent-decides-everything when the workflow is known (cheaper, testable, debuggable).
27
+
28
+ Escalation rule: Single Agent → add tools → ReAct → Sequential/Custom logic → one specialized multi-agent pattern. Each step is an ADR citing the measure the previous step failed.
29
+
30
+ ## Component Decision Axes
31
+
32
+ | Axis | LITE | ROBUST | Decision driver (scenario) |
33
+ |---|---|---|---|
34
+ | Model access | Managed API: Bedrock, OpenAI, Anthropic | Multi-model routing; fine-tuned/self-hosted | Cost/latency measures; data-residency security scenarios |
35
+ | Model choice | One capable default model | Router: small model first, escalate on confidence | Cost ceiling per request |
36
+ | Tools | Few function tools in-process | MCP servers / API-gateway-governed tools | Tool reuse across agents; governance requirements |
37
+ | Memory (short) | In-context only | Externalized session state (Redis/DynamoDB) | Horizontal scaling scenario — any multi-instance deploy forces this |
38
+ | Memory (long) / RAG | S3 Vectors + Bedrock KB, single index | OpenSearch vector store, hybrid search, reranking | Corpus size, recall measures, filter complexity |
39
+ | Runtime | Lambda / managed agent runtime | Containers (ECS/EKS) for long-running or stateful agents | Execution time limits, streaming needs |
40
+ | Guardrails | Provider-level (Bedrock Guardrails) + input validation | Dedicated eval/guard pipeline, red-team suite | Security & compliance scenarios |
41
+
42
+ AWS-first defaults (per AKILI expertise): Bedrock for orchestration/models, S3 Vectors for lite RAG, OpenSearch for robust retrieval, Step Functions for deterministic orchestration of agent steps; OpenAI/Anthropic APIs when the project's ecosystem or model requirements dictate.
43
+
44
+ ## LLM-Specific NFR Scenarios (write these explicitly)
45
+
46
+ - **Cost:** `1000 requests/day → agent pipeline ⇒ ≤ $X/month; alarm at 80%` — token budget is a response measure.
47
+ - **Latency:** p95 including model calls; streaming-first for user-facing paths.
48
+ - **Accuracy/quality:** eval-set pass rate ≥ X% before deploy; regression evals in CI.
49
+ - **Safety/security:** prompt-injection resistance on tool-using paths (treat all retrieved/user content as untrusted input to tools); PII redaction before external model calls; auditable trace of every tool invocation (non-repudiation tactic).
50
+ - **Availability:** provider outage behavior — degrade to smaller model / cached answers / honest failure (graceful-degradation tactic + circuit breaker on the provider port).
51
+ - **Determinism boundary:** which steps must be reproducible (temperature 0, seeded, or code) vs creative — record as variability.
52
+
53
+ ## Architecture Rules for LLM Systems
54
+
55
+ 1. The model provider sits behind a **port** (hexagonal): swapping Bedrock ↔ OpenAI ↔ Anthropic touches one adapter — this is the modifiability tactic that pays for itself first.
56
+ 2. Prompts and model config are **versioned artifacts** (config/defer-binding tactic), not string literals in code.
57
+ 3. Every agent action is **observable**: correlation ID from user request through every model/tool call (traces are also the audit log).
58
+ 4. Multi-agent is a distributed system: apply the same rigor — idempotency, timeouts, budgets-as-bulkheads (max tokens/steps per request).
59
+ 5. In the C4 container view, model providers and vector stores are external systems/containers with labeled protocols; the trust boundary between them and user data is drawn explicitly.
@@ -0,0 +1,67 @@
1
+ # Architecture Styles & the Robust-vs-Lite Matrix
2
+
3
+ Style is chosen **after** scenarios and tactics exist (Decision Spine step 3). A style is a vocabulary of components/connectors plus constraints; it earns its place by satisfying the scenario set at the lowest complexity that works.
4
+
5
+ ## Style Catalog — when each one wins
6
+
7
+ | Style | Core idea | Choose when scenarios show… | Watch out |
8
+ |---|---|---|---|
9
+ | **Layered / N-tier** | Presentation / business / data separation, dependencies point down | Simple CRUD systems, small teams, uniform scaling | Layer skipping, "lasagna" of anemic layers |
10
+ | **Hexagonal (Ports & Adapters)** | Domain core surrounded by ports (interfaces) and adapters (tech) | Modifiability scenarios: swap DB/API/provider without touching business rules | Overkill for pure pipelines/scripts |
11
+ | **Clean Architecture** | Entities → Use Cases → Interface Adapters → Frameworks; Dependency Rule points inward, framework-independent domain | Long-lived products, testability scenarios (domain testable without infra), multiple delivery mechanisms | Ceremony on tiny services; don't create 4 layers for a webhook |
12
+ | **Modular Monolith** | One deployable, hard module boundaries (enforced imports), per-module data ownership | Team ≤ ~8, uniform availability target, fast iteration + future split option | Boundary erosion — enforce with lint/build rules |
13
+ | **Microservices** | Independently deployable services, own data, contract-based communication | Independent scaling of hot paths, >1 team per deployable cadence, divergent availability/regulatory isolation | Distributed monolith; needs observability + delivery maturity first |
14
+ | **Event-Driven** | Producers/consumers via broker; choreography or orchestration | Async workflows, spiky load absorption, audit trails, fan-out | Eventual consistency is an ADR; idempotency + DLQs mandatory |
15
+ | **Serverless** | Functions + managed services, scale-to-zero | Spiky/unpredictable load, cost scenarios favoring pay-per-use, small ops team | Cold starts vs latency measures; vendor coupling is an accepted ADR |
16
+ | **CQRS / Event Sourcing** | Split write/read models; state as event log | Read/write asymmetry proven by measures; audit/replay requirements | The most-regretted premature escalation; demand hard evidence |
17
+
18
+ Styles compose: a serverless system with a hexagonal core, or microservices where each service is internally clean, are normal outcomes. Name the composition in the TRD.
19
+
20
+ ## Robust-vs-Lite Decision Matrix (expanded)
21
+
22
+ Score each axis from the scenario set; the tier is decided per axis, not globally — a lite structure with robust data is valid.
23
+
24
+ | Axis | LITE default | Escalate to ROBUST when (scenario evidence) | ADR must state |
25
+ |---|---|---|---|
26
+ | Structure | Modular monolith (hexagonal/clean inside) | Hot path needs independent scaling; team topology exceeds one deploy cadence | Split boundaries + contract ownership |
27
+ | Compute | Serverless (Lambda) or one managed runtime (ECS/App Runner) | Sustained high utilization (serverless cost crossover), long-running/stateful work, cold starts break latency measures | Cost crossover math, latency data |
28
+ | Data | One primary DB + cache | Polyglot proven by access patterns; regulatory isolation; write/read asymmetry | Consistency model per store |
29
+ | Async | Direct calls; one queue for the genuinely async | Multi-step sagas, streaming volumes, cross-service choreography | Failure/compensation model |
30
+ | Delivery | One pipeline, trunk-based, IaC from day one | Many services × environments; progressive delivery needed by availability scenarios | Promotion + rollback strategy |
31
+ | AI | Single agent, managed API | Multi-agent only when task decomposition is proven (see `agentic-ai.md`) | Token cost order-of-magnitude |
32
+
33
+ Anti-rule: never escalate two axes "while we're at it." Each escalation cites its own scenario.
34
+
35
+ ## Reference Stack Mapping (AKILI default expertise: AWS + Node.js/TypeScript)
36
+
37
+ Use the project's declared stack and `## Skill Map` first. When the project is greenfield and the user's ecosystem applies, these are the calibrated defaults — deviations (Go for CPU-bound hot paths, Python for ML/data) go through an ADR:
38
+
39
+ | Concern | LITE | ROBUST |
40
+ |---|---|---|
41
+ | API/backend | Lambda + API Gateway (Node/TS), or NestJS on a single runtime | NestJS services on ECS/EKS; Go for measured hot paths; FastAPI for ML-adjacent services |
42
+ | Frontend | Next.js / Astro (content) on managed hosting | Next.js/Angular with edge rendering, feature-flagged progressive delivery |
43
+ | Relational data | Single MySQL (RDS) / managed Postgres | Aurora, read replicas, partitioning; Oracle when the org mandates it |
44
+ | NoSQL | DynamoDB single-table for known access patterns | DynamoDB + streams; MongoDB for document-flexible domains |
45
+ | Async | SQS (+ one DLQ) | EventBridge/SNS fan-out, Step Functions sagas, Kinesis streaming |
46
+ | AI/RAG | Bedrock (or OpenAI/Anthropic API) + S3 Vectors | Bedrock multi-model routing, OpenSearch vector store, dedicated inference |
47
+ | IaC | CDK/SAM, one stack per app | CDK multi-stack/multi-account, pipelines per service |
48
+
49
+ ## Clean/Hexagonal Layer Mapping for Node.js/TypeScript
50
+
51
+ The Dependency Rule: source dependencies point inward only; the domain imports nothing from outer layers; data crossing boundaries is plain structures.
52
+
53
+ ```
54
+ src/
55
+ domain/ # entities, value objects, domain services, ports (interfaces) — zero framework imports
56
+ application/ # use cases orchestrating domain; transaction boundaries; input/output DTOs
57
+ infrastructure/ # adapters: repositories (MySQL/Dynamo/Mongo), external APIs, message producers
58
+ interfaces/ # delivery: HTTP controllers/resolvers (NestJS/Fastify), CLI, queue consumers
59
+ ```
60
+
61
+ - NestJS: modules per bounded context; providers implement domain ports; controllers stay thin (map transport ↔ use case DTOs).
62
+ - Serverless: each handler is an `interfaces/` adapter invoking a use case — business logic never lives in the handler file.
63
+ - Test consequence (testability tactic): domain + application test with in-memory port fakes, no infra needed.
64
+
65
+ ## Style → Scenario Traceability Block (TRD requirement)
66
+
67
+ End the Architecture Overview with a compact table: `Scenario ID → Tactic → Style/axis decision it justified`. If a style decision has no scenario row, it is preference — delete it or find its scenario.
@@ -0,0 +1,70 @@
1
+ # Design Patterns — Selection, Principles, and the Tactic→Pattern Bridge
2
+
3
+ Patterns enter a design only at Decision Spine step 4: bound to a named problem, implementing a chosen tactic, with the simpler alternative stated. Catalog basis: the Refactoring.Guru catalog (Alexander Shvets) — 22 of the 23 GoF patterns (Interpreter omitted).
4
+
5
+ ## Design Principles (the review checklist above any pattern)
6
+
7
+ 1. **Encapsulate what varies** — isolate the changing part behind a boundary before reaching for a pattern name.
8
+ 2. **Program to an interface, not an implementation.**
9
+ 3. **Favor composition over inheritance.**
10
+ 4. **SOLID:** Single Responsibility · Open/Closed · Liskov Substitution · Interface Segregation · Dependency Inversion (the Dependency Rule of clean/hexagonal is DIP at architecture scale).
11
+
12
+ If a principle solves it, stop there — a pattern nobody needs is complexity (MUDA).
13
+
14
+ ## Selection Table — problem → pattern
15
+
16
+ ### Creational (object creation)
17
+ | You need to… | Pattern | Note |
18
+ |---|---|---|
19
+ | Decouple client from concrete classes it instantiates | **Factory Method** | First stop; evolves into the ones below |
20
+ | Create families of related objects consistently | **Abstract Factory** | Often composed of factory methods |
21
+ | Build complex objects step-by-step (many optional params) | **Builder** | Kills telescoping constructors |
22
+ | Clone configured objects instead of rebuilding | **Prototype** | |
23
+ | Exactly one instance, controlled access | **Singleton** | In DI ecosystems (NestJS), prefer container-scoped providers |
24
+
25
+ ### Structural (composition)
26
+ | You need to… | Pattern | Note |
27
+ |---|---|---|
28
+ | Make an incompatible interface fit (legacy, 3rd-party SDK) | **Adapter** | The workhorse of hexagonal `infrastructure/` |
29
+ | Vary abstraction and implementation independently (2 dimensions) | **Bridge** | Prevents class explosion (e.g. notification kind × channel) |
30
+ | Part-whole trees treated uniformly | **Composite** | |
31
+ | Add responsibilities dynamically without subclassing | **Decorator** | Middleware/interceptors are this |
32
+ | One simple door to a complex subsystem | **Facade** | Use-case classes often act as facades |
33
+ | Share heavy immutable state across many instances | **Flyweight** | Rare in business apps |
34
+ | Control access: lazy, cache, guard, remote | **Proxy** | Repositories with caching layers |
35
+
36
+ ### Behavioral (interaction & responsibility)
37
+ | You need to… | Pattern | Note |
38
+ |---|---|---|
39
+ | Pass a request through potential handlers | **Chain of Responsibility** | Validation/auth pipelines |
40
+ | Requests as objects (queue, log, undo, retry) | **Command** | Natural fit for queue-driven work |
41
+ | Traverse a collection without exposing structure | **Iterator** | Built into JS/TS; rarely hand-rolled |
42
+ | Centralize chatty peer-to-peer communication | **Mediator** | Orchestrators, event buses in-process |
43
+ | Snapshot/restore state without breaking encapsulation | **Memento** | |
44
+ | Notify dependents on state change (pub/sub) | **Observer** | In-process events; at system scale → event-driven style |
45
+ | Behavior changes with internal state (kill state conditionals) | **State** | Order/workflow lifecycles |
46
+ | Interchangeable algorithms behind one interface | **Strategy** | Pricing rules, retry policies, LLM model routing |
47
+ | Algorithm skeleton with overridable steps | **Template Method** | Prefer Strategy (composition) when possible |
48
+ | Add operations across a class hierarchy without touching it | **Visitor** | Last resort; heavy coupling to hierarchy |
49
+
50
+ ## Tactic → Pattern Bridge (connects step 2 to step 4)
51
+
52
+ | Tactic (from `nfr-scenarios.md`) | Patterns that implement it |
53
+ |---|---|
54
+ | Prevent ripple / intermediary | Facade, Bridge, Mediator, Proxy, Adapter |
55
+ | Defer binding | Strategy, Abstract Factory, Dependency Injection (DIP), plugin registration |
56
+ | Encapsulation / swap providers | Adapter + port interfaces (hexagonal), Bridge |
57
+ | Retry / failover / degradation | Command (retryable units), Proxy (circuit breaker), Chain of Responsibility (fallbacks) |
58
+ | Caching / multiple copies | Proxy (cache-aside), Flyweight |
59
+ | Rate limiting / arbitration | Decorator or Proxy on the entry port; Command queues |
60
+ | Audit / undo / replay | Command + Memento; at system scale → event sourcing (ADR!) |
61
+ | Workflow state control | State, Template Method → Strategy |
62
+ | Test doubles / seams | All port-based patterns (Adapter, Strategy) via DIP |
63
+
64
+ ## Justification Format (what lands in the document)
65
+
66
+ For each pattern decision, one compact line in Design Decisions:
67
+
68
+ `[Problem] → [Pattern] implementing [Tactic] for [Scenario ID] — simpler alternative rejected: [X, reason]`
69
+
70
+ Evolution guidance: start with the simplest member of a family (Factory Method before Abstract Factory; Strategy before a full plugin system) and record the trigger that would justify upgrading. Patterns are design-level reuse — cheaper than framework lock-in, more durable than copied code.
@@ -0,0 +1,75 @@
1
+ # NFR Scenarios & Tactics
2
+
3
+ Non-functional requirements are captured as **quality-attribute scenarios** (SEI six-part format) and satisfied by **tactics** — named design decisions that control the system's response to a stimulus. This file is the scenario template plus the tactics menu per attribute.
4
+
5
+ ## The Six-Part Scenario (the only valid NFR format)
6
+
7
+ | Part | Meaning | Example (performance) |
8
+ |---|---|---|
9
+ | **Source** | Who/what generates the stimulus | 500 concurrent end users |
10
+ | **Stimulus** | The condition arriving at the system | submit checkout requests |
11
+ | **Environment** | System state when it arrives | normal operation, peak season |
12
+ | **Artifact** | Component(s) affected | order API + payment integration |
13
+ | **Response** | What the system does | process and confirm the order |
14
+ | **Response measure** | The testable threshold | p95 latency ≤ 800 ms, error rate < 0.1% |
15
+
16
+ Rules:
17
+
18
+ - Write scenarios one-per-line in compact form: `[Source] → [Stimulus] on [Artifact] during [Environment] ⇒ [Response] measured by [Measure]`.
19
+ - Every scenario must be **architecturally significant** (shapes structure, not just code) and **testable** (the measure feeds `/akili-test`).
20
+ - Derive stimuli from PRD goals and real usage claims only. If the PRD lacks the number, ask or state the assumption explicitly.
21
+ - 3–7 scenarios per attribute that matters; zero for attributes marked "not architecturally significant here" (that marking is itself required output).
22
+
23
+ Example measures by attribute (calibrate to the project, don't copy blindly): availability — monthly downtime budget, RTO/RPO; performance — p95/p99 latency, throughput at N concurrent users; security — time to detect/revoke, blast radius of a leaked credential; modifiability — "add a payment provider touching ≤ 2 modules"; scalability — 10× load with linear cost, no redesign; cost — monthly ceiling per environment; observability — MTTD < X min for a failing dependency.
24
+
25
+ ## Tactics Menu per Attribute
26
+
27
+ A tactic is chosen to satisfy a scenario, then implemented by styles/patterns (see `architecture-styles.md`, `design-patterns.md`). Cite the tactic by name in the TRD next to its scenario.
28
+
29
+ ### Availability
30
+ - **Detect faults:** health checks/heartbeat, exception handling, timeouts.
31
+ - **Recover:** retry with backoff, failover/replicas, checkpoints + transaction log, graceful degradation, circuit breaker.
32
+ - **Prevent:** transactions (atomic rollback), bulkheads/isolation, removal from service for maintenance.
33
+
34
+ ### Performance
35
+ - **Control resource demand:** increase computational efficiency, reduce overhead, manage event rate, bound queue sizes, bound execution times.
36
+ - **Manage resources:** introduce concurrency, maintain multiple copies (caching, read replicas, CDN), increase available resources (scale up/out).
37
+ - **Arbitrate resources:** scheduling/priority policies, rate limiting, backpressure.
38
+
39
+ ### Security
40
+ Properties: confidentiality, integrity, non-repudiation, availability, auditability.
41
+ - **Resist:** authentication (tokens, certs, MFA), authorization (per-role/least privilege), encrypt in transit + at rest, validate inputs, limit exposure (private networking, minimal surface).
42
+ - **Detect:** intrusion/anomaly detection, request filtering, audit logging.
43
+ - **Recover:** state restoration, credential rotation/revocation, traceable audit trail for attack identification.
44
+
45
+ ### Modifiability
46
+ - **Localize changes:** semantic coherence (high cohesion / low coupling), anticipate expected changes, generalize modules.
47
+ - **Prevent ripple:** encapsulation, intermediaries (facade, bridge, mediator, strategy, proxy, factory, repository), stable interfaces.
48
+ - **Defer binding:** configuration files, feature flags, runtime registration/plugins, polymorphism, dependency injection.
49
+
50
+ ### Testability
51
+ - Interface/implementation separation, dependency injection for substitutable test doubles, specialized test interfaces, internal state monitoring, deterministic seams (clock/random injected).
52
+
53
+ ### Usability (architectural slice only)
54
+ - Runtime: feedback, cancel/undo support. Design-time: separate UI from application logic (the same tactic as modifiability's semantic coherence — MVC and descendants).
55
+
56
+ ### Scalability (cloud-era extension)
57
+ - Statelessness (externalize session/state), horizontal scaling + load balancing, partitioning/sharding, async decoupling via queues, autoscaling policies, cache hierarchies, read/write splitting.
58
+
59
+ ### Observability (cloud-era extension)
60
+ - Structured logging with correlation IDs, RED/USE metrics, distributed tracing, health/readiness endpoints, alerting on symptoms (SLOs) not causes, dashboards per audience.
61
+
62
+ ### Cost / FinOps (cloud-era extension)
63
+ - Serverless/scale-to-zero for spiky loads, right-sizing + reserved capacity for steady loads, tiered storage lifecycle, cache to cut egress/compute, model routing (small model first) for LLM workloads, budget alarms as deploy artifacts.
64
+
65
+ ## Trade-off Table (always disclose)
66
+
67
+ Tactics conflict; the TRD must say which side won and why (this feeds `judgment-day`):
68
+
69
+ | Tension | Typical resolution note |
70
+ |---|---|
71
+ | Performance ↔ Modifiability | Layers/indirection add hops; keep them until a scenario measure fails, then flatten the measured path only |
72
+ | Security ↔ Performance/Usability | Encrypt and authenticate by default; budget the latency in the performance measures |
73
+ | Availability ↔ Cost | Replicas and multi-AZ cost money; the availability scenario's downtime budget justifies (or caps) the spend |
74
+ | Scalability ↔ Consistency | Prefer strong consistency until a scenario demands otherwise; eventual consistency is an ADR, never an accident |
75
+ | Cost ↔ everything | Every ROBUST escalation names its monthly cost order-of-magnitude |
@@ -0,0 +1,65 @@
1
+ # Views & Documentation — C4, View Selection, ADRs, Interfaces
2
+
3
+ Documenting an architecture = documenting the relevant **views**, then adding what applies across views (rationale, mapping, roadmap). Views are chosen by stakeholder need, never by habit. Basis: C4 (Simon Brown) as notation + SEI Views & Beyond as method.
4
+
5
+ ## C4 — the default notation
6
+
7
+ | Level | Diagram | Shows | Use |
8
+ |---|---|---|---|
9
+ | 1 | **System Context** | The system as one box + users/personas + neighboring systems. People and systems, not tech | Always — first diagram of every TRD |
10
+ | 2 | **Container** | Separately deployable/runnable units (web app, API, DB, queue, function) + tech choices + comm links | Always |
11
+ | 3 | **Component** | Major building blocks inside ONE container + responsibilities | Only for complex containers |
12
+ | 4 | Code (UML class) | Classes inside a component | Almost never; generate on demand |
13
+
14
+ Rules: every element carries name + type tag + one-line description (`[Container: NestJS/Node]`); every relationship is a labeled directed arrow; **every diagram has a legend** — shared abstractions matter more than notation. Supplementary diagrams reuse the same elements: a **deployment view** (containers → AWS infrastructure) and, when async flows exist, a **runtime/sequence view** for the 1–3 most critical scenarios. Mermaid is the default renderer in AKILI docs.
15
+
16
+ ## Which views, for whom (selection method)
17
+
18
+ 1. List stakeholders; keep candidate views having at least one vested stakeholder; 2. combine/drop overview-only views; 3. prioritize — 80% done breadth-first beats one perfect view; **never defer rationale**.
19
+
20
+ | Stakeholder | Needs (detail) |
21
+ |---|---|
22
+ | Developers / AKILI Implementer | Module structure + layer rules (d), their container's components (d), interfaces (d) |
23
+ | Tech lead / future architect | Everything + candid rationale (d) |
24
+ | Ops / infra | Deployment view (d), container view (s) |
25
+ | Testers / AKILI Tester | C&C behavior + interfaces + scenario measures (d) |
26
+ | PM / customer | Context (o), container (o), cost/tier decision (o) |
27
+
28
+ Quality-attribute → view mapping: performance → runtime + deployment views; security → deployment + data-flow + trust boundaries; modifiability → module/dependency view; availability → deployment + failover behavior. If a scenario matters, some view must let a reader analyze it.
29
+
30
+ ## View documentation template (per view, compact)
31
+
32
+ 1. **Primary presentation** (the diagram, with legend)
33
+ 2. **Element catalog** — one line per element: responsibility + key properties
34
+ 3. **Context** — what's in/out of scope for this view
35
+ 4. **Variability** — variation points and binding times (config, flags, plugins)
36
+ 5. **Rationale** — why this shape; link scenario/ADR IDs
37
+
38
+ Mark unused sections "n/a" — never silently omit. Avoid repetition: define an element once, cross-reference elsewhere.
39
+
40
+ ## ADR — Architecture Decision Record (compact 8-field AKILI profile)
41
+
42
+ Full SEI template has 12 fields; AKILI uses 8 (drop bureaucracy, keep traceability):
43
+
44
+ ```markdown
45
+ ### ADR-NNN: <decision title>
46
+ - **Status:** proposed | accepted | superseded by ADR-MMM
47
+ - **Issue:** the forcing problem (link Scenario IDs)
48
+ - **Decision:** what was chosen
49
+ - **Alternatives:** options seriously considered
50
+ - **Argument:** why this one — cost, TCO, time-to-market, measures
51
+ - **Implications:** new constraints, renegotiated scope, revisit triggers
52
+ - **Related:** ADRs / requirements / affected artifacts
53
+ ```
54
+
55
+ Document a decision when it is hard to undo, took real evaluation effort, is confusing without context, or is unusual enough to be "fixed" by mistake. ROI test: capture now if that's cheaper than rediscovery later. For contested choices, a trade-study table (rows = concerns/scenarios, columns = alternatives, cells = ✓/✗/?) replaces prose.
56
+
57
+ Keep an ADR index table at the top of Architecture Overview & Decisions: `ID | Title | Status | Scenarios`.
58
+
59
+ ## Interface / contract documentation (per exposed interface)
60
+
61
+ 1. Identity & version · 2. Resources/operations (syntax, semantics, errors) · 3. Data types · 4. Error model (shared) · 5. Variability · 6. Quality characteristics (SLO/SLA: latency, rate limits) · 7. Rationale · 8. Usage examples. In practice: OpenAPI/GraphQL schema covers 1–4; the TRD adds 5–8 — especially 6, where interface SLOs inherit from scenario measures.
62
+
63
+ ## Seven rules for sound documentation (package checklist)
64
+
65
+ 1. Write for the reader · 2. Avoid repetition · 3. Explain every notation (legends) · 4. Standard organization (templates above; mark gaps "TBD") · 5. Record rationale while fresh, including rejected options · 6. Version and release docs; avoid perpetual-draft drift · 7. Review with the real stakeholders (in AKILI: `judgment-day` is the structured review).
package/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@ The format is inspired by Keep a Changelog and the repository follows semantic v
10
10
 
11
11
  - No unreleased changes yet.
12
12
 
13
+ ## [2.10.1] - 2026-07-23
14
+
15
+ ### Changed
16
+
17
+ - **Installer auto-detects installed targets (`bin/akili.js`):** when `--tool` is omitted, `install`, `update`, and `doctor` now scan disk for already-installed targets (`~/.claude`, `~/.config/opencode`, `~/.gemini`) and act on **all** of them instead of silently defaulting to `claude`. A bare `akili update` therefore refreshes every installed tool — fixing the case where new commands (e.g. `akili-quick`, `akili-resume`) landed in Claude Code but never reached OpenCode. An explicit `--tool <name>` still wins; a first-time run with nothing installed still defaults to `claude`. Auto-detected runs print which targets were found, and the update/verify summaries report the resolved tool set and a matching `akili doctor --tool …` hint.
18
+ ## [2.10.0] - 2026-07-22
19
+
20
+ ### Added
21
+
22
+ - **New `caveman` skill** (by Julius Brussee, MIT — github.com/juliusbrussee/caveman; adapted for AKILI-SPECS): token-economy communication style (~65% output-token reduction in upstream benchmarks) scoped by an AKILI **Scope Contract** to *transient agent output only* — inter-agent messages in the `/akili-execute` triad and `/akili-test` Leader↔Tester communication at `full`, user-visible progress narration at `lite`. Explicitly OFF for persistent artifacts (PRD/TRD/specs/`execution.md`/`test-report.md`/PRs/Kaizen log — `cognitive-doc-design` territory), HITL approval gates, Pivot/`PRODUCT_BUG` escalations, and verbatim evidence (Reviewer FAIL reports, error strings, test output — the Structured Feedback rule wins). Boundary rule recorded in both skills: *"cognitive-doc-design owns artifacts; caveman owns transient agent output."* Wired into `/akili-execute` (Multi-Agent Triad) and `/akili-test` (Token discipline).
23
+
24
+ - **New `software-architect` skill** (by Juan Carlos Cadavid — jcadavid.com, MIT; original AKILI authorship): senior-software-architect skill built around the **Decision Spine** — Scenario → Tactic → Tier & Style → Pattern → View & Record. Captures non-functional requirements as six-part, measurable quality-attribute scenarios (SEI format) with a mandatory security/performance/scalability/availability sweep; sizes the architecture through a **robust-vs-lite gate** (evidence-based escalation recorded as ADRs, infrastructure derives from the tier); selects architecture styles (hexagonal, clean, modular monolith, microservices, event-driven, serverless) and GoF design patterns only when bound to named problems; documents with C4 views (legend required) and compact 8-field ADRs. Progressive disclosure via `references/` (nfr-scenarios, architecture-styles, design-patterns, views-documentation, agentic-ai — the latter covering single/multi-agent patterns, RAG/vector decisions, and LLM-specific NFRs). Wired into the methodology: `/akili-constitution` Step 5 (required skill for the TRD; the TRD structure gains `Architecture Overview & Decisions` and `Quality Attribute Scenarios (Non-Functional Requirements)` sections) and Step 6 (infrastructure cites the tier decision), and `/akili-specify` Phase 2 for architecturally significant features. Inspired by SEI (Bass/Clements/Kazman; Views & Beyond), the C4 model (Simon Brown), Refactoring.Guru (Alexander Shvets), Clean/Hexagonal architecture, and Google Cloud agentic AI guides.
13
25
  ## [2.9.0] - 2026-07-20
14
26
 
15
27
  ### Added
package/bin/akili.js CHANGED
@@ -96,7 +96,9 @@ Commands:
96
96
  help Show this help
97
97
 
98
98
  Options:
99
- --tool <name> Install target: claude, opencode, antigravity, both, or all. Default: claude
99
+ --tool <name> Install target: claude, opencode, antigravity, both, or all.
100
+ When omitted, install/update/doctor auto-detect already-installed
101
+ targets; if none are found they default to claude.
100
102
  --target <path> Target config directory for selected single tool
101
103
  --claude-target Claude config directory. Default: ~/.claude
102
104
  --opencode-target OpenCode config directory. Default: ~/.config/opencode
@@ -178,9 +180,17 @@ function getArgs() {
178
180
  const baseOpencode = values.local ? path.join(process.cwd(), ".config", "opencode") : defaultPaths.opencode;
179
181
  const baseAntigravity = values.local ? path.join(process.cwd(), ".gemini") : defaultPaths.antigravity;
180
182
 
183
+ // Whether the user explicitly passed --tool. When they did not, install/
184
+ // update/doctor auto-detect already-installed targets instead of assuming
185
+ // the "claude" default (see resolveTools).
186
+ const toolExplicit =
187
+ process.argv.includes("--tool") ||
188
+ process.argv.some((a) => a.startsWith("--tool="));
189
+
181
190
  const args = {
182
191
  command,
183
192
  tool: values.tool,
193
+ toolExplicit,
184
194
  force: values.force,
185
195
  dryRun: values["dry-run"],
186
196
  commandsOnly: values["commands-only"],
@@ -230,6 +240,57 @@ function selectedTools(args) {
230
240
  return [args.tool];
231
241
  }
232
242
 
243
+ const ALL_TOOLS = ["claude", "opencode", "antigravity"];
244
+
245
+ // A tool counts as installed when any of its target directories exists and is
246
+ // non-empty. Checking commands / skills / resources covers --commands-only and
247
+ // --skills-only installs too, not just full ones.
248
+ function isToolInstalled(tool, args) {
249
+ const { paths } = getToolRegistryInfo(tool, args);
250
+ const dirs = [...paths.commands, paths.skills, paths.resources];
251
+ return dirs.some((dir) => {
252
+ try {
253
+ return fs.existsSync(dir) && fs.readdirSync(dir).length > 0;
254
+ } catch {
255
+ return false;
256
+ }
257
+ });
258
+ }
259
+
260
+ function detectInstalledTools(args) {
261
+ return ALL_TOOLS.filter((tool) => isToolInstalled(tool, args));
262
+ }
263
+
264
+ // Resolve which tools an install/update/doctor run should act on. An explicit
265
+ // --tool always wins. Otherwise we auto-detect targets already on disk so a bare
266
+ // `akili update` refreshes every installed tool (e.g. claude AND opencode)
267
+ // instead of silently defaulting to claude only. A first-time run with nothing
268
+ // installed falls back to the default (claude). The resolved list and any
269
+ // auto-detection note are stashed on args for the summary output.
270
+ function resolveTools(args) {
271
+ if (args.toolExplicit) {
272
+ args.resolvedTools = selectedTools(args);
273
+ return args.resolvedTools;
274
+ }
275
+ const detected = detectInstalledTools(args);
276
+ const isJustDefault = detected.length === 1 && detected[0] === args.tool;
277
+ if (detected.length > 0 && !isJustDefault) {
278
+ args.autoDetected = detected;
279
+ args.resolvedTools = detected;
280
+ return detected;
281
+ }
282
+ args.resolvedTools = selectedTools(args);
283
+ return args.resolvedTools;
284
+ }
285
+
286
+ // Map a resolved tool list back to a --tool flag value for verify hints.
287
+ function toolFlagFor(tools) {
288
+ if (tools.length === 1) return tools[0];
289
+ const set = new Set(tools);
290
+ if (set.size === 2 && set.has("claude") && set.has("opencode")) return "both";
291
+ return "all";
292
+ }
293
+
233
294
  function shouldInclude(type, args) {
234
295
  if (args.commandsOnly) return type === "commands";
235
296
  if (args.skillsOnly) return type === "skills";
@@ -580,8 +641,9 @@ function runUpdate(args) {
580
641
  } else {
581
642
  console.log(` Package: updated from v${versionBefore} (${installType} install; new version could not be read)`);
582
643
  }
583
- console.log(` Files: reinstalled with --force for ${selectedTools(args).join(", ")} (see Install Summary above)`);
584
- console.log(` Verify: ${colors.cyan}akili doctor --tool ${args.tool}${colors.reset}`);
644
+ const updatedTools = args.resolvedTools || selectedTools(args);
645
+ console.log(` Files: reinstalled with --force for ${updatedTools.join(", ")}${args.autoDetected ? " (auto-detected)" : ""} (see Install Summary above)`);
646
+ console.log(` Verify: ${colors.cyan}akili doctor --tool ${toolFlagFor(updatedTools)}${colors.reset}`);
585
647
  }
586
648
 
587
649
  function summaryCounts(result) {
@@ -589,7 +651,15 @@ function summaryCounts(result) {
589
651
  }
590
652
 
591
653
  function runInstall(args) {
592
- const tools = selectedTools(args);
654
+ const tools = resolveTools(args);
655
+ if (args.autoDetected) {
656
+ console.log(
657
+ `\n${colors.cyan}Auto-detected installed target(s): ${args.autoDetected.join(", ")}${colors.reset}`
658
+ );
659
+ console.log(
660
+ ` Refreshing all detected targets. Pass ${colors.yellow}--tool <name>${colors.reset} to override.`
661
+ );
662
+ }
593
663
  const results = [];
594
664
 
595
665
  for (const tool of tools) {
@@ -626,7 +696,7 @@ function runInstall(args) {
626
696
  if (args.dryRun) {
627
697
  console.log(` - Re-run without ${colors.yellow}--dry-run${colors.reset} to apply the changes above.`);
628
698
  } else {
629
- console.log(` - Verify the installation with ${colors.cyan}akili doctor --tool ${args.tool}${colors.reset}.`);
699
+ console.log(` - Verify the installation with ${colors.cyan}akili doctor --tool ${toolFlagFor(tools)}${colors.reset}.`);
630
700
  }
631
701
  }
632
702
 
@@ -755,7 +825,16 @@ function doctorTool(tool, args) {
755
825
  function runDoctor(args) {
756
826
  const results = [];
757
827
 
758
- for (const tool of selectedTools(args)) {
828
+ const tools = resolveTools(args);
829
+ if (args.autoDetected) {
830
+ console.log(
831
+ `\n${colors.cyan}Auto-detected installed target(s): ${args.autoDetected.join(", ")}${colors.reset}`
832
+ );
833
+ console.log(
834
+ ` Checking all detected targets. Pass ${colors.yellow}--tool <name>${colors.reset} to override.`
835
+ );
836
+ }
837
+ for (const tool of tools) {
759
838
  results.push({ tool, ...doctorTool(tool, args) });
760
839
  }
761
840
 
@@ -875,6 +954,7 @@ async function runInteractiveInit() {
875
954
  const args = {
876
955
  command: "install",
877
956
  tool: tool,
957
+ toolExplicit: true,
878
958
  force: false,
879
959
  dryRun: false,
880
960
  commandsOnly: false,
@@ -20,6 +20,7 @@ The skill set is **curated, not accumulated**: every skill declares its original
20
20
  | [`api-design-principles`](api-design-principles.md) | stack | Seth Hobson (MIT) | REST and GraphQL API design and review | Skill Map; constitution/specify stack lists |
21
21
  | [`aws-serverless`](aws-serverless.md) | stack | vibeship (Apache-2.0) | Lambda, API Gateway, DynamoDB, SQS/SNS, SAM/CDK | Skill Map; constitution/specify stack lists |
22
22
  | [`brainstorming`](brainstorming.md) | core | Jesse Vincent — obra (MIT) | Clarifying ideas, scope, options, and trade-offs before implementation | `/akili-constitution` Step 0, `/akili-propose`, `/akili-specify` phases 1–3 |
23
+ | [`caveman`](caveman.md) | core | Julius Brussee (MIT) | Token-economy compression of transient agent output (inter-agent messages `full`, progress lines `lite`) — never documents, HITL gates, or verbatim evidence | `/akili-execute` triad communication; `/akili-test` Leader↔Tester communication |
23
24
  | [`cognitive-doc-design`](cognitive-doc-design.md) | core | gentleman-programming (Apache-2.0) | Human-facing docs that reduce cognitive load (lead with the answer, progressive disclosure, tables over prose) | `/akili-constitution`, `/akili-specify`, `/akili-execute` (PR docs), `/akili-archive` |
24
25
  | [`error-handling-patterns`](error-handling-patterns.md) | stack | Seth Hobson (MIT) | Exceptions, Result patterns, graceful degradation, reliability | Skill Map; constitution/specify stack lists |
25
26
  | [`frontend-design`](frontend-design.md) | conditional | Anthropic (Apache-2.0) | Distinctive frontend UI and UX implementation (fallback when `ui-ux-pro-max` is unavailable) | UI steps of `/akili-constitution`, `/akili-specify`, `/akili-test`, `/akili-validate`, `/akili-seo` |
@@ -31,6 +32,7 @@ The skill set is **curated, not accumulated**: every skill declares its original
31
32
  | [`react-doctor`](react-doctor.md) | stack | Million.dev | React diagnostics after changes | Skill Map; `/akili-test`, `/akili-validate`, `/akili-execute` React work |
32
33
  | [`seo-audit`](seo-audit.md) | core | Corey Haines (MIT) | Technical, on-page, and international SEO audits with a standard finding format | `/akili-seo` audit phase (required) |
33
34
  | [`shadcn-ui`](shadcn-ui.md) | stack | community (origin unverified) | shadcn/ui components, forms, themes, Tailwind integration | Skill Map; constitution/specify stack lists; persona examples |
35
+ | [`software-architect`](software-architect.md) | core | Juan Carlos Cadavid — jcadavid.com (MIT) | Senior-architect Decision Spine: NFRs as measurable quality-attribute scenarios, tactics, robust-vs-lite tier sizing, architecture styles (hexagonal/clean/microservices), GoF pattern selection, C4 views + ADRs, agentic AI patterns | `/akili-constitution` Step 5 (required) and Step 6 tier handoff; `/akili-specify` Phase 2 for architecturally significant features |
34
36
  | [`stitch-design`](stitch-design.md) | conditional | Google — google-labs-code | Stitch prompt enhancement and design generation workflows (fallback UI chain with `frontend-design`) | UI steps of `/akili-constitution`, `/akili-propose`, `/akili-specify` |
35
37
  | [`systematic-debugging`](systematic-debugging.md) | core | Jesse Vincent — obra (MIT) | Root-cause investigation for bugs, test failures, unexpected behavior | `/akili-propose` Bug Track, `/akili-specify` Bug Mode, `/akili-test`, `/akili-validate`, `/akili-seo` |
36
38
  | [`tailwind-design-system`](tailwind-design-system.md) | stack | Seth Hobson (MIT) | Tailwind CSS v4 tokens, component systems, responsive patterns | Skill Map; constitution/specify stack lists |
@@ -0,0 +1,38 @@
1
+ # `caveman`
2
+
3
+ **Author:** Julius Brussee — [github.com/juliusbrussee/caveman](https://github.com/juliusbrussee/caveman) (MIT)
4
+ **Adapted for AKILI-SPECS by:** Juan Carlos Cadavid — [jcadavid.com](https://jcadavid.com)
5
+
6
+ ## Purpose
7
+
8
+ Ultra-compressed communication style (~65% fewer output tokens in upstream benchmarks): drop filler, keep substance, fragments OK, code and errors byte-for-byte exact. In AKILI it is the preventive tactic against output-token **MUDA** — scoped strictly to *transient* agent output, the chatter nobody rereads.
9
+
10
+ ## The Scope Contract (the AKILI adaptation)
11
+
12
+ > `cognitive-doc-design` owns artifacts; `caveman` owns transient agent output.
13
+
14
+ | Output | Caveman |
15
+ |---|---|
16
+ | Inter-agent messages (Leader ↔ Implementer/Reviewer/Tester) | `full` |
17
+ | User-visible progress narration mid-run | `lite` |
18
+ | Persistent artifacts (PRD, TRD, specs, `execution.md`, `test-report.md`, PRs, Kaizen log) | off |
19
+ | HITL approval gates, Pivot blockers, `PRODUCT_BUG` escalations | off |
20
+ | Verbatim evidence: error strings, Reviewer FAIL reports, test output, code | never touched |
21
+
22
+ Upstream Auto-Clarity is preserved and extended: security warnings, irreversible-action confirmations, and every HITL pause drop compression automatically. When in doubt whether output is transient or persistent, treat it as persistent (off).
23
+
24
+ ## Use When
25
+
26
+ - `/akili-execute` — automatic: inter-agent briefs/reports/feedback relays at `full`, progress lines at `lite`; the Structured Feedback rule wins (Reviewer reports pass unchanged).
27
+ - `/akili-test` — automatic: Leader→Tester slices and Tester structured reports at `full`.
28
+ - The user asks for token efficiency ("less tokens", "be brief", "caveman mode") in any context — respecting the Scope Contract.
29
+
30
+ ## Best Paired Commands
31
+
32
+ - `/akili-execute`, `/akili-test` — where the multi-agent fan-out burns most output tokens.
33
+ - `kaizen` — compressed inter-agent chatter is measurable MUDA reduction; retrospectives may cite the savings.
34
+
35
+ ## Source
36
+
37
+ - `../../.claude/skills/caveman/SKILL.md`
38
+ - Upstream: https://github.com/juliusbrussee/caveman
@@ -18,7 +18,7 @@ Every skill declares `metadata.binding` in its `SKILL.md` frontmatter. The bindi
18
18
 
19
19
  | Binding | Skills |
20
20
  |---|---|
21
- | `core` | `kaizen` (archive), `judgment-day` (specify), `cognitive-doc-design` (all human-facing docs), `brainstorming` (constitution, propose), `product-manager-toolkit` (constitution), `systematic-debugging` (bug flows), `seo-audit` (seo) |
21
+ | `core` | `kaizen` (archive), `judgment-day` (specify), `cognitive-doc-design` (all human-facing docs), `brainstorming` (constitution, propose), `product-manager-toolkit` (constitution), `software-architect` (constitution TRD/infra, specify design), `caveman` (execute/test transient inter-agent output), `systematic-debugging` (bug flows), `seo-audit` (seo) |
22
22
  | `conditional` | `ui-ux-pro-max`, `frontend-design`, `stitch-design` (UI work), `gsap-animation` (animation work) |
23
23
  | `stack` | `angular-developer`, `nestjs-expert`, `shadcn-ui`, `tailwind-design-system`, `react-doctor`, `vercel-react-best-practices`, `aws-serverless`, `api-design-principles`, `error-handling-patterns` |
24
24
 
@@ -49,6 +49,8 @@ metadata:
49
49
 
50
50
  Attribution is non-negotiable: MIT and Apache-2.0 licenses require preserving the original copyright and license notices. `adapted-by` records curation and AKILI adaptation — it never replaces the original `author`.
51
51
 
52
+ **Original-authorship variant:** skills authored originally for AKILI-SPECS (e.g. `kaizen`, `software-architect`) carry `author: Juan Carlos Cadavid — jcadavid.com` and may declare `inspired-by:` (a list of the works the method synthesizes) instead of `source`/`adapted-by`/`adapted-for` — there is no upstream to adapt from, but intellectual influences are still credited.
53
+
52
54
  ## Adaptation Levels
53
55
 
54
56
  | Level | Who gets it | What it is |
@@ -0,0 +1,32 @@
1
+ # `software-architect`
2
+
3
+ **Author:** Juan Carlos Cadavid — [jcadavid.com](https://jcadavid.com)
4
+
5
+ ## Purpose
6
+
7
+ Makes the agent operate as a **senior software architect** during TRD and design work. Its differentiator is the **Decision Spine** — Scenario → Tactic → Tier & Style → Pattern → View & Record: non-functional requirements are captured as six-part, measurable quality-attribute scenarios (SEI format); tactics answer each scenario; a **robust-vs-lite gate** sizes the architecture (and therefore the infrastructure) with evidence; design patterns enter only bound to named problems; everything lands as C4 views and compact ADRs. Inspired by SEI's *Software Architecture in Practice* and *Documenting Software Architectures*, the C4 model (Simon Brown), the Refactoring.Guru pattern catalog, Clean/Hexagonal architecture, and Google Cloud's agentic AI guides.
8
+
9
+ ## Use When
10
+
11
+ - `/akili-constitution` reaches **Step 5 (TRD)** — automatic, required; Step 6 (Infrastructure) derives its shape from the tier decision.
12
+ - `/akili-specify` Phase 2 designs an architecturally significant feature (new module/service, integration, data-flow, or NFR impact).
13
+ - The user asks for architecture review, NFR identification, stack sizing, or design-pattern guidance.
14
+
15
+ ## Core Rules
16
+
17
+ - **No NFR without a measure** — every scenario ends in a testable response measure; "fast/secure/scalable" without numbers is banned output.
18
+ - **Minimum NFR sweep** — security, performance, scalability, availability always evaluated explicitly; "not architecturally significant" is valid, silence is not.
19
+ - **Start lite, escalate with evidence** — robust choices (microservices, polyglot data, multi-agent AI) require a scenario whose measure the lite option cannot meet, recorded as an ADR.
20
+ - **No pattern without a named problem** — each pattern cites the tactic it implements and the simpler alternative it beat.
21
+ - **Every diagram has a legend**; C4 Context + Container are the default view set.
22
+ - **Token frugality** — progressive disclosure via `references/` (NFR scenarios & tactics, architecture styles, design patterns, views & ADRs, agentic AI); conceptual designs only, no implementation code in documents.
23
+
24
+ ## Best Paired Commands
25
+
26
+ - `/akili-constitution` — runs the full spine in Step 5; hands the tier decision to Step 6.
27
+ - `/akili-specify` — feature-scale spine in Phase 2 `design.md`; its scenario→tactic→pattern traceability is what `judgment-day` audits.
28
+ - `/akili-test` — scenario response measures become non-functional test candidates.
29
+
30
+ ## Source
31
+
32
+ - `../../.claude/skills/software-architect/SKILL.md`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "akili-specs",
3
- "version": "2.9.0",
3
+ "version": "2.10.1",
4
4
  "description": "Portable AKILI-SPECS methodology commands and skills for AI-assisted development.",
5
5
  "homepage": "https://github.com/JuankCadavid/akili-specs#readme",
6
6
  "repository": {