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,121 @@
1
+ ---
2
+ title: Scope
3
+ description: Gather context, check existing plans and learnings, validate domain, and return a scoped context object for downstream modules (research, design, generate).
4
+ type: module
5
+ version: 1.1
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Phase 1 - Scope & Context Gathering
10
+
11
+ **Purpose:** Entry point to the planning workflow. Gathers context, checks existing plans and learnings, validates domain, and returns a scoped context object that downstream modules (research, design, generate) consume.
12
+
13
+ ## Workflow
14
+
15
+ This is the Phase 1 pipeline for the Plan Skill. It orchestrates the following steps:
16
+
17
+ ### Step 0: Verification
18
+
19
+ Run the **[Step 0 verification](../references/error-handling.md)**. Required input: a valid **User Input Artifact** (see [user-input.md](../references/templates/artifacts/user-input.md)) from the Orchestrator.
20
+
21
+ ### Step 1: Check for Existing Plan
22
+
23
+ 1. Search `docs/plans/index.md` for existing plans related (grep title and description) to the task.
24
+ - If the index file does not exist, assume no existing plans are present.
25
+ - Ask the user one multiple-choice question:
26
+ ```
27
+ The Plans Index was not found. Do you want to run the /arreio-init to create all the necessary folders, files, and index for planning? (Recommended)
28
+ What would you like to do?
29
+ - Yes: Run /arreio-init to create the planning structure
30
+ - No: Skip and continue without creating the structure
31
+ ```
32
+ - If the user selects "Yes," run `/arreio-init` to create the necessary structure, then run the Step 1 of the Scope phase again to check for existing plans.
33
+
34
+ 2. **If an existing plan is found:**
35
+ - Read the plan to understand its title and goal. Plan files are stored in `docs/plans/` with naming format: `YYYY-MM-DD-NNN-<kebab-case-name>.md` (e.g., `docs/plans/2026-07-02-001-migrate-session-storage.md`)
36
+ - Ask the user one multiple-choice question:
37
+ ```
38
+ An existing plan was found: "[Plan Title]"
39
+ What would you like to do?
40
+ - Resume: Continue working on this plan
41
+ - Review: Read the plan before deciding
42
+ - Archive: Keep for reference, mark as inactive
43
+ - Delete: Remove the plan entirely
44
+ - Create New: Start fresh
45
+ ```
46
+ - Handle each choice:
47
+ - **Resume:** Use plan as-is; set `existing_plan.action: resume`, `existing_plan.path: docs/plans/YYYY-MM-DD-NNN-<kebab-case-name>.md` and carry the reference forward; the pipeline still runs and produces a new `plan-id` that supersedes the existing plan
48
+ - **Review:** Show plan summary, then re-prompt with same options
49
+ - **Archive:** Move to archive; set `existing_plan.action: archive`, update `docs/plans/index.md` to mark as archived
50
+ - **Delete:** Remove file; set `existing_plan.action: delete`, update `docs/plans/index.md` to remove entry
51
+ - **Create New:** Keep old plan in archive; set `existing_plan.action: create-new`, `existing_plan.path: null`
52
+
53
+ 3. **If no existing plan is found:**
54
+ - Set `existing_plan.path: null`, `existing_plan.action: none`
55
+ - Proceed to Step 2
56
+
57
+ ### Step 2: Domain Validation
58
+
59
+ - Check if the context provided is a software/code planning task (the downstream phases are tailored for software planning).
60
+ - Record `domain: software | non-software` in the scoped context.
61
+ - **If the task is non-software:** ask one question with options *(1) Proceed anyway* (continue with generic, reduced software-style guidance) or *(2) Abort and plan manually*. On Abort, stop and inform the Orchestrator. On Proceed, continue with `domain: non-software`.
62
+
63
+ ### Step 3: Bootstrap Problem Context
64
+
65
+ Evaluate if context is "rich enough" by confirming the **User Input Artifact** contains **all three** of:
66
+
67
+ - **Problem frame** — a clear `Task Description` (the problem statement)
68
+ - **Intended Behavior** — an observable desired outcome
69
+ - **Success Criteria** — 1–3 measurable outcomes (derive from `Goals & Objectives` if already measurable; otherwise collect below)
70
+
71
+ **If any of these three are missing or vague:** ask the user, one question at a time:
72
+
73
+ 1. **Problem Frame:** "What problem are you trying to solve? Describe it in 1–2 sentences." (maps to `Task Description`)
74
+ 2. **Intended Behavior:** "What should happen after this is implemented? Describe the desired outcome." (maps to `Intended Behavior`)
75
+ 3. **Success Criteria:** "How will we know this is complete? What specific outcomes define success?" Collect 1–3 criteria.
76
+
77
+ **If all three are present and concrete:** extract them from the **User Input Artifact** and proceed to Step 4.
78
+
79
+ ### Step 4: Learnings Index Gate
80
+
81
+ Always search for project learnings (in `docs/learn/index.md`) for entries matching the task description. For details on keyword matching, relevance rating, gap identification, and examples, see **[learnings-gate-logic.md](../references/learnings-gate-logic.md)**. Add HIGH and MEDIUM relevance learnings to `Related Learnings`; identify and document any learning gaps.
82
+
83
+ ### Step 5: Requirements Search
84
+
85
+ 1. Search `docs/` for files whose names or content match the task description.
86
+ - Keywords: exact match on filename, grep content for relevant terms
87
+ - If the directory does not exist, skip silently
88
+ - ignore files in `docs/archives/`,`docs/plans/`, and `docs/learn/` (already handled in previous steps)
89
+ 2. **For each match:**
90
+ - Extract the title and a 1-2 sentence relevant excerpt
91
+ - Add to `Requirements Found` list
92
+ 3. If no matches found, set `Requirements Found` to empty.
93
+
94
+ ### Step 6: Generate the Scoped Context Artifact
95
+
96
+ 1. **Assign a `scope-id`** per [id-generation.md](../references/id-generation.md) (format `YYYY-MM-DD-NNN-scope`, saved to `docs/plans/.scope/`). Reuse it if the user later picks **Edit & Retry**.
97
+
98
+ 2. Produce a **Scoped Context Artifact** block (as markdown) following the schema in [scoped-context.md](../references/templates/artifacts/scoped-context.md).
99
+ - Include the generated `scope-id` in the artifact
100
+
101
+ ### Step 7: Present, Confirm, and Save
102
+
103
+ Apply the **[phase confirmation behavior](../references/interaction-mode-propagation.md)** for the current `interactionMode`, using these scope-specific **Smart pause triggers**:
104
+
105
+ - 3+ learning gaps identified, or
106
+ - Domain flagged non-software (Step 2), or
107
+ - Conflicting requirements detected in the User Input.
108
+
109
+ - **Detailed:** present the Scoped Context Artifact and ask one question with options *(1) Proceed to Research, (2) Edit & Retry, (3) Abort*. On **Edit & Retry**, loop back through Steps 2–6 reusing the `scope-id`. On **Abort**, stop and inform the Orchestrator.
110
+ - **Smart:** pause only when a pause trigger above is true; otherwise auto-proceed.
111
+ - **Autopilot:** auto-proceed (no confirmation).
112
+
113
+ Then save the artifact to `docs/plans/.scope/<scope-id>.md` (ensure `interactionMode` is included) and return it, with the `interactionMode` value, to the Orchestrator for the transition to Phase 2 (Research).
114
+
115
+ ## Output: Scoped Context Artifact
116
+
117
+ - Verify that the Scoped Context Artifact is complete and valid, containing all required fields, and it accurately reflects the user's input and any existing plans, learnings, or requirements found.
118
+ - Verify that the `interactionMode` value is set correctly based on the user's selection in the Orchestrator skill.
119
+ - Verify that the artifact is saved to `docs/plans/.scope/<scope-id>.md` for future reference or reuse.
120
+
121
+ > Pass the scoped context to `research` (Phase 2) for the research phase.
@@ -0,0 +1,190 @@
1
+ ---
2
+ title: Tasks
3
+ description: Slice the finalized plan into granular, executable, test-driven task files saved to docs/tasks/. One task per Acceptance Criterion; one test per task; ordered by dependency. Optional Phase 5 of the Plan pipeline.
4
+ type: module
5
+ version: 2.0
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Phase 5 - Tasks
10
+
11
+ **Purpose:** Fifth and final (optional) step in the planning workflow. Reads the Final Plan's Implementation Units and their **Acceptance Criteria**, slices them into granular, executable task files per the [task-slicing rules](../references/task-slicing-rules.md), orders them by dependency, and saves them to `docs/tasks/<plan-id>/`. Produces a set of [Task Artifacts](../references/templates/artifacts/task.md) that the Work skill (`work/SKILL.md`) consumes for execution.
12
+
13
+ > **Optional phase.** The Orchestrator must ask the user before continuing to this phase, even in Autopilot mode — the user may prefer to defer task generation.
14
+
15
+ ## Core rule
16
+
17
+ **One Acceptance Criterion per task. One test per task. Test-Driven.**
18
+
19
+ - Each Implementation Unit carries one or more **Acceptance Criteria** (set in the Design phase).
20
+ - Each Acceptance Criterion becomes **exactly one task** → with **exactly one test file** in `files.test` asserting that single criterion.
21
+ - Each task's `## Steps` follow **Red → Green → Refactor** (write the failing test first and confirm it fails, implement the minimum code to pass, then refactor with the test green).
22
+ - Never bundle multiple Acceptance Criteria into one task. Never merge units into a shared multi-criterion task.
23
+
24
+ ## Workflow
25
+
26
+ This is the Phase 5 pipeline for the Plan Skill. It orchestrates the following steps:
27
+
28
+ ### Step 0: Verification
29
+
30
+ Run the **[Step 0 verification](../references/error-handling.md)**. Required input: a valid **Final Plan Artifact** from Generate. Specifically verify:
31
+
32
+ 1. The Final Plan exists at `docs/plans/YYYY-MM-DD-NNN-<kebab-case-name>.md` and is non-empty.
33
+ 2. The plan frontmatter contains `plan-id`, `tier`, `complexity`, `risk`, and `interactionMode`.
34
+ 3. The plan body contains an `## Implementation Units (Phased)` section with at least one unit (`U1`), and each unit lists its **Acceptance Criteria** (at least one).
35
+ 4. If the plan has no Implementation Units, abort and ask the user to re-run the Generate phase — the plan is incomplete.
36
+
37
+ ### Step 1: Read and Normalize Units
38
+
39
+ 1. **Read the Implementation Units** from the Final Plan. Parse each unit into a normalized record:
40
+
41
+ ```yaml
42
+ - id: U1
43
+ name: "[Unit Name]"
44
+ goal: "[What this unit accomplishes]"
45
+ phase: 1 | 2 | 3
46
+ dependencies: [U<id>, ...] # Unit IDs this depends on
47
+ files:
48
+ create: [path, ...]
49
+ modify: [path, ...]
50
+ test: [path, ...]
51
+ acceptance_criteria: # each becomes exactly one task + one test
52
+ - "[single, verifiable criterion]"
53
+ test_scenarios: # informational; the task's one test asserts the AC
54
+ - "[Scenario]: [Input -> Expected Outcome]"
55
+ ```
56
+
57
+ 2. **Extract the plan's `Related Learnings`** to carry into task files that touch the relevant domains.
58
+ 3. **Extract the plan's `tier`** to determine sizing guidance (see [task-slicing-rules.md](../references/task-slicing-rules.md)).
59
+
60
+ ### Step 2: Slice Into Candidate Tasks (one per Acceptance Criterion)
61
+
62
+ Apply the [task-slicing rules](../references/task-slicing-rules.md):
63
+
64
+ 1. **One task per Acceptance Criterion.** For every criterion on every unit, create one candidate task inheriting the unit's goal, dependencies, and file paths. Each task gets its own dedicated test file in `files.test`.
65
+ 2. **Never split within an Acceptance Criterion.** If a criterion would need > 5 files or > 1 day of effort, **split the criterion into two finer sub-criteria** (each its own task) and update the originating unit accordingly — do not slice a task partway through a criterion. Honor the tier's sizing targets (Fast: 1–3 tasks; Standard: 4–8; Deep: 8–15) when choosing how fine to split.
66
+ 3. **Sub-IDs only.** If one unit yields multiple criteria/tasks, use sub-identifiers: `U1` → `U1a`, `U1b`. Never renumber original units.
67
+ 4. **No merging across criteria.** Do not merge tasks; a task always carries exactly one Acceptance Criterion. (Trivial adjacent units that genuinely share a single criterion are already a single criterion by definition.)
68
+ 5. Record slicing decisions for traceability (which criteria were split and why).
69
+
70
+ ### Step 3: Order by Dependencies
71
+
72
+ Order the tasks so each task's dependencies are satisfied by earlier tasks, using the topological ordering algorithm in [task-slicing-rules.md](../references/task-slicing-rules.md):
73
+
74
+ ```
75
+ 1. Start with all tasks as "remaining".
76
+ 2. Find tasks whose dependencies are all already ordered → "ready".
77
+ 3. If no task is ready: a cycle exists → surface to the user, ask to break or abort.
78
+ 4. Sort ready tasks by original unit number (stable ordering).
79
+ 5. Append ready tasks to "ordered"; remove from "remaining".
80
+ 6. Repeat until all tasks are ordered.
81
+ ```
82
+
83
+ On a cycle: log the error, list the involved tasks, and ask the user one question whether to break the cycle manually (remove a dependency) or abort the Tasks phase.
84
+
85
+ ### Step 4: Assign Priorities
86
+
87
+ Assign a priority to each ordered task:
88
+
89
+ | Priority | Criteria |
90
+ | -------- | -------------------------------------------------- |
91
+ | P0 | Blocks all other tasks (foundation, infra, schema) |
92
+ | P1 | On the critical path but not blocking |
93
+ | P2 | Can be deferred or parallelized |
94
+
95
+ Default: Phase 1 (Foundation) tasks → `P0`; Phase 2 (Integration) → `P1`; Phase 3 (Rollout) → `P2`. Adjust based on the plan's risk analysis — a rollout task that mitigates a HIGH risk may be `P1`.
96
+
97
+ ### Step 5: Present and Confirm
98
+
99
+ > **Always ask the user in this phase**, even in Autopilot mode (per [interaction-mode-propagation.md](../references/interaction-mode-propagation.md)).
100
+
101
+ Present the ordered task manifest to the user with one question:
102
+
103
+ ```
104
+ The plan has been sliced into <N> tasks (T01–T<NN>); one per Acceptance Criterion,
105
+ each with its own failing-first test.
106
+ Would you like me to create the task files in docs/tasks/<plan-id>/?
107
+ - Yes: Create all task files and update the index
108
+ - Review: Show the task list first, then ask again
109
+ - No: Skip task creation
110
+ ```
111
+
112
+ - **Review:** display the full task list (IDs, titles, AC, dependencies, priorities, test file) and re-prompt.
113
+ - **No:** skip task creation; the plan remains the unit of work (the user can slice manually later). Inform the Orchestrator that the plan is complete without tasks.
114
+ - **Detailed mode only:** before saving, also show the full content of each task file and allow edit requests.
115
+ - **Yes:** proceed to Step 6.
116
+
117
+ ### Step 6: Materialize Task Files
118
+
119
+ For each ordered task, materialize a task file using the [Task Artifact template](../references/templates/artifacts/task.md):
120
+
121
+ 1. **Assign a task ID:** `<plan-id>-T<NN>` where `NN` is a zero-padded 2-digit number matching dependency order (01, 02, ..., 10). Sub-IDs → `T02a`, `T02b` (letters, not extra digits).
122
+ 2. **Derive the filename:** `T<NN>-<kebab-case-name>.md` (e.g., `T01-redis-client-setup.md`).
123
+ 3. **Fill the schema** (all fields required unless noted):
124
+ - `id` = `<plan-id>-T<NN>`; `title` action-oriented (from the criterion); `plan-id`; `unit` = originating unit (or sub-ID, e.g., `U1` / `U1a`); `tier` inherited; `status = not-started`; `priority` from Step 4; `dependencies` = mapped earlier task IDs; `files` = inherited (create/modify + a **dedicated `test` file for this criterion**); `estimated-effort` by tier (Fast: ≤ half day; Standard/Deep: ≤ 1 day).
125
+ - `## Goal` — inherited from the unit, scoped to this criterion (1–2 sentences).
126
+ - `## Acceptance Criterion` — **exactly one** verifiable criterion.
127
+ - `## Steps` — **Red → Green → Refactor**, in that order:
128
+ 1. **(Red)** Write the failing test in the file from `files.test` asserting this one Acceptance Criterion. Run it and confirm it fails **for the right reason**.
129
+ 2. **(Green)** Implement the minimum code (in `files.create` / `files.modify`) to make the test pass.
130
+ 3. **(Refactor)** Clean up naming, duplication, and structure while keeping the test green.
131
+ - `## Test Scenarios` — the assertion(s) for this criterion: `[Scenario]: [Input -> Expected Outcome]` (required for Phase 1–2; optional for rollout-only). May be a single scenario (this task asserts one criterion).
132
+ - `## Dependencies` — `task-id: why` or `None`.
133
+ - `## Notes` — carry the relevant `Related Learnings` and any gotchas.
134
+ 4. **Validate** each task file against the [task.md template](../references/templates/artifacts/task.md) validation rules (singular AC, one test per AC, Red-first Steps, repository-relative paths).
135
+
136
+ ### Step 7: Save Task Files
137
+
138
+ 1. **Create the task directory** `docs/tasks/<plan-id>/` if it does not exist.
139
+ 2. **Save each task file** to `docs/tasks/<plan-id>/T<NN>-<kebab-case-name>.md`.
140
+ 3. **Verify** all files were written successfully.
141
+
142
+ ### Step 8: Update Tasks Index
143
+
144
+ Append a section to `docs/tasks/<plan-id>/index.md`. Mark each task with `- [ ]` (unchecked); the Work skill updates these to `- [x]` as tasks complete.
145
+
146
+ ```markdown
147
+ ## <plan-id> — [Plan Title]
148
+
149
+ - [ ] T01 — [Task title] (`U1`, AC: [criterion]) — `docs/tasks/<plan-id>/T01-<name>.md`
150
+ - [ ] T02 — [Task title] (`U2a`, AC: [criterion]) — `docs/tasks/<plan-id>/T02-<name>.md`
151
+ ```
152
+
153
+ If the index does not exist, create it with a header and the new section. If it exists but is malformed, log a warning and append the section without reformatting existing content.
154
+
155
+ ### Step 9: Return to Orchestrator
156
+
157
+ 1. **Return the task manifest**:
158
+
159
+ ```yaml
160
+ plan-id: YYYY-MM-DD-NNN
161
+ task-count: <N>
162
+ tasks:
163
+ - id: <plan-id>-T01
164
+ path: docs/tasks/<plan-id>/T01-<name>.md
165
+ unit: U1
166
+ acceptance_criterion: "[criterion]"
167
+ priority: P0
168
+ dependencies: []
169
+ - id: <plan-id>-T02
170
+ path: docs/tasks/<plan-id>/T02-<name>.md
171
+ unit: U2a
172
+ acceptance_criterion: "[criterion]"
173
+ priority: P1
174
+ dependencies: [<plan-id>-T01]
175
+ interactionMode: detailed | smart | autopilot
176
+ ```
177
+
178
+ 2. **Inform the Orchestrator** that the Plan workflow is complete. The task files are ready for the Work skill (`work/SKILL.md`) to execute in dependency order.
179
+
180
+ ## Output: Task Artifacts
181
+
182
+ - Verify that **one task file exists per Acceptance Criterion** (never one task for multiple criteria), saved to `docs/tasks/<plan-id>/T<NN>-<name>.md`.
183
+ - Verify that each task carries **exactly one Acceptance Criterion** and **exactly one `files.test` entry** (its own test asserting that criterion).
184
+ - Verify that each task's `## Steps` are ordered **Red → Green → Refactor**, with the failing test written and confirmed before implementation.
185
+ - Verify that task IDs are zero-padded 2 digits matching dependency order, with no gaps.
186
+ - Verify that no task depends on a later task (dependency order is valid).
187
+ - Verify that `docs/tasks/<plan-id>/index.md` has been updated with an unchecked checklist for all tasks.
188
+ - Verify that the task manifest returned to the Orchestrator accurately reflects the saved files.
189
+
190
+ > The Task Artifacts are the handoff to the Work skill. Each task is self-contained around a single Acceptance Criterion and its test — executable without re-reading the full plan.
@@ -0,0 +1,118 @@
1
+ ---
2
+ title: Design Complexity Assessment
3
+ description: Reference for the Design phase. Defines the complexity scoring algorithm across five dimensions, the heuristics for assigning complexity levels, and how complexity maps to interaction-mode pause behavior.
4
+ type: reference
5
+ version: 1.1
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Design Complexity Assessment
10
+
11
+ This file documents the complexity scoring system used by the **Design** phase (Phase 3) to size a solution and decide whether to pause for user confirmation in Smart mode. It defines five scoring dimensions, the complexity-level thresholds, and the mapping to interaction-mode behavior.
12
+
13
+ ## When to Apply
14
+
15
+ Complexity assessment runs at the end of the Design phase, after the approach and implementation units have been drafted but before the artifact is presented or saved. The resulting `complexity` field is written to the Design Artifact and read by the Generate phase to select a plan tier (see [plan-tier-selection.md](plan-tier-selection.md)).
16
+
17
+ ## Scoring Dimensions
18
+
19
+ Score each dimension from 0 to 3, then sum for a total complexity score (0–15).
20
+
21
+ | Dimension | 0 — None | 1 — Low | 2 — Medium | 3 — High |
22
+ | ----------------------- | ----------------------- | ----------------------- | --------------------------------- | --------------------------------- |
23
+ | **Scope Breadth** | Single file | 2–3 files, one module | Multiple modules | Cross-system / cross-repo |
24
+ | **Integration Surface** | No new integrations | One new internal API | Multiple internal or one external | Multiple external / third-party |
25
+ | **Risk Level** | LOW (from research) | MEDIUM (single area) | HIGH (single area) | HIGH (multiple areas) or CRITICAL |
26
+ | **Novelty** | Existing pattern reused | Minor variation | New pattern in familiar domain | New pattern in unfamiliar domain |
27
+ | **Data / Migration** | No data changes | Additive, backward-safe | Schema change with migration path | Destructive or no rollback path |
28
+
29
+ ### Dimension Definitions
30
+
31
+ - **Scope Breadth** — How many files, modules, or systems the change touches. Read from the Implementation Units' `Files` lists.
32
+ - **Integration Surface** — Number and kind of APIs/services the solution must connect to. Pull from the Research Findings `Patterns Found` and `Tech Stack`.
33
+ - **Risk Level** — Inherited from the Research phase `High-Risk Detection`. Do not re-score; copy the value.
34
+ - **Novelty** — Whether the approach reuses an existing local pattern or introduces a new one. Compare the chosen approach against `Patterns Found` confidence levels.
35
+ - **Data / Migration** — Whether data schemas change and whether the change is reversible. Read from the Design's `Operational / Rollout Notes` draft.
36
+
37
+ ## Complexity Level Thresholds
38
+
39
+ Map the total score to a complexity level:
40
+
41
+ ```
42
+ total = sum(scope_breadth, integration_surface, risk_level, novelty, data_migration)
43
+
44
+ if total >= 11:
45
+ complexity = VERY_HIGH
46
+ elif total >= 7:
47
+ complexity = HIGH
48
+ elif total >= 4:
49
+ complexity = MEDIUM
50
+ elif total >= 1:
51
+ complexity = LOW
52
+ else:
53
+ complexity = TRIVIAL
54
+ ```
55
+
56
+ | Level | Score Range | Typical Profile |
57
+ | --------- | ----------- | --------------------------------------------------- |
58
+ | TRIVIAL | 0 | Single-file tweak, no integrations, LOW risk |
59
+ | LOW | 1–3 | Small feature, one module, no migration |
60
+ | MEDIUM | 4–6 | Multi-module feature, one integration, additive |
61
+ | HIGH | 7–10 | Cross-module or external integration, schema change |
62
+ | VERY_HIGH | 11–15 | Cross-system, multiple risks, destructive migration |
63
+
64
+ ## Mapping to Interaction Mode
65
+
66
+ | Mode | Pause Behavior |
67
+ | --------- | ------------------------------------------------------- |
68
+ | Detailed | Always pause; show units and complexity; ask to proceed |
69
+ | Smart | Pause **only** if `complexity = VERY_HIGH` |
70
+ | Autopilot | Never pause; auto-proceed |
71
+
72
+ **Smart mode also pauses if any of these flags are true** (regardless of complexity):
73
+
74
+ - Research phase reported HIGH risk and `patterns_found_count < 3`
75
+ - 3+ learning gaps were identified in the Scope phase
76
+ - The selected approach has no local pattern precedent (Novelty = 3)
77
+
78
+ ## Mapping to Plan Tier
79
+
80
+ Complexity feeds into tier selection in the Generate phase:
81
+
82
+ | Complexity | Default Tier | Rationale |
83
+ | ---------------- | ------------ | ------------------------------------------ |
84
+ | TRIVIAL / LOW | Fast | Short plan; minimal structure needed |
85
+ | MEDIUM | Standard | Full template; phased units; risk table |
86
+ | HIGH / VERY_HIGH | Deep | Full template + alternatives + rollout ops |
87
+
88
+ See [plan-tier-selection.md](plan-tier-selection.md) for the complete tier-selection algorithm, including how complexity combines with risk and user preference.
89
+
90
+ ## Worked Example
91
+
92
+ **Task:** Migrate session storage from in-memory to Redis.
93
+
94
+ | Dimension | Score | Reasoning |
95
+ | ------------------- | ----- | ------------------------------------------------- |
96
+ | Scope Breadth | 2 | Multiple modules: middleware, store, client |
97
+ | Integration Surface | 2 | One external system (Redis) |
98
+ | Risk Level | 2 | HIGH (single area: sessions/auth) |
99
+ | Novelty | 1 | Redis is new to the codebase but pattern is known |
100
+ | Data / Migration | 1 | Additive; sessions expire naturally |
101
+ | **Total** | **8** | **Complexity: HIGH** |
102
+
103
+ Result: In Smart mode, this would **not** pause (HIGH, not VERY_HIGH) unless the secondary flags trigger (e.g., 3+ learning gaps).
104
+
105
+ ## Error Handling
106
+
107
+ | Scenario | Recovery |
108
+ | ---------------------------------------------------------------- | ---------------------------------------- |
109
+ | Risk level missing from Research artifact | Default to MEDIUM (score 2); log warning |
110
+ | Implementation Units not yet drafted | Defer scoring until units exist |
111
+ | Two dimensions conflict (e.g., LOW risk + destructive migration) | Use the higher score; log warning |
112
+ | Score lands exactly on a threshold (e.g., 7) | Round up to the higher level (HIGH) |
113
+
114
+ ## Notes
115
+
116
+ - Complexity is a planning aid, not a precise metric — favor conservative (higher) scoring when uncertain
117
+ - The complexity value must be written to the Design Artifact for the Generate phase to consume
118
+ - If the user overrides the tier in the Generate phase, complexity is preserved for reference but no longer drives tier selection
@@ -0,0 +1,155 @@
1
+ ---
2
+ title: Error Handling & Recovery
3
+ description: Reference for error handling and recovery strategies in the Plan Skill phases. Provides guidance on how to handle missing or malformed artifacts, invalid user input, and other common errors.
4
+ type: reference
5
+ version: 1.2
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Error Handling & Recovery
10
+
11
+ This file documents the error handling and recovery strategies shared across all Plan Skill phases (Scope, Research, Design, Generate, Tasks). Each phase begins with a **Step 0: Verification** that validates the incoming artifact; this reference defines the validation rules, recovery actions, and termination conditions.
12
+
13
+ ## Core Principle
14
+
15
+ **Fail explicitly, never silently.** When an artifact is missing, malformed, or inconsistent, the phase must surface a clear error with a recovery suggestion rather than guessing or proceeding with bad data. Silent failures cascade downstream and produce invalid plans.
16
+
17
+ ## Step 0: Artifact Verification
18
+
19
+ Every phase receives an artifact from the previous phase (or the Orchestrator, for Scope). Step 0 validates the artifact before any work begins.
20
+
21
+ ### Verification Procedure
22
+
23
+ ```
24
+ 1. Confirm the artifact exists and is non-empty
25
+ 2. Confirm the required frontmatter fields are present and well-formed
26
+ 3. Confirm the artifact type matches the expected phase input
27
+ 4. Confirm interactionMode is present and valid (default to "smart" if missing)
28
+ 5. Confirm status field indicates the previous phase completed successfully
29
+ ```
30
+
31
+ ### Required Fields by Artifact Type
32
+
33
+ | Artifact Type | Required Fields | Produced By |
34
+ | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------ |
35
+ | `user-input` | `type`, `timestamp`, `source`, `status`, Task Description, Intended Behavior | Orchestrator |
36
+ | `scope` | `type`, `scope-id`, `domain`, `status`, `interactionMode`, Problem, Intended Behavior, Success Criteria | Scope |
37
+ | `research` | `research-id`, `scope-id`, `status`, `interactionMode`, Patterns Found, High-Risk Detection, Tech Stack | Research |
38
+ | `design` | `design-id`, `scope-id`, `research-id`, `status`, `interactionMode`, `complexity`, `tier_recommended`, Approach, High-Level Technical Design, Implementation Units (each with Acceptance Criteria), Alternative Approaches, Complexity | Design |
39
+ | `plan` | `plan-id`, `type`, `title`, `status`, `tier`, `tier_recommended`, `complexity`, `risk`, `scope-id`, `research-id`, `design-id`, `interactionMode`, `created`, `updated`, `version`, High-Level Design, Implementation Units, Risk Analysis | Generate |
40
+
41
+ ## Error Categories
42
+
43
+ ### Category 1: Missing Artifact
44
+
45
+ The expected input artifact was not provided by the Orchestrator or previous phase.
46
+
47
+ | Trigger | Recovery Action | Terminate? |
48
+ | --------------------------------- | ------------------------------------------------------------- | ------------------ |
49
+ | Artifact object is null/undefined | Ask Orchestrator to re-run previous phase | Yes, after 1 retry |
50
+ | Artifact file path does not exist | Log warning; ask user to locate file or re-run previous phase | No |
51
+ | Artifact file is empty (0 bytes) | Re-run previous phase from its saved context | Yes, after 1 retry |
52
+
53
+ ### Category 2: Malformed Artifact
54
+
55
+ The artifact exists but is missing required fields or has invalid structure.
56
+
57
+ | Trigger | Recovery Action | Terminate? |
58
+ | --------------------------------------------- | ----------------------------------------------------------- | ---------- |
59
+ | Missing required frontmatter field | Re-run previous phase to regenerate artifact | No |
60
+ | `interactionMode` missing or invalid | Default to `smart`; log warning; continue | No |
61
+ | `status` field is `failed` or `pending` | Reject; ask Orchestrator to re-run previous phase | Yes |
62
+ | Artifact `type` does not match expected input | Reject; ask Orchestrator to check phase ordering | Yes |
63
+ | YAML frontmatter has syntax errors | Log error with line number; ask user to fix or re-run phase | No |
64
+
65
+ ### Category 3: Invalid User Input
66
+
67
+ Only applies to the Scope phase (Step 0) when validating the User Input Artifact.
68
+
69
+ | Trigger | Recovery Action | Terminate? |
70
+ | --------------------------------------------------- | ---------------------------------------------------- | ---------- |
71
+ | Task Description empty or > 500 chars | Ask: "What problem are you trying to solve?" | No |
72
+ | Intended Behavior empty or unobservable | Ask: "What should happen after this is implemented?" | No |
73
+ | Context Source is not a valid enum value | Infer from input origin; ask if ambiguous | No |
74
+ | Task Description AND Intended Behavior both missing | Abort; ask user to return with more context | Yes |
75
+
76
+ ### Category 4: File System Errors
77
+
78
+ Errors encountered while saving or reading artifact files.
79
+
80
+ | Trigger | Recovery Action | Terminate? |
81
+ | ------------------------------------------------ | ----------------------------------------------------------------- | ------------------ |
82
+ | Target directory does not exist | Create directory (`mkdir -p`); treat counter as 0; start from 001 | No |
83
+ | Counter directory exists but no files match date | Start counter at 001 | No |
84
+ | File write permission denied | Log error; ask user to check permissions; retry once | Yes, after 1 retry |
85
+ | Index file (`docs/plans/index.md`) missing | Create empty index; append entry | No |
86
+ | Index file locked or corrupted | Log warning; skip index update; continue with save | No |
87
+
88
+ ### Category 5: Interaction Mode Errors
89
+
90
+ Errors related to `interactionMode` propagation.
91
+
92
+ | Trigger | Recovery Action | Terminate? |
93
+ | ---------------------------------------- | ---------------------------------------------------------- | ---------- |
94
+ | Mode missing from incoming artifact | Default to `smart`; log warning; continue | No |
95
+ | Mode value is not in enum | Reject; re-prompt Orchestrator to set valid mode | Yes |
96
+ | User selects "Abort" during confirmation | Stop immediately; inform Orchestrator of abort with reason | Yes |
97
+ | User does not respond (timeout) | Pause; ask user to retry or abort | No |
98
+
99
+ ## Recovery Workflow
100
+
101
+ When a verification failure is detected in Step 0, apply this workflow:
102
+
103
+ ```
104
+ 1. Identify the error category (1-5) from the tables above
105
+ 2. Look up the specific trigger to find the recovery action
106
+ 3. Execute the recovery action:
107
+ - If recovery is "ask user": ask one question with clear options (2–4 concrete choices)
108
+ - If recovery is "re-run previous phase": return to Orchestrator with error context
109
+ - If recovery is "default and continue": apply default, log warning, proceed
110
+ 4. If terminate = Yes: stop and inform Orchestrator with:
111
+ - Error category and trigger
112
+ - Recovery action attempted
113
+ - Reason for termination
114
+ 5. If terminate = No: after recovery, continue to Step 1 of the phase
115
+ ```
116
+
117
+ ## Retry Limits
118
+
119
+ - **Maximum retries per error:** 1
120
+ - **Maximum total retries per phase:** 2
121
+ - After exhausting retries, terminate with a clear error message explaining what failed and suggesting the user re-run the planning workflow from the start or from the last successful phase.
122
+
123
+ ## Error Reporting Format
124
+
125
+ When reporting an error to the Orchestrator or user, use this format:
126
+
127
+ ```yaml
128
+ error:
129
+ phase: scope | research | design | generate | tasks
130
+ step: 0 | 1 | 2 | ...
131
+ category: 1 | 2 | 3 | 4 | 5
132
+ trigger: "[specific trigger description]"
133
+ recovery_attempted: "[action taken]"
134
+ outcome: recovered | terminated
135
+ suggestion: "[next step for the user or Orchestrator]"
136
+ ```
137
+
138
+ ## Cross-Phase Consistency Checks
139
+
140
+ In addition to per-phase verification, the Orchestrator should verify consistency between phases:
141
+
142
+ | Check | Action on Failure |
143
+ | ---------------------------------------------------- | ------------------------------------------- |
144
+ | `scope-id` in research artifact matches scope output | Reject research; re-run from scope |
145
+ | `scope-id` in design artifact matches scope output | Reject design; re-run from research |
146
+ | `plan-id` references the correct design artifact | Reject generate; re-run from design |
147
+ | `interactionMode` is identical across all artifacts | Log warning; use earliest non-default value |
148
+
149
+ ## Notes
150
+
151
+ - All errors and warnings should be logged with a timestamp for debugging
152
+ - When a phase terminates, its saved artifact (if any) should be marked `status: failed`
153
+ - The Orchestrator is responsible for deciding whether to retry the entire workflow or resume from the last successful phase
154
+ - ID assignment and re-use (including recycle-on-edit) is defined in [id-generation.md](id-generation.md); this reference covers only verification and recovery
155
+ - This reference is shared by all five phases; phase-specific error handling (e.g., research's "no patterns found") is documented inline in the respective module
@@ -0,0 +1,61 @@
1
+ ---
2
+ title: External Research Guidance
3
+ description: Guidance for generating targeted external research queries when high-risk areas are detected and external research is recommended.
4
+ type: reference
5
+ version: 1.1
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # External Research Guidance
10
+
11
+ This file documents how to generate targeted external research queries when high-risk areas are detected and external research is recommended.
12
+
13
+ ## When to Run External Research
14
+
15
+ External research is recommended when:
16
+
17
+ - One or more high-risk areas identified (see high-risk-detection.md)
18
+ - Fewer than 3 similar local implementations found
19
+
20
+ ## Generating Targeted Queries
21
+
22
+ Generate specific, actionable queries that include:
23
+
24
+ - **Topic:** The specific area (e.g., "payment gateway", "OAuth2 implementation")
25
+ - **Tech stack:** Relevant technologies (e.g., "Node.js", "Express", "PostgreSQL")
26
+ - **Scope:** Information type (e.g., "best practices", "patterns", "troubleshooting")
27
+ - **Year:** Current year for recent guidance
28
+
29
+ ## Query Templates
30
+
31
+ | Area | Template | Example |
32
+ | -------------- | ----------------------------------------- | ---------------------------------------------- |
33
+ | Security | `[area] patterns [tech-stack] [year]` | `JWT authentication patterns Node.js 2026` |
34
+ | Payments | `[provider] integration [tech-stack]` | `Stripe integration Node.js best practices` |
35
+ | API Design | `[type] design patterns [year]` | `REST API versioning strategies 2026` |
36
+ | Migrations | `[type] migration guide [tech-stack]` | `Database migration PostgreSQL best practices` |
37
+ | Complex Logic | `[algorithm] implementation [tech-stack]` | `Search optimization patterns Node.js` |
38
+ | Infrastructure | `[tech] [deployment] patterns [year]` | `Kubernetes deployment best practices 2026` |
39
+
40
+ ## Executing External Research
41
+
42
+ Use generated queries with:
43
+
44
+ - **Web search:** Use the agent's web search or fetch capabilities with your generated query
45
+ - **Manual research:** GitHub, official docs, blogs, Stack Overflow
46
+ - **Integration:** Some agents may offer specialized research tools — check agent documentation
47
+
48
+ ## Refining Queries
49
+
50
+ | Finding | Strategy |
51
+ | ------------------ | -------------------------------------- |
52
+ | Too many results | Add "best practices" or "production" |
53
+ | Too few results | Broaden or use alternative terminology |
54
+ | Outdated info | Add current year to query |
55
+ | Conflicting advice | Compare approaches side-by-side |
56
+
57
+ ## Notes
58
+
59
+ - Queries should be actionable and specific to the tech stack
60
+ - Use whatever web search or research capabilities are available in your agent environment
61
+ - Capture findings as learnings after research to build organizational knowledge