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,129 @@
1
+ ---
2
+ name: plan
3
+ description: "Create durable implementation plans that can be handed off for execution. Orchestrates a deterministic pipeline of micro-skills: Scope -> Research -> Design -> Generate -> Tasks. No agent dependency, no fallback paths."
4
+ disable-model-invocation: true
5
+ ---
6
+
7
+ # Plan
8
+
9
+ Orchestrates a deterministic pipeline of micro-skills: `Scope -> Research -> Design -> Generate -> Tasks`. No agent dependency, no fallback paths.
10
+
11
+ ## Skill Invocation
12
+
13
+ This skill is invoked by prompting `/plan <task description>`. This skill will run the planning pipeline, producing a final plan artifact and optionally a set of task artifacts, acting as the Orchestrator.
14
+
15
+ ## Interaction Method
16
+
17
+ - Ask the user one structured question at a time (2–4 concrete options) using the agent's interactive question capability; never hardcode a specific tool name.
18
+ - If input is empty, ask: "What would you like to plan? Describe the task or project."
19
+
20
+ Before starting the workflow, ask the user to choose an interaction mode:
21
+
22
+ - **Detailed** — Confirm at each phase transition; inspect artifacts; maximum control. Best for complex/unfamiliar work.
23
+ - **Autopilot** — All phases run automatically; only final outcome reported. Fastest. Best for straightforward work.
24
+ - **Smart** — Phases run automatically; pause only on HIGH-risk operations.
25
+
26
+ Store in the context object:
27
+
28
+ ```yaml
29
+ interactionMode: detailed | smart | autopilot
30
+ ```
31
+
32
+ **Propagation:** `interactionMode` flows into `research`, `design`, and `generate` artifacts; each downstream phase reads it to adjust confirmation behaviour (detailed = pause every transition; autopilot = run all; smart = pause only on HIGH-risk).
33
+
34
+ ## Orchestration Implementation
35
+
36
+ Each phase runs sequentially: the orchestrator calls the module, receives the output artifact, validates it with a quality gate, and passes it to the next phase.
37
+
38
+ ### INPUT
39
+
40
+ - Receives a context object (task description, goals, constraints, references, previous plans) from the user, a saved prompt, a document, or a combination.
41
+ - **If no context is provided**, ask: "What would you like to plan? Describe the task or project."
42
+ - Output: [User Input Artifact](references/templates/artifacts/user-input.md)
43
+
44
+ ### Pre-Flight Check
45
+
46
+ Before starting the planning pipeline, the orchestrator verifies that required folders exist:
47
+
48
+ - `docs/plans/` — must exist for saving final plan
49
+ - `docs/tasks/` — must exist if task generation is enabled
50
+
51
+ **Self-Healing:** If missing, the orchestrator automatically creates these folders. This allows the plan skill to run even if `arreio-init` wasn't explicitly run.
52
+
53
+ ### Phases
54
+
55
+ | Phase | Module | Output Artifact |
56
+ | ----- | -------------------------------------- | ---------------------------------------------------------------------------------- |
57
+ | 1 | [Scope](modules/scope.md) | [Scoped context](references/templates/artifacts/scoped-context.md) |
58
+ | 2 | [Research](modules/research.md) | [Research findings](references/templates/artifacts/research-findings.md) |
59
+ | 3 | [Design](modules/design.md) | [Design with unit decomposition](references/templates/artifacts/design.md) |
60
+ | 4 | [Generate](modules/generate.md) | [Final plan](references/templates/artifacts/final-plan.md) saved to `docs/plans/` |
61
+ | 5 | [Tasks](modules/tasks.md) _(optional)_ | [Task list](references/templates/artifacts/task.md) saved to `docs/tasks/plan-id/` |
62
+
63
+ **Phase 5** is optional; ask the user 'Generate individual task files?' before running, even in Autopilot. If user declines, planning is complete.
64
+
65
+ ### Quality Gates
66
+
67
+ Between phases, the orchestrator validates the output artifact before passing it to the next phase:
68
+
69
+ 1. **Schema validation** — required fields present and well-formed (see [error-handling.md](references/error-handling.md) for the per-type field list).
70
+ 2. **Cross-phase consistency** — IDs (`scope-id`, `research-id`, `design-id`, `plan-id`) match the upstream artifacts; `interactionMode` is identical across artifacts.
71
+ 3. **Status check** — the artifact's `status` is `complete` (not `pending` or `failed`).
72
+ 4. **Tier/complexity coherence** (after Design) — the `tier_recommended` is consistent with `complexity` and `risk_level` per [plan-tier-selection.md](references/plan-tier-selection.md).
73
+
74
+ If a gate fails, the orchestrator returns to the producing phase with the error context (per the recovery workflow in [error-handling.md](references/error-handling.md)).
75
+
76
+ ### Index Registration
77
+
78
+ Each skill module is responsible for registering its own outputs:
79
+
80
+ | Module | Registers To | Artifact Format |
81
+ | -------- | ------------------------------- | ------------------------------------------------ |
82
+ | Generate | `docs/plans/index.md` | Link + brief summary to final plan file |
83
+ | Tasks | `docs/tasks/<plan-id>/index.md` | Folder creation + task links (created on-demand) |
84
+
85
+ **Who updates what:**
86
+
87
+ - **Generate phase:** Creates `docs/plans/index.md` if missing; appends new plan entry with timestamp and link
88
+ - **Tasks phase:** Creates `docs/tasks/<plan-id>/` folder and `docs/tasks/<plan-id>/index.md` if missing; populates with task file links and metadata
89
+
90
+ ### FINAL OUTPUT
91
+
92
+ - **Plan file:** Saved to `docs/plans/YYYY-MM-DD-NNN-<kebab-case-name>.md`
93
+ - **Registration:** Generate phase appends an entry to `docs/plans/index.md` linking the new plan
94
+ - **Task files (optional):** Saved to `docs/tasks/<plan-id>/TASK-NNN-<kebab-case-name>.md`
95
+ - **Registration:** Tasks phase creates `docs/tasks/<plan-id>/index.md` and registers task file links there
96
+ - Ready for the Work skill to consume via `docs/tasks/<plan-id>/index.md`
97
+
98
+ ## References
99
+
100
+ The orchestrator and modules share these reference files:
101
+
102
+ | Reference | Used By |
103
+ | ----------------------------------------------------------------------------- | -------------------------------- |
104
+ | [error-handling.md](references/error-handling.md) | All phases (Step 0 verification) |
105
+ | [id-generation.md](references/id-generation.md) | Scope, Research, Design, Generate (ID assignment) |
106
+ | [interaction-mode-propagation.md](references/interaction-mode-propagation.md) | All phases (Step N confirmation) |
107
+ | [learnings-gate-logic.md](references/learnings-gate-logic.md) | Scope (Step 4) |
108
+ | [high-risk-detection.md](references/high-risk-detection.md) | Research (Step 2) |
109
+ | [external-research-guidance.md](references/external-research-guidance.md) | Research (Step 4) |
110
+ | [design-complexity-assessment.md](references/design-complexity-assessment.md) | Design (Step 4) |
111
+ | [plan-tier-selection.md](references/plan-tier-selection.md) | Generate (Step 1) |
112
+ | [task-slicing-rules.md](references/task-slicing-rules.md) | Tasks (Steps 2–3) |
113
+
114
+ Artifact templates live in [references/templates/artifacts/](references/templates/artifacts/).
115
+
116
+ ## Core Principles
117
+
118
+ - **Deterministic Pipeline:** Phases always execute in sequence (no agent switching, no fallback paths).
119
+ - **Error Handling:** Fail explicitly, not silently; each phase has clear error handling with recovery suggestions.
120
+ - **Focus on Decisions:** Capture approach, structure, risks, and sequencing (not code simulation).
121
+ - **Right-Size:** Small tasks → short plans; complex work → more structure.
122
+ - **Separate Planning from Execution:** NEVER simulate implementation during planning.
123
+ - **Be Concrete:** Use specific files, components, and dependencies.
124
+ - **Stay Portable:** Use repository-relative paths only.
125
+ - **Transparent Artifacts:** Each phase produces an explicit output artifact for the next phase.
126
+ - **Interaction Mode Propagation:** `interactionMode` is read at the start of each subsequent phase and determines whether confirmation steps execute.
127
+ - **Single Source of Truth:** This skill defines all its own rules; it does not depend on any external agent rule file.
128
+ - **Behavior-Described, Tool-Agnostic:** Steps describe required capabilities ("search the codebase", "ask the user one question"), not specific tool names; each agent maps to its native tools.
129
+ - **Test-Driven Tasks:** One Acceptance Criterion per task; one test per AC; 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).
@@ -0,0 +1,140 @@
1
+ ---
2
+ title: Design
3
+ description: Design the solution based on the scoped context and research findings. Decomposes the approach into phased implementation units, assesses complexity, and produces a Design Artifact for the Generate phase.
4
+ type: module
5
+ version: 1.1
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Phase 3 - Design
10
+
11
+ **Purpose:** Third step in the planning workflow. Reads the Scoped Context and Research Findings, selects an approach, decomposes it into phased implementation units, assesses complexity, and returns a [Design Artifact](../references/templates/artifacts/design.md) that the Generate phase renders into a final plan.
12
+
13
+ ## Workflow
14
+
15
+ This is the Phase 3 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 inputs:
20
+
21
+ 1. **Scoped Context Artifact** with `scope-id`, `domain`, `Problem`, `Intended Behavior`, `Success Criteria`.
22
+ 2. **Research Findings Artifact** with `research-id`, `Patterns Found`, `High-Risk Detection` (with `risk_level`), `Tech Stack`.
23
+ 3. `interactionMode` present (default to `smart` if missing; log warning).
24
+ 4. Cross-phase consistency: the research artifact's `scope-id` matches the scope output.
25
+
26
+ ### Step 1: Approach Selection
27
+
28
+ 1. **Read the Scoped Context** to understand the problem, intended behavior, and success criteria.
29
+ 2. **Read the Research Findings** to identify available patterns, confidence levels, high-risk areas, and technical constraints.
30
+ 3. **Draft 2–3 candidate approaches** that satisfy the success criteria. Base each on:
31
+ - Patterns found in the codebase (prefer HIGH-confidence patterns when available)
32
+ - Tech stack constraints from research
33
+ - Risk level and whether external research was conducted
34
+ 4. **Evaluate each approach** against:
35
+ - Fit with success criteria
36
+ - Pattern reuse (higher confidence = lower risk)
37
+ - Complexity (fewer integration points = simpler)
38
+ - Reversibility (can it be rolled back?)
39
+ 5. **Select the recommended approach.** If no clear winner emerges, present the top 2 to the user in one question and let them choose.
40
+ 6. **Record the selected approach** as a 1–3 sentence summary in the Design Artifact's `Approach` field, including why it fits the context and research.
41
+
42
+ ### Step 2: High-Level Technical Design
43
+
44
+ Produce a **directional** design representation (NOT an implementation specification). Choose ONE of:
45
+
46
+ - **Mermaid diagram** — Use `sequenceDiagram`, `flowchart`, or `graph` to show component interaction. Best for multi-actor flows.
47
+ - **Pseudo-code sketch** — High-level steps in plain language. Best for algorithmic/logic-heavy work.
48
+ - **Data-flow map** — ASCII arrows showing how data moves through the system. Best for pipeline/ETL work.
49
+
50
+ The design must:
51
+
52
+ - Reference real components, files, or services from the research findings (be concrete)
53
+ - Show the "happy path" only; edge cases go in the Implementation Units
54
+ - Avoid implementation details (naming, abstractions, code structure) — those are decided during execution
55
+
56
+ > **Note:** This is directional guidance for review, not an implementation specification to copy. The implementation phase will determine specific naming, abstractions, and code structure.
57
+
58
+ ### Step 3: Implementation Unit Decomposition
59
+
60
+ Break the approach into **phased implementation units**. Each unit is a coherent, testable chunk of work.
61
+
62
+ 1. **Define phases** based on dependency layers:
63
+ - **Phase 1: Foundation** — Units with no dependencies (infra, interfaces, schema)
64
+ - **Phase 2: Integration** — Units depending on Phase 1 (wiring, middleware, adapters)
65
+ - **Phase 3: Rollout** (if applicable) — Units for migration, feature flags, cutover
66
+
67
+ 2. **For each unit, record:**
68
+ - **Unit ID:** `U1`, `U2`, ... (never renumber; preserve across iterations)
69
+ - **Name:** Short, descriptive
70
+ - **Goal:** What this unit accomplishes (1 sentence)
71
+ - **Dependencies:** Which unit IDs must complete first (or "None")
72
+ - **Files:** `Create`, `Modify`, and `Test` paths — repository-relative, in backtick code formatting
73
+ - **Acceptance Criteria:** A list of one or more checkable criteria. **Each criterion later becomes exactly one task and one test** (see Tasks phase). Phrase each as a single, verifiable outcome — not a bundle.
74
+ - **Test Scenarios:** `[Scenario]: [Input -> Expected Outcome]` (required for Phase 1–2 units; optional for rollout-only)
75
+
76
+ 3. **Decomposition check:** Units are sized so the Tasks phase can honor **one Acceptance Criterion per task**. If a unit's criteria would need > 5 files or > 1 day, split that unit (or its criteria) finer; never let a single criterion exceed one task (see [task-slicing-rules.md](../references/task-slicing-rules.md)).
77
+
78
+ 4. **Dependency check:** Verify no cycles exist. A unit may only depend on units in earlier phases. If a cycle is detected, restructure the units.
79
+
80
+ ### Step 4: Complexity Assessment
81
+
82
+ Score the design across five dimensions (0–3 each) and compute the complexity level. For the scoring table, dimension definitions, and threshold mapping, see **[design-complexity-assessment.md](../references/design-complexity-assessment.md)**.
83
+
84
+ 1. Score each dimension:
85
+ - `scope_breadth` — from the Implementation Units' file lists
86
+ - `integration_surface` — from Research Findings' patterns and tech stack
87
+ - `risk_level` — **inherited** from Research Findings (do not re-score)
88
+ - `novelty` — compare chosen approach against `Patterns Found` confidence
89
+ - `data_migration` — from the design's operational/rollout notes draft
90
+ 2. Sum the scores (0–15).
91
+ 3. Map to complexity level: `TRIVIAL | LOW | MEDIUM | HIGH | VERY_HIGH`.
92
+ 4. Record all five scores, the total, and the complexity level in the Design Artifact.
93
+
94
+ ### Step 5: Alternative Approaches
95
+
96
+ Document the approaches considered but not selected, with rejection rationale.
97
+
98
+ - **TRIVIAL / LOW complexity:** At least 1 alternative (may be brief).
99
+ - **MEDIUM complexity:** At least 1 alternative with rationale.
100
+ - **HIGH / VERY_HIGH complexity:** At least 2 alternatives with side-by-side rationale.
101
+
102
+ Format: `**[Approach Name]**: [Description] → **Rejected because:** [Rationale]`
103
+
104
+ ### Step 6: Learnings and Gaps Update
105
+
106
+ 1. **Carry forward** the `Related Learnings` and `Learning Gaps` from the Scoped Context.
107
+ 2. **Add new learnings** discovered during design (e.g., a pattern confirmed or refuted).
108
+ 3. **Add new gaps** the design revealed (e.g., "No learning on Redis failover in production").
109
+ 4. Update both lists in the Design Artifact.
110
+
111
+ ### Generate the Design Artifact
112
+
113
+ 1. **Assign a `design-id`** per [id-generation.md](../references/id-generation.md) (format `YYYY-MM-DD-NNN-design`, saved to `docs/plans/.design/`). Reuse it if the user later picks **Edit & Retry**.
114
+
115
+ 2. Produce a **Design Artifact** block (as markdown) following the schema in [design.md](../references/templates/artifacts/design.md).
116
+ - Include the generated `design-id`, inherited `scope-id` and `research-id`, `interactionMode`, `complexity`, and `tier_recommended` (derived from complexity per [plan-tier-selection.md](../references/plan-tier-selection.md)).
117
+
118
+ ### Step 7: Present, Confirm, and Save
119
+
120
+ Apply the **[phase confirmation behavior](../references/interaction-mode-propagation.md)** for the current `interactionMode`, using these design-specific **Smart pause triggers**:
121
+
122
+ - `complexity = VERY_HIGH`, or
123
+ - Research reported HIGH risk with `patterns_found_count < 3`, or
124
+ - 3+ learning gaps carried from Scope, or
125
+ - The selected approach has no local pattern precedent (Novelty = 3).
126
+
127
+ - **Detailed:** present the Design Artifact and ask one question with options *(1) Proceed to Generate, (2) Edit & Retry, (3) Abort*. On **Edit & Retry**, loop back through Steps 1–6 reusing the `design-id`. On **Abort**, stop and inform the Orchestrator.
128
+ - **Smart:** pause only when a pause trigger above is true; otherwise auto-proceed.
129
+ - **Autopilot:** auto-proceed (no confirmation).
130
+
131
+ Then save the artifact to `docs/plans/.design/<design-id>.md` (ensure `interactionMode`, `complexity`, and `tier_recommended` are included) and return it, with the `interactionMode` value, to the Orchestrator for the transition to Phase 4 (Generate).
132
+
133
+ ## Output: Design Artifact
134
+
135
+ - Verify that the Design Artifact is complete and valid, containing all required fields: `design-id`, `scope-id`, `research-id`, `interactionMode`, `complexity`, `tier_recommended`, Approach, High-Level Technical Design, Implementation Units (each with Acceptance Criteria), Complexity Assessment, Alternative Approaches, Related Learnings, and Learning Gaps.
136
+ - Verify that the `complexity` value matches the threshold mapping from the five dimension scores.
137
+ - Verify that `tier_recommended` is consistent with the complexity and risk level per [plan-tier-selection.md](../references/plan-tier-selection.md).
138
+ - Verify that the artifact is saved to `docs/plans/.design/<design-id>.md` for future reference or reuse.
139
+
140
+ > Pass the design artifact to `generate` (Phase 4) for final plan generation.
@@ -0,0 +1,156 @@
1
+ ---
2
+ title: Generate
3
+ description: Render the final plan from the Design Artifact by selecting a tier, filling the plan template, and saving it to docs/plans/. Produces a Final Plan Artifact for the optional Tasks phase.
4
+ type: module
5
+ version: 1.1
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Phase 4 - Generate
10
+
11
+ **Purpose:** Fourth step in the planning workflow. Reads the Design Artifact, selects a plan tier (Fast/Standard/Deep) based on complexity and risk, renders the final plan from the [Final Plan template](../references/templates/artifacts/final-plan.md), and saves it to `docs/plans/`. Returns a [Final Plan Artifact](../references/templates/artifacts/final-plan.md) that the optional Tasks phase consumes.
12
+
13
+ ## Workflow
14
+
15
+ This is the Phase 4 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 **Design Artifact**. Specifically verify:
20
+
21
+ 1. The Design Artifact exists and contains `design-id`, `scope-id`, `research-id`, `interactionMode`, `complexity`, `tier_recommended`, `Approach`, `High-Level Technical Design`, and `Implementation Units`.
22
+ 2. The `complexity` field is one of: `TRIVIAL`, `LOW`, `MEDIUM`, `HIGH`, `VERY_HIGH`.
23
+ 3. The `interactionMode` is present and valid (default to `smart` if missing; log warning).
24
+ 4. Cross-phase consistency: the `scope-id` and `research-id` match the upstream artifacts.
25
+
26
+ ### Step 1: Tier Selection
27
+
28
+ Select the plan tier based on complexity, risk, and user preference. For the full algorithm, risk floor rules, and tier section requirements, see **[plan-tier-selection.md](../references/plan-tier-selection.md)**.
29
+
30
+ 1. **Read inputs:**
31
+ - `complexity` from the Design Artifact
32
+ - `risk_level` from the Research Findings (carried via the Design Artifact's complexity assessment)
33
+ - `tier_recommended` from the Design Artifact (the algorithm's suggestion)
34
+
35
+ 2. **Determine user preference:**
36
+ - In **Detailed** mode: Ask the user which tier they want, presenting the recommendation. Options: `Fast`, `Standard`, `Deep`, `Auto`.
37
+ - In **Smart** mode: Auto-select, unless a pause trigger fires (Deep tier, preference conflicts with risk floor, or CRITICAL risk). If paused, ask the user.
38
+ - In **Autopilot** mode: Set `user_preference = auto`; never ask.
39
+
40
+ 3. **Apply the selection algorithm** (see [plan-tier-selection.md](../references/plan-tier-selection.md)):
41
+ - Start from the complexity-driven default tier.
42
+ - Upgrade if risk warrants it (respect the risk floor).
43
+ - Honor user preference unless it violates the risk floor.
44
+
45
+ 4. **Record the selected tier** as `tier` and the algorithm's recommendation as `tier_recommended` (for audit when the user overrides).
46
+
47
+ ### Step 2: Plan Rendering
48
+
49
+ Render the final plan from the [Final Plan template](../references/templates/artifacts/final-plan.md), including only the sections required by the selected tier.
50
+
51
+ 1. **Assemble frontmatter:**
52
+
53
+ ```yaml
54
+ plan-id: YYYY-MM-DD-NNN
55
+ type: plan
56
+ title: "[Plan title]"
57
+ status: complete
58
+ tier: fast | standard | deep
59
+ tier_recommended: fast | standard | deep
60
+ complexity: TRIVIAL | LOW | MEDIUM | HIGH | VERY_HIGH
61
+ risk: Low | Medium | High | Critical
62
+ scope-id: YYYY-MM-DD-NNN-scope
63
+ research-id: YYYY-MM-DD-NNN-research
64
+ design-id: YYYY-MM-DD-NNN-design
65
+ interactionMode: detailed | smart | autopilot
66
+ created: YYYY-MM-DD
67
+ updated: YYYY-MM-DD
68
+ version: 1.0
69
+ ```
70
+
71
+ 2. **Render sections per tier** (see [plan-tier-selection.md](../references/plan-tier-selection.md) for the full section list):
72
+
73
+ | Section | Fast | Standard | Deep |
74
+ | ----------------------------- | :--: | :------: | :--: |
75
+ | Overview | ✅ | ✅ | ✅ |
76
+ | High-Level Technical Design | ✅ | ✅ | ✅ |
77
+ | Implementation Units (Phased) | ✅ | ✅ | ✅ |
78
+ | Alternative Approaches | ➖ | ✅ | ✅ |
79
+ | Risk Analysis & Mitigation | ✅ | ✅ | ✅ |
80
+ | Operational / Rollout Notes | ➖ | ✅ | ✅ |
81
+ | Related Learnings | ✅ | ✅ | ✅ |
82
+ | Learning Gaps | ➖ | ✅ | ✅ |
83
+
84
+ Legend: ✅ required, ➖ optional (skip if not applicable).
85
+
86
+ 3. **Carry forward content from the Design Artifact:**
87
+ - `Approach` → Overview
88
+ - `High-Level Technical Design` → High-Level Technical Design
89
+ - `Implementation Units` → Implementation Units (Phased)
90
+ - `Alternative Approaches` → Alternative Approaches Considered
91
+ - `Related Learnings` → Related Learnings
92
+ - `Learning Gaps` → Learning Gaps
93
+
94
+ 4. **Build the Risk Analysis table** from the Research Findings' high-risk detection and the Design's complexity:
95
+ - Each risk row: `| [Specific risk] | High/Medium | [Concrete mitigation] |`
96
+ - Fast tier: 1–2 rows (brief)
97
+ - Standard tier: full table covering all detected high-risk areas
98
+ - Deep tier: full table with impact ratings + rollback plan
99
+
100
+ 5. **Build Operational / Rollout Notes** (Standard/Deep only) from the Design's rollout units:
101
+ - Feature flags, monitoring, data migration, rollback plan, performance baseline
102
+ - Skip the section entirely if not applicable (Fast tier, or no rollout units)
103
+
104
+ 6. **Right-size:** Per Plan Skill core principles — small tasks → short plans; complex work → more structure. Do not pad a Fast plan with empty sections; do not omit required sections from a Deep plan.
105
+
106
+ ### Step 3: Plan ID Generation
107
+
108
+ 1. **Assign a `plan-id`** per [id-generation.md](../references/id-generation.md) (format `YYYY-MM-DD-NNN`). Reuse it if the user later picks **Edit & Retry**.
109
+ 2. **Derive the plan filename** from the plan title (lowercase, hyphens, no stopwords): `docs/plans/YYYY-MM-DD-NNN-<kebab-case-name>.md`.
110
+
111
+ ### Step 4: Present and Confirm
112
+
113
+ Apply the **[phase confirmation behavior](../references/interaction-mode-propagation.md)** for the current `interactionMode`, using these generate-specific **Smart pause triggers**:
114
+
115
+ - The selected tier is `Deep`, or
116
+ - The user's tier preference conflicts with the risk floor, or
117
+ - Research reported CRITICAL risk (Security or Payments).
118
+
119
+ - **Detailed:** present the assembled Final Plan (in memory) and ask one question with options *(1) Proceed to Tasks, (2) Edit & Retry, (3) Skip Tasks, (4) Abort*.
120
+ - **Smart:** pause only when a pause trigger above is true; otherwise auto-proceed.
121
+ - **Autopilot:** auto-proceed (no confirmation); the Tasks phase still always asks the user before writing files.
122
+
123
+ Map each answer to its action so save+index **never run before the decision**:
124
+
125
+ | Answer | Action |
126
+ | --- | --- |
127
+ | **Proceed to Tasks** | Run Step 5, then return with `continue-to-tasks: true`. |
128
+ | **Skip Tasks** | Run Step 5, then return with `continue-to-tasks: false`. |
129
+ | **Edit & Retry** | Loop back through Steps 1–3 reusing the `plan-id` (save+index have not run yet). |
130
+ | **Abort** | Stop; inform the Orchestrator; do not save. |
131
+
132
+ ### Step 5: Assemble, Save, and Register
133
+
134
+ Run this step only after confirmation (or any auto-proceed path); never on **Abort** or a pending **Edit & Retry**.
135
+
136
+ 1. **Assemble** the complete plan — frontmatter (Step 2.1) + rendered sections (Step 2.2–2.6) — with `plan-id` set to the assigned id.
137
+ 2. **Save** (write or overwrite) the plan to `docs/plans/YYYY-MM-DD-NNN-<kebab-case-name>.md`.
138
+ 3. **Register** in `docs/plans/index.md`. **Insert or replace** the row by `plan-id` (idempotent on Edit & Retry) — never blind-append. If the index does not exist, create it with a header row. Row format:
139
+
140
+ ```markdown
141
+ | [YYYY-MM-DD-NNN](YYYY-MM-DD-NNN-<kebab-case-name>.md) | [Plan Title] | [tier] | [tier_recommended] | [complexity] | [risk] | ready |
142
+ ```
143
+
144
+ ### Step 6: Return to Orchestrator
145
+
146
+ Return the Final Plan Artifact to the Orchestrator — `path`, `plan-id`, `tier`, `tier_recommended`, `interactionMode`, and `continue-to-tasks` (`true` if the user chose Proceed to Tasks, `false` on Skip). The Orchestrator continues to Phase 5 (Tasks) when `continue-to-tasks: true`, or marks the plan complete otherwise.
147
+
148
+ ## Output: Final Plan Artifact
149
+
150
+ - Verify that the Final Plan is complete and valid, containing all required frontmatter fields (`plan-id`, `type`, `title`, `status`, `tier`, `tier_recommended`, `complexity`, `risk`, `scope-id`, `research-id`, `design-id`, `interactionMode`, `created`, `updated`, `version`) and all tier-required sections.
151
+ - Verify that all file paths in the plan are repository-relative (never absolute) and wrapped in backtick code formatting.
152
+ - Verify that `## Related Learnings` is present and references `docs/learn/index.md` entries (or states "No relevant learnings found").
153
+ - Verify that `## Learning Gaps` is present (may be empty).
154
+ - Verify that the plan is saved to `docs/plans/YYYY-MM-DD-NNN-<kebab-case-name>.md` and registered in `docs/plans/index.md`.
155
+
156
+ > The Final Plan is the primary deliverable of the Plan Skill. Pass it to `tasks` (Phase 5, optional) for task slicing, or mark the plan as complete if the user declines tasks.
@@ -0,0 +1,122 @@
1
+ ---
2
+ title: Research
3
+ description: Research the task and gather relevant information, requirements, and constraints. Produces a Research Findings Artifact for downstream phases.
4
+ type: module
5
+ version: 1.1
6
+ timestamp: "2026-08-07"
7
+ ---
8
+
9
+ # Phase 2 - Research
10
+
11
+ **Purpose:** Second step in the planning workflow. Performs local codebase research, detects high-risk areas, and determines if external research is needed. Returns [research findings](../references/templates/artifacts/research-findings.md) that inform the design phase.
12
+
13
+ ## Workflow
14
+
15
+ This is the Phase 2 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 **Scoped Context Artifact** from Scope carrying `scope-id`, `domain`, `Problem`, `Intended Behavior`, `Success Criteria`, and `interactionMode`.
20
+
21
+ ### Step 1: Local Pattern Discovery
22
+
23
+ 1. **Read the scoped context** to understand the task and extract key terms (domain, feature, technology area).
24
+
25
+ 2. **Detect tech stack** from config files in repository root:
26
+ - Check for: `package.json` (Node.js), `pyproject.toml` (Python), `go.mod` (Go), `Cargo.toml` (Rust), `Gemfile` (Ruby), `composer.json` (PHP), `pom.xml` (Java), `build.gradle` (Java/Kotlin)
27
+ - Record detected tech stack and versions for Step 5
28
+ - If multiple tech stacks detected, prioritize primary language
29
+ - **If NO config files match:** Record "Unknown/Multi-language" and proceed to Step 3 using generic search queries (e.g., "architecture", "pattern", "implementation") instead of tech-specific table. Note: This may result in broader matches and lower confidence.
30
+
31
+ 3. **Define tech-stack-specific search queries** based on detected stack and task domain:
32
+
33
+ | Tech Stack | Example Query (Auth Pattern) | Example Query (API Pattern) |
34
+ | ---------- | -------------------------------------------------- | --------------------------------------------- |
35
+ | Node.js | "middleware", "passport", "jwt", "express auth" | "router", "express", "endpoint", "middleware" |
36
+ | Python | "decorator", "authenticate", "middleware", "flask" | "route", "flask", "endpoint", "blueprint" |
37
+ | Go | "middleware", "handler", "auth", "gin" | "handler", "route", "gin", "endpoint" |
38
+ | Rust | "middleware", "guard", "auth", "actix" | "handler", "route", "actix", "endpoint" |
39
+ | Java | "filter", "interceptor", "security", "spring" | "controller", "endpoint", "spring", "mapping" |
40
+
41
+ 4. **Search in two phases** (hybrid approach):
42
+
43
+ **Phase A — Pattern search (literal):**
44
+ - Search common directories: `src/`, `app/`, `lib/`, `services/`, `api/`, `controllers/`, `handlers/`
45
+ - Use tech-stack-specific queries from table above
46
+ - Also search for: `architecture.md`, `design.md`, `ARCHITECTURE.md`, `DESIGN.md` at repo root and in `docs/`, `design/`, `architecture/` subdirectories
47
+ - **Collect all unique file paths found** (count across all Phase A searches; deduplicate)
48
+ - Record total count and note which queries yielded matches
49
+
50
+ **Phase B — Pattern gap detection (meaning-based, conditional):**
51
+ - **Decision rule:** If Phase A found fewer than 3 unique file paths, proceed to Phase B
52
+ - Run a meaning-based search using the task description as the query
53
+ - Example: "How is authentication implemented in this codebase?" or "Where are API endpoints defined?"
54
+ - Captures conceptual patterns missed by literal pattern search
55
+ - **If Phase A found 3+ files:** Skip Phase B; proceed to Step 5 with existing matches
56
+
57
+ 5. **Count confidence levels** based on total unique file matches:
58
+ - **HIGH:** 3 or more files with pattern examples
59
+ - **MEDIUM:** 1–2 file examples found
60
+ - **LOW (or 0):** No pattern examples in codebase
61
+
62
+ 6. **For each pattern found, record:**
63
+ - File path(s)
64
+ - Pattern name and brief description
65
+ - Confidence level (HIGH/MEDIUM/LOW)
66
+ - Relevant code snippet or line range (if available)
67
+
68
+ 7. **Output:** Compile patterns found into `Patterns Found` section of Research Findings Artifact with confidence levels.
69
+
70
+ ### Step 2: High-Risk Area Detection
71
+
72
+ - Scan the task description and scoped context for high-risk keywords across six areas: Security, Payments, APIs, Migrations, Complex Logic, and Infrastructure.
73
+ - For details on the risk keyword table, area definitions, and heuristics for assigning risk levels, see **[high-risk-detection.md](../references/high-risk-detection.md)**.
74
+
75
+ ### Step 3: External Research Decision
76
+
77
+ 1. Look up the external-research decision in the **risk × patterns matrix** in [high-risk-detection.md](../references/high-risk-detection.md) ("Mapping to Research Decision") using the detected **risk level** (Step 2) and the **patterns found count** (Step 1).
78
+ 2. If the matrix returns "Recommend external": provide specific web search guidance (Step 4). If it returns "Skip external", record `External Research: skipped` and proceed to Step 5.
79
+ 3. If it returns "Optional external": provide guidance only when interaction is detailed/smart or risk is HIGH/CRITICAL.
80
+
81
+ ### Step 4: External Research Guidance (if needed)
82
+
83
+ Generate targeted web search queries when external research is recommended.
84
+ For query templates, formatting guidance, and examples for each high-risk area, see **[external-research-guidance.md](../references/external-research-guidance.md)**.
85
+
86
+ ### Step 5: Technical Constraints Gathering
87
+
88
+ 1. Document all technical constraints found:
89
+ - Framework and language versions from config files
90
+ - Performance requirements or implications
91
+ - Compatibility notes (e.g., "must support IE11", "must work with existing auth")
92
+ - Deployment constraints (e.g., "must run on AWS Lambda")
93
+ - Integration constraints (e.g., "must use existing logging framework")
94
+
95
+ ### Step 6: Generate the Research Findings Artifact
96
+
97
+ 1. **Assign a `research-id`** per [id-generation.md](../references/id-generation.md) (format `YYYY-MM-DD-NNN-research`, saved to `docs/plans/.research/`). Reuse it if the user later picks **Edit & Retry**.
98
+
99
+ 2. Produce a **Research Findings Artifact** block (as markdown) following the schema in [research-findings.md](../references/templates/artifacts/research-findings.md):
100
+ - Include the generated `research-id` and the inherited `scope-id`.
101
+ - Write a 2–3 sentence **Findings Summary** overview of the Patterns Found, risk level, and constraints.
102
+
103
+ ### Step 7: Present, Confirm, and Save
104
+
105
+ Apply the **[phase confirmation behavior](../references/interaction-mode-propagation.md)** for the current `interactionMode`, using these research-specific **Smart pause triggers**:
106
+
107
+ - Risk level is HIGH or CRITICAL **and** fewer than 3 patterns found (external research recommended), or
108
+ - Zero patterns found in the codebase.
109
+
110
+ - **Detailed:** present the Research Findings Artifact and ask one question with options *(1) Proceed to Design, (2) Edit & Retry, (3) Abort*. On **Edit & Retry**, loop back through Steps 1–6 reusing the `research-id`. On **Abort**, stop and inform the Orchestrator.
111
+ - **Smart:** pause only when a pause trigger above is true; otherwise auto-proceed.
112
+ - **Autopilot:** auto-proceed (no confirmation).
113
+
114
+ On any proceed/skip path: save the artifact to `docs/plans/.research/<research-id>.md` (ensure `interactionMode` is included), then return the artifact and `interactionMode` to the Orchestrator for the transition to Phase 3 (Design).
115
+
116
+ ## Output: Research Findings Artifact
117
+
118
+ - Verify that the Research Findings 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.
119
+ - Verify that the `interactionMode` value is set correctly based on the user's selection in the Orchestrator skill.
120
+ - Verify that the artifact is saved to `docs/plans/.research/<research-id>.md` for future reference or reuse.
121
+
122
+ > Pass the research findings to `design` (Phase 3) for the design phase.