arreio 1.0.0-dev.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.
Files changed (81) hide show
  1. package/README.md +81 -0
  2. package/package.json +42 -0
  3. package/scripts/postinstall.js +50 -0
  4. package/skills/arreio-init/SKILL.md +214 -0
  5. package/skills/arreio-init/references/architecture-template.md +85 -0
  6. package/skills/arreio-init/references/learn-index-template.md +15 -0
  7. package/skills/arreio-init/references/plan-index-template.md +29 -0
  8. package/skills/arreio-init/references/tasks-index-template.md +15 -0
  9. package/skills/learn/SKILL.md +151 -0
  10. package/skills/learn/modules/capture.md +108 -0
  11. package/skills/learn/modules/index.md +94 -0
  12. package/skills/learn/modules/maintain.md +116 -0
  13. package/skills/learn/modules/refine.md +104 -0
  14. package/skills/learn/references/dedup-rules.md +129 -0
  15. package/skills/learn/references/entry-schema.md +152 -0
  16. package/skills/learn/references/error-handling.md +178 -0
  17. package/skills/learn/references/id-generation.md +114 -0
  18. package/skills/learn/references/index-format.md +140 -0
  19. package/skills/learn/references/interaction-mode-propagation.md +89 -0
  20. package/skills/learn/references/migration-bootstrap.md +142 -0
  21. package/skills/learn/references/templates/artifacts/captured-entry.md +172 -0
  22. package/skills/learn/references/templates/artifacts/index-update.md +135 -0
  23. package/skills/learn/references/templates/artifacts/learn-input.md +100 -0
  24. package/skills/learn/references/templates/artifacts/maintain-log.md +142 -0
  25. package/skills/learn/references/templates/artifacts/refined-entry.md +168 -0
  26. package/skills/plan/SKILL.md +129 -0
  27. package/skills/plan/modules/design.md +140 -0
  28. package/skills/plan/modules/generate.md +156 -0
  29. package/skills/plan/modules/research.md +122 -0
  30. package/skills/plan/modules/scope.md +121 -0
  31. package/skills/plan/modules/tasks.md +190 -0
  32. package/skills/plan/references/design-complexity-assessment.md +118 -0
  33. package/skills/plan/references/error-handling.md +155 -0
  34. package/skills/plan/references/external-research-guidance.md +61 -0
  35. package/skills/plan/references/high-risk-detection.md +111 -0
  36. package/skills/plan/references/id-generation.md +55 -0
  37. package/skills/plan/references/interaction-mode-propagation.md +75 -0
  38. package/skills/plan/references/learnings-gate-logic.md +93 -0
  39. package/skills/plan/references/plan-tier-selection.md +174 -0
  40. package/skills/plan/references/task-slicing-rules.md +220 -0
  41. package/skills/plan/references/templates/artifacts/design.md +134 -0
  42. package/skills/plan/references/templates/artifacts/final-plan.md +265 -0
  43. package/skills/plan/references/templates/artifacts/research-findings.md +50 -0
  44. package/skills/plan/references/templates/artifacts/scoped-context.md +53 -0
  45. package/skills/plan/references/templates/artifacts/task.md +192 -0
  46. package/skills/plan/references/templates/artifacts/user-input.md +112 -0
  47. package/skills/review/SKILL.md +163 -0
  48. package/skills/review/modules/analyze.md +104 -0
  49. package/skills/review/modules/prepare.md +103 -0
  50. package/skills/review/modules/report.md +109 -0
  51. package/skills/review/modules/scope.md +126 -0
  52. package/skills/review/references/approval-criteria.md +101 -0
  53. package/skills/review/references/change-set-resolution.md +126 -0
  54. package/skills/review/references/error-handling.md +172 -0
  55. package/skills/review/references/id-generation.md +80 -0
  56. package/skills/review/references/interaction-mode-propagation.md +80 -0
  57. package/skills/review/references/review-categories.md +124 -0
  58. package/skills/review/references/scope-creep-detection.md +120 -0
  59. package/skills/review/references/severity-rubric.md +107 -0
  60. package/skills/review/references/templates/artifacts/findings.md +161 -0
  61. package/skills/review/references/templates/artifacts/review-input.md +116 -0
  62. package/skills/review/references/templates/artifacts/review-kit.md +135 -0
  63. package/skills/review/references/templates/artifacts/review-report.md +175 -0
  64. package/skills/review/references/templates/artifacts/review-scope.md +146 -0
  65. package/skills/work/SKILL.md +163 -0
  66. package/skills/work/modules/execute.md +109 -0
  67. package/skills/work/modules/prepare.md +140 -0
  68. package/skills/work/modules/review.md +164 -0
  69. package/skills/work/modules/triage.md +181 -0
  70. package/skills/work/references/ad-hoc-input-resolution.md +122 -0
  71. package/skills/work/references/error-handling.md +183 -0
  72. package/skills/work/references/execution-mode-selection.md +95 -0
  73. package/skills/work/references/id-generation.md +85 -0
  74. package/skills/work/references/interaction-mode-propagation.md +80 -0
  75. package/skills/work/references/review-checklist.md +94 -0
  76. package/skills/work/references/task-execution-rules.md +116 -0
  77. package/skills/work/references/templates/artifacts/execution-log.md +123 -0
  78. package/skills/work/references/templates/artifacts/execution-plan.md +111 -0
  79. package/skills/work/references/templates/artifacts/work-input.md +78 -0
  80. package/skills/work/references/templates/artifacts/work-manifest.md +119 -0
  81. package/skills/work/references/templates/artifacts/work-report.md +143 -0
@@ -0,0 +1,111 @@
1
+ ---
2
+ title: High-Risk Area Detection
3
+ description: "Scan the task description and scoped context for high-risk keywords across six areas: Security, Payments, APIs, Migrations, Complex Logic, and Infrastructure."
4
+ type: reference
5
+ version: 1.1
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # High-Risk Area Detection
10
+
11
+ This file documents the keyword-based detection system for identifying high-risk areas during the research phase. It includes the risk keyword table, area definitions, and the heuristic for mapping detected areas to risk levels.
12
+
13
+ ## Risk Keywords Table
14
+
15
+ Scan the task description and scoped context for these keywords to identify high-risk areas:
16
+
17
+ | Area | Keywords | Risk Category |
18
+ | -------------- | ------------------------------------------------------------------------------------------------------ | ------------- |
19
+ | Security | auth, jwt, oauth, session, encryption, ssl, tls, certificate, permission, rbac, acl, audit, credential | CRITICAL |
20
+ | Payments | payment, billing, stripe, checkout, invoice, refund, transaction, subscription, pci, card | CRITICAL |
21
+ | APIs | api, rest, graphql, endpoint, integration, webhook, rate-limit, versioning | HIGH |
22
+ | Migrations | migration, upgrade, data, schema, version, backward-compat, deprecation | HIGH |
23
+ | Complex Logic | algorithm, analysis, processing, computation, ml, analytics, optimization | HIGH |
24
+ | Infrastructure | deploy, kubernetes, docker, scaling, network, cdn, load-balance, failover, disaster-recovery | HIGH |
25
+
26
+ ## Area Definitions
27
+
28
+ ### Security (CRITICAL)
29
+
30
+ Involves authentication, authorization, session management, encryption, or credential handling.
31
+
32
+ - **Examples:** JWT implementation, OAuth integration, session cookies, SSL certificates, password hashing
33
+ - **Why critical:** Security breaches can compromise the entire system
34
+ - **Escalation:** Always recommend external research unless extensive local patterns exist
35
+
36
+ ### Payments (CRITICAL)
37
+
38
+ Involves payment processing, billing, invoicing, or financial transactions.
39
+
40
+ - **Examples:** Stripe integration, checkout flow, refund logic, subscription management
41
+ - **Why critical:** Payment systems have strict compliance requirements (PCI DSS); errors cause financial loss
42
+ - **Escalation:** Always recommend external research; verify compliance requirements
43
+
44
+ ### APIs (HIGH)
45
+
46
+ Involves REST, GraphQL, or other API design and integration.
47
+
48
+ - **Examples:** RESTful endpoint design, GraphQL schema, third-party API integration, versioning
49
+ - **Why high:** Poor API design can create compatibility issues; integration errors block downstream work
50
+ - **Escalation:** Recommend external research if designing new APIs or integrating unfamiliar third-party services
51
+
52
+ ### Migrations (HIGH)
53
+
54
+ Involves schema changes, version upgrades, or data migration with impact on production.
55
+
56
+ - **Examples:** Database schema migration, framework upgrade, data format change, breaking API changes
57
+ - **Why high:** Migrations can cause data loss or downtime if not carefully planned
58
+ - **Escalation:** Recommend external research for migrations without local patterns
59
+
60
+ ### Complex Logic (HIGH)
61
+
62
+ Involves algorithms, machine learning, complex computations, or analysis.
63
+
64
+ - **Examples:** Sorting/searching algorithms, ML model selection, financial calculations, performance-critical code
65
+ - **Why high:** Bugs in complex logic can cascade; optimization mistakes are hard to reverse
66
+ - **Escalation:** Recommend external research if no local examples exist
67
+
68
+ ### Infrastructure (HIGH)
69
+
70
+ Involves deployment, container orchestration, scaling, or network architecture.
71
+
72
+ - **Examples:** Kubernetes deployment, Docker setup, load balancing, CDN configuration, disaster recovery
73
+ - **Why high:** Infrastructure mistakes can cause downtime or security vulnerabilities
74
+ - **Escalation:** Recommend external research for infrastructure patterns not yet documented
75
+
76
+ ## Risk Level Determination
77
+
78
+ After identifying which areas the task touches, assign a risk level using this logic:
79
+
80
+ ```
81
+ risk_level = determine_risk(areas_detected, high_risk_count)
82
+
83
+ if any_area_is_security_or_payments:
84
+ risk_level = CRITICAL
85
+ reason = "Critical area detected: " + critical_area
86
+ elif high_risk_count >= 2:
87
+ risk_level = HIGH
88
+ reason = "Multiple high-risk areas: " + areas_detected.join(", ")
89
+ elif any_area_is_api_migration_logic_infra:
90
+ risk_level = MEDIUM
91
+ reason = "High-risk area detected: " + area_name
92
+ else:
93
+ risk_level = LOW
94
+ reason = "No high-risk areas detected"
95
+ ```
96
+
97
+ ## Mapping to Research Decision
98
+
99
+ > **Authoritative.** The Research phase (Step 3) looks up its external-research decision directly in the matrix below, using the detected **risk level** and the **patterns found count**. Do not apply a separate formula — this matrix is the single source of truth.
100
+
101
+ Use risk level to determine if external research should be recommended:
102
+
103
+ | Risk Level | Patterns Found | Decision | Notes |
104
+ | ---------- | -------------- | ------------------ | -------------------------------------------- |
105
+ | CRITICAL | 0-2 | Recommend external | Insufficient local patterns; must research |
106
+ | CRITICAL | 3+ | Recommend external | Critical area; external research required |
107
+ | HIGH | 0-2 | Recommend external | Insufficient local patterns; must research |
108
+ | HIGH | 3+ | Optional external | Strong local patterns; external optional |
109
+ | MEDIUM | 0-1 | Recommend external | Limited local examples; external recommended |
110
+ | MEDIUM | 2+ | Optional external | Adequate local patterns; external optional |
111
+ | LOW | any | Skip external | Low risk; no external research needed |
@@ -0,0 +1,55 @@
1
+ ---
2
+ title: Artifact ID Generation
3
+ description: Reference for Scope, Research, Design, and Generate phases. Defines the daily-counter algorithm for unique artifact IDs, the recycle-on-edit rule, and the plan-id counting skip-list.
4
+ type: reference
5
+ version: 1.0
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Artifact ID Generation
10
+
11
+ Shared ID algorithm for the `scope`, `research`, `design`, and `generate` phases. Each phase assigns exactly one ID per newly produced artifact; the ID is reused (never re-incremented) when the user picks **Edit & Retry** at the phase confirmation.
12
+
13
+ ## ID Format by Phase
14
+
15
+ | Phase | ID format | Saved to |
16
+ | -------- | ----------------------------------- | -------------------------------- |
17
+ | Scope | `YYYY-MM-DD-NNN-scope` | `docs/plans/.scope/<id>.md` |
18
+ | Research | `YYYY-MM-DD-NNN-research` | `docs/plans/.research/<id>.md` |
19
+ | Design | `YYYY-MM-DD-NNN-design` | `docs/plans/.design/<id>.md` |
20
+ | Generate | `YYYY-MM-DD-NNN` (= `plan-id`) | `docs/plans/<id>-<kebab-name>.md`|
21
+
22
+ `<kebab-name>` is the plan title in lowercase-hyphen form (no stopwords).
23
+
24
+ ## Algorithm (new artifact)
25
+
26
+ ```
27
+ 1. Get the current date in UTC (e.g., 2026-07-03)
28
+ 2. List existing files for today in the phase's save directory
29
+ - scope -> docs/plans/.scope/ matching YYYY-MM-DD-*.md
30
+ - research-> docs/plans/.research/matching YYYY-MM-DD-*.md
31
+ - design -> docs/plans/.design/ matching YYYY-MM-DD-*.md
32
+ - generate-> docs/plans/ matching YYYY-MM-DD-*.md
33
+ EXCLUDE the .scope/, .research/, .design/ subdirectories
34
+ 3. NNN = (count + 1), zero-padded to 3 digits (001, 002, ..., 010, ...)
35
+ 4. id = "<date>-<NNN>-<phase>" (or "<date>-<NNN>" for plan-id)
36
+ ```
37
+
38
+ If two scope artifacts were created today, the next one is `2026-07-03-003-scope`. Counters are independent per phase; each phase counts only its own files.
39
+
40
+ ## Recycle on Edit & Retry
41
+
42
+ When the user picks **Edit & Retry** at the phase confirmation, **reuse the original ID** and overwrite the existing artifact file. Do **not** increment the counter. This keeps IDs stable across iterations and prevents orphaned artifacts.
43
+
44
+ ## Error Handling
45
+
46
+ | Trigger | Action |
47
+ | ----------------------------------------------- | -------------------------------------------- |
48
+ | Phase save directory does not exist | Create it; treat count as 0; start from 001 |
49
+ | Directory exists but no files match today's date | Start counter at 001 |
50
+ | Write permission denied | Log error; ask the user; retry once |
51
+
52
+ ## Notes
53
+
54
+ - IDs are reused for cross-phase chaining: `research-id` carries the `scope-id`, `design-id` carries both, and `plan-id` carries `scope-id`, `research-id`, and `design-id` (see [error-handling.md](error-handling.md) "Cross-Phase Consistency Checks").
55
+ - Counter collisions are impossible within a date because each phase writes to its own directory and recomputes the count from the directory listing.
@@ -0,0 +1,75 @@
1
+ ---
2
+ title: Interaction Mode Propagation
3
+ description: Reference for how `interactionMode` propagates through the Plan pipeline (Scope → Research → Design → Generate → Tasks). Set at Orchestrator; each phase reads and applies mode-specific behavior.
4
+ type: reference
5
+ version: 1.1
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Interaction Mode Propagation
10
+
11
+ Reference for how `interactionMode` propagates through the Plan pipeline (Scope → Research → Design → Generate → Tasks). Set at Orchestrator; each phase reads and applies mode-specific behavior.
12
+
13
+ ## Modes
14
+
15
+ | Mode | Behavior | Use Case |
16
+ | ------------- | ----------------------------------------------------- | ------------------------------------ |
17
+ | **Detailed** | Pause at each phase; show artifacts; require approval | Complex work, unfamiliar codebases |
18
+ | **Smart** | Auto-proceed; pause only on HIGH-risk flags | Familiar codebases with guardrails |
19
+ | **Autopilot** | Run all phases auto (except Tasks, which always asks) | Straightforward work, time-sensitive |
20
+
21
+ ## Phase Behavior by Mode
22
+
23
+ | Phase | Detailed | Smart | Autopilot |
24
+ | ------------ | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | --------------------------------- |
25
+ | **Scope** | Present artifact; ask Proceed/Edit/Abort | Auto-proceed; pause if 3+ learning gaps, non-software domain, or conflicting requirements | Auto-proceed |
26
+ | **Research** | Show findings; ask Proceed/Edit/Abort | Auto-proceed; pause if HIGH/CRITICAL risk with <3 patterns, or zero patterns found | Auto-proceed |
27
+ | **Design** | Show units; ask Proceed/Edit/Abort | Auto-proceed; pause if VERY_HIGH complexity, HIGH risk + <3 patterns, 3+ scope gaps, or Novelty=3 | Auto-proceed |
28
+ | **Generate** | Show plan; ask Proceed/Edit/Skip/Abort | Auto-proceed; pause if tier=Deep, tier preference conflicts with risk floor, or CRITICAL risk | Auto-proceed |
29
+ | **Tasks** | Ask Create/Review/No (full file content shown) | Ask Create/Review/No (summary shown) | Ask Create/Review/No (always asks) |
30
+
31
+ **Smart mode pauses only on each phase's documented triggers above** (the canonical list lives in each module's confirmation step; this table is a summary).
32
+
33
+ ## Artifact Schema
34
+
35
+ All phase artifacts (Scope 1-4) include:
36
+
37
+ ```yaml
38
+ type: scope | research | design | plan
39
+ scope-id: 2026-07-02-001-scope
40
+ interactionMode: detailed | smart | autopilot # Passed from previous phase
41
+ status: pending | complete | failed
42
+ ```
43
+
44
+ ## Implementation
45
+
46
+ **Each phase must:**
47
+
48
+ 1. Read `interactionMode` from incoming artifact (or context for Scope)
49
+ 2. Apply mode-specific behavior per table above
50
+ 3. Include `interactionMode` in output artifact
51
+
52
+ **Phase 5 (Tasks):** Always ask user about task slicing, even in Autopilot mode.
53
+
54
+ ## Example
55
+
56
+ **SMART mode on complex codebase task:**
57
+
58
+ - Scope detects 3 learning gaps → pauses (HIGH-risk)
59
+ - User approves → Research runs
60
+ - Research detects unfamiliar framework → pauses (HIGH-risk)
61
+ - User approves → Design runs
62
+ - Design complexity MEDIUM → auto-proceeds
63
+ - Generate renders → auto-proceeds
64
+ - Tasks asks user → user chooses yes
65
+
66
+ **Result:** Paused only for critical decisions; faster than Detailed with safety guardrails.
67
+
68
+ ## Error Handling
69
+
70
+ | Scenario | Recovery |
71
+ | --------------------------- | ------------------------------------- |
72
+ | Mode missing | Default to "smart"; log warning |
73
+ | Invalid mode value | Reject; re-prompt Orchestrator |
74
+ | Artifact missing mode field | Assume "smart"; log warning; continue |
75
+ | Timeout/connection lost | Pause; ask user to retry or abort |
@@ -0,0 +1,93 @@
1
+ ---
2
+ title: Learnings Gate Logic
3
+ description: Reference for Scope Phase Step 4. Defines keyword matching, relevance scoring, gap identification, and inclusion criteria.
4
+ type: reference
5
+ version: 1.1
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Learnings Gate Logic
10
+
11
+ Reference for **Scope Phase Step 4**. Defines keyword matching, relevance scoring, gap identification, and inclusion criteria.
12
+
13
+ ## Algorithm
14
+
15
+ 1. **Extract keywords** — Tokenize task description/intended behavior (remove stop words, normalize to lowercase, keep domain terms)
16
+ 2. **Match learnings** — Exact match: keyword in learning title/summary; Fuzzy match: Levenshtein ≤2 for variants (e.g., "auth" vs "authentication")
17
+ 3. **Score relevance** — HIGH/MEDIUM/LOW based on domain match and applicability
18
+ 4. **Filter** — Include only HIGH/MEDIUM in Scoped Context
19
+ 5. **Identify gaps** — For each task domain not covered by HIGH/MEDIUM learnings, document gap
20
+
21
+ **Example:** Task "Add WebSocket collaboration"
22
+
23
+ - Extract: `websocket`, `collaboration`, `synchronization`
24
+ - Match: `websocket-best-practices.md` (exact), `concurrent-edits.md` (fuzzy)
25
+ - Skip: `ci-cd-pipelines.md` (no match)
26
+
27
+ ## Relevance Scoring
28
+
29
+ | Level | Criteria | Example |
30
+ | ---------- | ------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
31
+ | **HIGH** | Exact domain match + DIRECT/CRITICAL applicability. Learning directly applies to explicit task goal. | Task: "Migrate REST→gRPC" + Learning: `grpc-performance-tuning.md` (DIRECT) → HIGH |
32
+ | **MEDIUM** | Related domain + RECOMMENDED/CONTEXTUAL applicability. Learning provides context or potential solution. | Task: "Reduce API latency" + Learning: `caching-strategies.md` (RECOMMENDED) → MEDIUM |
33
+ | **LOW** | Distant domain or HISTORICAL/INFORMATIONAL. Exclude from scope. | Task: "Add dark mode UI" + Learning: `backend-load-balancing.md` (unrelated) → EXCLUDE |
34
+
35
+ **Inclusion:** Add HIGH/MEDIUM learnings to `Related Learnings` in Scoped Context. Exclude LOW.
36
+
37
+ ## Gap Identification
38
+
39
+ A **learning gap** is a task domain with no HIGH/MEDIUM relevance learning.
40
+
41
+ **Algorithm:**
42
+
43
+ 1. Extract task domains (from description, goals, constraints)
44
+ 2. For each domain: check if HIGH/MEDIUM learning exists
45
+ 3. If not, document gap with: name, domain, relevance to task, suggested action
46
+
47
+ **Format:**
48
+
49
+ ```yaml
50
+ - gap_name: "[Domain] — [what's missing]"
51
+ domain: [primary domain]
52
+ relevance: why this matters for the task
53
+ suggested_action: "Research external resource" or "Document post-implementation"
54
+ ```
55
+
56
+ **Example:** Task "Implement multi-user undo/redo"
57
+
58
+ - Domains: `undo-redo`, `collaboration`, `conflict-resolution`
59
+ - Learning found: `ot-basics.md` (covers conflicts)
60
+ - Gap: "Undo/Redo Coordination — No learning on undo behavior in collaborative environments"
61
+ → Suggested action: "Research Google Docs model; document post-implementation"
62
+
63
+ ## Learning Entry Format (index.md)
64
+
65
+ Learnings must include:
66
+
67
+ ```yaml
68
+ filename: docs/learn/xxx.md
69
+ domain: [primary domain]
70
+ tags: [related_domain_1, related_domain_2]
71
+ applicability: DIRECT | RECOMMENDED | CONTEXTUAL | HISTORICAL | INFORMATIONAL
72
+ summary: [1-2 sentence summary]
73
+ ```
74
+
75
+ ## Scope Phase Integration
76
+
77
+ **Scope Step 4** executes:
78
+
79
+ 1. Extract keywords from task + intended behavior
80
+ 2. Keyword match against `docs/learn/index.md` (exact + fuzzy)
81
+ 3. Score matches: HIGH/MEDIUM/LOW per table above
82
+ 4. Filter: keep HIGH/MEDIUM only
83
+ 5. Identify gaps: domains not covered
84
+ 6. Output: `Related Learnings` + `Learning Gaps` in Scoped Context
85
+
86
+ ## Error Handling
87
+
88
+ | Error | Recovery |
89
+ | ---------------- | ------------------------------------ |
90
+ | index.md missing | Skip; set empty learnings & gaps |
91
+ | Malformed entry | Log warning; skip entry; continue |
92
+ | No matches | Set `Related Learnings: []`; proceed |
93
+ | >10 matches | Trim to top 5-7 by relevance score |
@@ -0,0 +1,174 @@
1
+ ---
2
+ title: Plan Tier Selection
3
+ description: Reference for the Generate phase. Defines the Fast/Standard/Deep tier model, the selection algorithm that combines complexity, risk, and user preference, and the template sections each tier requires.
4
+ type: reference
5
+ version: 1.1
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Plan Tier Selection
10
+
11
+ This file documents the tier system used by the **Generate** phase (Phase 4) to right-size the final plan document. It defines three tiers, the selection algorithm, the template sections each tier requires, and how tier choice interacts with the interaction mode.
12
+
13
+ ## When to Apply
14
+
15
+ Tier selection happens at the start of the Generate phase, after reading the Design Artifact (which carries the `complexity` field) and the Research Findings (which carry the `risk_level`). The chosen tier determines which sections of the [Final Plan template](templates/artifacts/final-plan.md) are rendered and how much structure the plan contains.
16
+
17
+ ## The Three Tiers
18
+
19
+ | Tier | Use When | Length | Sections Included |
20
+ | ------------ | -------------------------------------------------- | --------- | ---------------------------------------------------------------- |
21
+ | **Fast** | Trivial/low complexity, straightforward work | 1–2 pages | Overview, High-Level Design, Units (single phase), Risks (brief) |
22
+ | **Standard** | Medium complexity, typical feature work | 2–4 pages | All template sections, phased units, full risk table |
23
+ | **Deep** | High/very-high complexity, cross-system, high-risk | 4+ pages | All template sections + alternatives + rollout ops + monitoring |
24
+
25
+ ## Selection Algorithm
26
+
27
+ ```
28
+ function select_tier(complexity, risk_level, user_preference):
29
+ # 1. Start from complexity-driven default
30
+ if complexity in [TRIVIAL, LOW]:
31
+ base_tier = Fast
32
+ elif complexity == MEDIUM:
33
+ base_tier = Standard
34
+ else: # HIGH or VERY_HIGH
35
+ base_tier = Deep
36
+
37
+ # 2. Upgrade tier if risk warrants it
38
+ if risk_level == HIGH and base_tier == Fast:
39
+ base_tier = Standard
40
+ if risk_level == CRITICAL:
41
+ base_tier = Deep
42
+
43
+ # 3. Honor explicit user preference (never downgrade below risk floor)
44
+ if user_preference == "fast" and risk_level not in [HIGH, CRITICAL]:
45
+ return Fast
46
+ if user_preference == "deep":
47
+ return Deep
48
+ if user_preference == "standard" and risk_level != CRITICAL:
49
+ return Standard
50
+
51
+ return base_tier
52
+ ```
53
+
54
+ ### Inputs
55
+
56
+ | Input | Source | Values |
57
+ | ----------------- | ------------------------------- | ------------------------------------- |
58
+ | `complexity` | Design Artifact | TRIVIAL, LOW, MEDIUM, HIGH, VERY_HIGH |
59
+ | `risk_level` | Research Findings Artifact | LOW, MEDIUM, HIGH, CRITICAL |
60
+ | `user_preference` | User (asked in Generate Step 1) | `fast`, `standard`, `deep`, or `auto` |
61
+
62
+ ### Risk Floor
63
+
64
+ The risk level sets a **minimum tier** that user preference cannot override:
65
+
66
+ | Risk Level | Minimum Tier |
67
+ | ---------- | ------------ |
68
+ | LOW | Fast |
69
+ | MEDIUM | Fast |
70
+ | HIGH | Standard |
71
+ | CRITICAL | Deep |
72
+
73
+ Rationale: High/critical risk mandates enough structure to capture alternatives, rollout, and rollback — even if the user wants a short plan.
74
+
75
+ ## Tier Section Requirements
76
+
77
+ ### Fast Tier
78
+
79
+ Required sections:
80
+
81
+ - Overview (1–2 sentences)
82
+ - High-Level Technical Design (one of: Mermaid, pseudo-code, or data-flow map)
83
+ - Implementation Units (single phase, 1–3 units)
84
+ - Risk Analysis & Mitigation (brief table, 1–2 rows)
85
+ - Related Learnings
86
+
87
+ Optional (skip if not applicable): Alternative Approaches, Operational Notes, Learning Gaps.
88
+
89
+ ### Standard Tier
90
+
91
+ Required sections (all template sections):
92
+
93
+ - Overview
94
+ - High-Level Technical Design
95
+ - Implementation Units (phased, 2+ phases)
96
+ - Alternative Approaches Considered (at least 1)
97
+ - Risk Analysis & Mitigation (full table)
98
+ - Operational / Rollout Notes
99
+ - Related Learnings
100
+ - Learning Gaps
101
+
102
+ ### Deep Tier
103
+
104
+ Required sections (all Standard sections, plus):
105
+
106
+ - Alternative Approaches Considered (at least 2, with side-by-side comparison)
107
+ - Risk Analysis & Mitigation (full table with impact ratings)
108
+ - Operational / Rollout Notes (must include: feature flags, monitoring, data migration, rollback plan, performance baseline)
109
+ - Explicit complexity and tier in frontmatter
110
+ - Cross-system integration map (data-flow or sequence diagram)
111
+
112
+ ## Interaction Mode Behavior
113
+
114
+ | Mode | Tier Selection Behavior |
115
+ | --------- | --------------------------------------------------------------------------------------------------- |
116
+ | Detailed | Ask the user to confirm the selected tier; offer to override |
117
+ | Smart | Auto-select; pause **only** if selected tier is Deep (or user preference conflicts with risk floor) |
118
+ | Autopilot | Auto-select with `user_preference = auto`; never pause |
119
+
120
+ **Smart mode pause triggers:**
121
+
122
+ - Selected tier is Deep (signals complex work worth a review)
123
+ - User preference conflicts with risk floor (e.g., user wants Fast but risk is HIGH)
124
+ - Research phase reported CRITICAL risk (Security or Payments)
125
+
126
+ ## Asking the User for Preference
127
+
128
+ In Detailed mode (or when Smart mode pauses), ask the user one question:
129
+
130
+ ```
131
+ Based on the design complexity (HIGH) and risk level (HIGH), I recommend the Standard tier.
132
+ Which tier would you like for the plan?
133
+ - Fast: Short plan, minimal structure (1-2 pages)
134
+ - Standard: Full plan with phased units and risk table (2-4 pages) [Recommended]
135
+ - Deep: Comprehensive plan with alternatives and rollout ops (4+ pages)
136
+ - Auto: Let the algorithm decide (result: Standard)
137
+ ```
138
+
139
+ Record the user's choice as the selected **`tier`** in the final plan frontmatter; preserve the algorithm's suggestion as **`tier_recommended`** so an override is auditable.
140
+
141
+ ## Worked Examples
142
+
143
+ ### Example 1: Low complexity, low risk
144
+
145
+ - `complexity = LOW`, `risk_level = LOW`, `user_preference = auto`
146
+ - Base tier: Fast. No risk upgrade. Auto preference → **Fast**.
147
+
148
+ ### Example 2: Medium complexity, high risk, user wants fast
149
+
150
+ - `complexity = MEDIUM`, `risk_level = HIGH`, `user_preference = fast`
151
+ - Base tier: Standard. Risk upgrade: already Standard (HIGH floor). User wants Fast but HIGH risk floor is Standard → **Standard**.
152
+ - Smart mode would pause (preference conflicts with risk floor).
153
+
154
+ ### Example 3: High complexity, critical risk (payments)
155
+
156
+ - `complexity = HIGH`, `risk_level = CRITICAL`, `user_preference = auto`
157
+ - Base tier: Deep. CRITICAL forces Deep. Auto preference → **Deep**.
158
+ - Smart mode pauses (Deep tier + CRITICAL risk).
159
+
160
+ ## Error Handling
161
+
162
+ | Scenario | Recovery |
163
+ | --------------------------------------- | ----------------------------------------------- |
164
+ | `complexity` field missing from Design | Default to MEDIUM; log warning |
165
+ | `risk_level` missing from Research | Default to MEDIUM; log warning |
166
+ | User provides invalid preference value | Treat as `auto`; log warning |
167
+ | Selected tier conflicts with risk floor | Enforce risk floor; inform user of the override |
168
+
169
+ ## Notes
170
+
171
+ - Tier choice is recorded in the final plan's frontmatter as `tier: fast | standard | deep`
172
+ - The tier also influences the Tasks phase: Fast tier often produces 1–3 tasks; Standard 4–8; Deep 8+
173
+ - If the user overrides the tier, preserve the algorithm's recommendation in a `tier_recommended` field for audit
174
+ - Tier selection is the primary "right-sizing" mechanism — Small tasks → short plans; complex work → more structure (per Plan Skill core principles)