@trycore/spec-build-harness 0.1.0

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 (92) hide show
  1. package/.claude-plugin/marketplace.json +21 -0
  2. package/.claude-plugin/plugin.json +28 -0
  3. package/GOVERNANCE.md +48 -0
  4. package/INSTALL.md +295 -0
  5. package/METODOLOGIA.md +360 -0
  6. package/README.md +130 -0
  7. package/VERSION +1 -0
  8. package/agents/build/api-contract-tester.md +32 -0
  9. package/agents/build/build-orchestrator.md +50 -0
  10. package/agents/build/change-epic-coherence.md +41 -0
  11. package/agents/build/coherence-three-way.md +35 -0
  12. package/agents/build/data-consistency-checker.md +48 -0
  13. package/agents/build/dor-dod-gatekeeper.md +46 -0
  14. package/agents/build/security-reviewer.md +46 -0
  15. package/agents/build/simple-design-reviewer.md +33 -0
  16. package/agents/build/stack-guardian.md +41 -0
  17. package/agents/build/ux-krug-reviewer.md +33 -0
  18. package/commands/build/onboard.md +136 -0
  19. package/commands/opsx/apply.md +152 -0
  20. package/commands/opsx/archive.md +157 -0
  21. package/commands/opsx/bulk-archive.md +242 -0
  22. package/commands/opsx/continue.md +114 -0
  23. package/commands/opsx/explore.md +174 -0
  24. package/commands/opsx/ff.md +94 -0
  25. package/commands/opsx/new.md +69 -0
  26. package/commands/opsx/onboard.md +525 -0
  27. package/commands/opsx/sync.md +134 -0
  28. package/commands/opsx/verify.md +164 -0
  29. package/config/stack-allowlist.template.json +12 -0
  30. package/dist/cli.js +105 -0
  31. package/dist/commands/doctor.js +77 -0
  32. package/dist/commands/init.js +129 -0
  33. package/dist/commands/status.js +59 -0
  34. package/dist/commands/uninstall.js +52 -0
  35. package/dist/commands/update.js +11 -0
  36. package/dist/lib/install-engine.js +99 -0
  37. package/dist/lib/markers.js +81 -0
  38. package/dist/lib/paths.js +65 -0
  39. package/dist/lib/settings-merge.js +125 -0
  40. package/dist/lib/stack-prompt.js +69 -0
  41. package/dist/lib/state-seed.js +59 -0
  42. package/docs/agents.md +133 -0
  43. package/docs/commands.md +128 -0
  44. package/docs/customization/mcp-extensions.md +117 -0
  45. package/docs/examples/reference/data-consistency.example.md +61 -0
  46. package/docs/examples/reference/security-foco.example.md +39 -0
  47. package/docs/examples/reference/stack-allowlist.example.json +61 -0
  48. package/docs/getting-started.md +260 -0
  49. package/docs/hooks.md +143 -0
  50. package/hooks/build/build-gate-check.sh +24 -0
  51. package/hooks/build/coherence-flag.sh +23 -0
  52. package/hooks/build/gitflow-guard.sh +65 -0
  53. package/hooks/build/lint-typecheck.sh +33 -0
  54. package/hooks/build/load-build-state.sh +46 -0
  55. package/hooks/build/stack-guard.sh +63 -0
  56. package/hooks/build-harness.json +61 -0
  57. package/internal/skills/auditar-arnes/SKILL.md +29 -0
  58. package/package.json +67 -0
  59. package/scripts/check-agnostic.sh +81 -0
  60. package/scripts/check-state-clean.sh +48 -0
  61. package/scripts/check-version-sync.sh +51 -0
  62. package/scripts/denylist.txt +30 -0
  63. package/skills/building-a-slice/SKILL.md +82 -0
  64. package/skills/building-a-slice/references/data-consistency.md +34 -0
  65. package/skills/building-a-slice/references/dod.md +25 -0
  66. package/skills/building-a-slice/references/dor.md +17 -0
  67. package/skills/building-a-slice/references/gitflow.md +30 -0
  68. package/skills/building-a-slice/references/krug-ux.md +27 -0
  69. package/skills/building-a-slice/references/link-change-epic.md +34 -0
  70. package/skills/building-a-slice/references/mcp-map.md +29 -0
  71. package/skills/building-a-slice/references/newman-tests.md +47 -0
  72. package/skills/building-a-slice/references/simple-design.md +33 -0
  73. package/skills/building-a-slice/references/state-protocol.md +48 -0
  74. package/skills/openspec-apply-change/SKILL.md +156 -0
  75. package/skills/openspec-archive-change/SKILL.md +114 -0
  76. package/skills/openspec-bulk-archive-change/SKILL.md +246 -0
  77. package/skills/openspec-continue-change/SKILL.md +118 -0
  78. package/skills/openspec-explore/SKILL.md +290 -0
  79. package/skills/openspec-ff-change/SKILL.md +101 -0
  80. package/skills/openspec-new-change/SKILL.md +74 -0
  81. package/skills/openspec-onboard/SKILL.md +529 -0
  82. package/skills/openspec-sync-specs/SKILL.md +138 -0
  83. package/skills/openspec-verify-change/SKILL.md +168 -0
  84. package/skills/releasing-a-version/SKILL.md +56 -0
  85. package/skills/releasing-a-version/references/release-dod.md +20 -0
  86. package/state/README.md +56 -0
  87. package/state/build-state.schema.json +111 -0
  88. package/state/build-state.template.json +7 -0
  89. package/templates/CLAUDE.md.template +57 -0
  90. package/templates/newman.collection.template.json +28 -0
  91. package/templates/settings-hooks.template.json +25 -0
  92. package/templates/waivers/WAIVER.template.md +27 -0
@@ -0,0 +1,29 @@
1
+ # Mapa MCP / LSP por gate
2
+
3
+ Qué herramienta externa apoya cada fase del pipeline. Los MCP listados abajo son **ejemplos opt-in**:
4
+ el consumidor decide cuáles habilitar en su entorno según el stack declarado en su PRD. No asumas que
5
+ están disponibles; cuando lo estén, se usan **bajo demanda** para no saturar el contexto.
6
+
7
+ ## LSP — navegación semántica (toda fase con código)
8
+ - **TypeScript LSP**: seguir definiciones/referencias con precisión de compilador (mejor ROI que
9
+ `grep` en TS tipado). Útil para `coherence-three-way` (trazar símbolo→test) y
10
+ `simple-design-reviewer` (uso real de una función, duplicación).
11
+
12
+ ## MCP por gate (ejemplos opt-in)
13
+ Estos MCP son ejemplos representativos; habilita solo los que apliquen a tu stack. Si tu entorno no
14
+ los expone, el gate se cubre con las alternativas CLI/test indicadas.
15
+ | Fase / agente | MCP (ejemplo, si habilitado) | Para qué |
16
+ |---|---|---|
17
+ | `review` · `ux-krug-reviewer` | **chrome-devtools** | `take_snapshot` (árbol accesible), `lighthouse_audit` (Accessibility/Best-Practices), `take_screenshot`, `list_console_messages` para verificar la UI **corriendo**. |
18
+ | `api` · `api-contract-tester` | — (Newman CLI) | Contratos de endpoints. Newman no es MCP; corre vía Bash. |
19
+ | `data` · `data-consistency-checker` | **postgresql** *(solo si el slice usa Postgres)* | `read_query`/`describe_table` para validar consistencia en BD. Con un almacén embebido/cliente (según el stack declarado en el PRD del consumidor) se valida por tests, sin MCP. |
20
+ | perf (opcional, fuera del DoD) | **k6** | `execute_k6_test` para carga/latencia si una HU de la épica lo exige. |
21
+
22
+ ## Reglas de uso
23
+ - **Opt-in y just-in-time**: habilita el MCP solo si tu entorno lo expone, e invócalo solo en su
24
+ fase; no lo cargues "por si acaso".
25
+ - **chrome-devtools** (si habilitado) requiere la app levantada; úsalo en fase `active`.
26
+ - Para diagramas de arquitectura del slice, el ecosistema **figma** es otro ejemplo opt-in: si está
27
+ habilitado puede ayudar, pero es opcional y no forma parte de ningún gate.
28
+ - Datos sintéticos siempre: ningún MCP debe recibir datos sensibles / PII regulados reales (los que
29
+ el consumidor declara en el bloque de dominio de su CLAUDE.md o su PRD) ni secretos.
@@ -0,0 +1,47 @@
1
+ # Pruebas de contrato con Newman (endpoints)
2
+
3
+ Guía que aplica `api-contract-tester` a slices con Route Handlers / Server Actions. Newman es el
4
+ runner CLI de colecciones Postman. (No es un MCP; se ejecuta vía Bash.)
5
+
6
+ ## Estructura de archivos
7
+ ```
8
+ tests/postman/
9
+ ├── <slice>.postman_collection.json # requests + aserciones del slice
10
+ └── environment.json # baseUrl y variables (sin secretos reales)
11
+ ```
12
+
13
+ ## Diseño de la colección (alineada a los AC de las HU de la épica)
14
+ Por cada endpoint del slice, al menos tres requests que reflejen los AC en Given/When/Then:
15
+ - **Happy**: entrada válida → status 2xx + **forma de respuesta** esperada (validar esquema, no solo el status).
16
+ - **Error**: entrada inválida → 4xx con mensaje útil y **sin filtrar datos sensibles / PII regulados** ni detalles internos.
17
+ - **Edge**: límites del dominio (campo obligatorio faltante, respuesta de servicio externo parcial, casos borde del dominio declarados por el consumidor…).
18
+
19
+ Aserciones recomendadas en cada request (`pm.test`):
20
+ ```javascript
21
+ pm.test("status", () => pm.response.to.have.status(200));
22
+ pm.test("shape", () => {
23
+ const b = pm.response.json();
24
+ pm.expect(b).to.have.property("resultado");
25
+ // (sustituir por el contrato del consumidor: las decisiones de alto impacto
26
+ // del dominio se declaran en su domain-pack / PRD)
27
+ pm.expect(b.decision).to.be.oneOf(["DECISION_A","DECISION_B","DECISION_C"]);
28
+ });
29
+ ```
30
+
31
+ ## Ejecución
32
+ ```bash
33
+ # 1) levantar la app (si aplica), p.ej. en background:
34
+ npm run dev # o: npm run build && npm run start
35
+ # 2) correr Newman cuando el server esté listo:
36
+ npx --yes newman run tests/postman/<slice>.postman_collection.json \
37
+ -e tests/postman/environment.json \
38
+ --reporters cli,json \
39
+ --reporter-json-export .claude/state/newman-<slice>.json
40
+ ```
41
+
42
+ ## Interpretación → gate
43
+ - **100% requests + assertions verdes** → `gates.api: true`.
44
+ - Cualquier fallo → `gates.api: false`, reportando request + aserción + causa.
45
+ - Slice sin endpoints → `gates.api: null` (N/A, no bloquea DoD).
46
+
47
+ > El entorno usa datos sintéticos. Nunca incluyas datos sensibles / PII regulados reales ni claves de servicios externos declaradas server-side en la colección o el environment versionado.
@@ -0,0 +1,33 @@
1
+ # Diseño simple (Kent Beck) + code smells
2
+
3
+ Guía que aplica `simple-design-reviewer` sobre código **que ya pasa los tests**.
4
+
5
+ ## Las 4 reglas de diseño simple (orden de prioridad de Beck)
6
+ 1. **Pasa los tests.** Correcto antes que bonito.
7
+ 2. **Revela la intención.** Nombres y estructura cuentan la historia; un lector entiende sin adivinar.
8
+ 3. **No tiene duplicación.** DRY de *conocimiento* (no de texto casual). Regla de tres antes de extraer.
9
+ 4. **Menos elementos.** Lo mínimo que cumpla 1–3. YAGNI: nada especulativo.
10
+
11
+ Conflictos: 1 manda siempre; entre 2 y 3, prioriza eliminar duplicación; entre 4 y 2/3, prioriza
12
+ revelar intención y no duplicar (la concisión no justifica oscuridad).
13
+
14
+ ## Smells frecuentes (y su refactor)
15
+ | Smell | Señal | Refactor |
16
+ |---|---|---|
17
+ | Función larga | hace muchas cosas | Extract Function; una responsabilidad |
18
+ | Lista de parámetros larga | 4+ params | Introduce Parameter Object |
19
+ | Números/strings mágicos | literales sueltos | Constante con nombre / config versionada |
20
+ | Duplicación | misma lógica en 2+ sitios | Extraer función/módulo compartido |
21
+ | Feature envy | un módulo usa más datos de otro | Mover el comportamiento a donde viven los datos |
22
+ | Componente "Dios" | UI + estado + lógica de negocio | Separar la capa de decisión del dominio de la vista |
23
+ | `any` / casts | tipos perdidos | Tipar con interfaces/zod |
24
+ | Comentario-muleta | explica código confuso | Renombrar/extraer hasta que sobre el comentario |
25
+ | Código muerto | no se referencia | Borrar |
26
+
27
+ ## Específico del dominio
28
+ - La **capa de decisión determinista del dominio** vive en su propio módulo puro (testeable, sin UI, sin IA): mismas entradas → misma salida, explicable.
29
+ - **Parámetros de decisión** (umbrales, pesos, bandas) = configuración versionada, jamás literales repartidos por el código.
30
+ - La **capa de servicios externos** (el servicio externo/IA de la frontera declarada por el consumidor) queda aislada detrás de una interfaz; el resto del código no la conoce.
31
+ - La salida de cualquier servicio externo/IA se trata como **input no confiable**: validación contra un esquema fijo centralizada (un solo esquema reutilizado) antes de alimentar la capa de decisión.
32
+
33
+ Clasifica hallazgos en BLOQUEANTE / RECOMENDADO / NIT. Solo los BLOQUEANTES impiden `gates.smell`.
@@ -0,0 +1,48 @@
1
+ # Protocolo del archivo de estado (`build-state.json`)
2
+
3
+ El estado es **cómo se comunican los agentes** en el modelo secuencial: cada uno lee antes de
4
+ actuar y escribe su resultado, dejando el testigo al siguiente. Esquema y reglas base viven en
5
+ `.claude/state/README.md` y `.claude/state/build-state.schema.json`; aquí va el uso operativo.
6
+
7
+ ## Lectura
8
+ ```bash
9
+ python3 -c 'import json;print(json.dumps(json.load(open(".claude/state/build-state.json")),indent=2,ensure_ascii=False))'
10
+ ```
11
+ - `active_slice == null` → no hay slice; solo `dor` puede abrir uno.
12
+ - Si no es null → identifica el **primer gate en `false`**: ahí se reanuda.
13
+
14
+ ## Escritura (una transición = una escritura)
15
+ Patrón seguro (lee-modifica-escribe) con timestamp UTC:
16
+ ```bash
17
+ python3 - <<'PY'
18
+ import json,datetime
19
+ p=".claude/state/build-state.json"; d=json.load(open(p))
20
+ s=d["active_slice"]
21
+ s["gates"]["journey_smoke"]=True # el gate que cierras (inner loop)
22
+ s["phase"]="smoke" # la nueva fase
23
+ s["updated_at"]=datetime.datetime.now(datetime.timezone.utc).isoformat()
24
+ s["updated_by"]="build-orchestrator" # quién escribe
25
+ json.dump(d,open(p,"w"),indent=2,ensure_ascii=False)
26
+ PY
27
+ ```
28
+
29
+ ## Inner loop vs releases[]
30
+ - **Inner loop (por slice)**: gates `dor`, `tdd`, `journey_smoke`, `coherence_link`, `data`, `api`,
31
+ `dod` en `active_slice.gates`. Los escribe el flujo de `building-a-slice` / `build-orchestrator`.
32
+ - **Outer loop (por release)**: los gates pesados (`security`, `smell`, `ux`, `coherence`,
33
+ `stack_arch`, `integration`) **no** viven en el slice — viven en una entrada de `releases[]` que
34
+ escribe la skill `releasing-a-version`. Una release = una línea de release del Story Map.
35
+
36
+ ## Reglas
37
+ 1. **No saltes gates**: no cierres `dod` con gates abiertos.
38
+ 2. **Retroceso permitido**: si una revisión posterior falla, pon su gate en `false` y retrocede `phase`.
39
+ 3. **`ux`/`api` = `null`** cuando no aplican (no cuentan como abiertos para DoD).
40
+ 4. **Archivar**: mueve `active_slice` a `history[]` con `phase:"archived"`, deja `active_slice:null`.
41
+ 5. **Valida tras escribir**:
42
+ ```bash
43
+ python3 -c "import jsonschema,json; jsonschema.Draft202012Validator(json.load(open('.claude/state/build-state.schema.json'))).validate(json.load(open('.claude/state/build-state.json'))); print('OK')"
44
+ ```
45
+
46
+ ## Tabla de responsabilidad (quién cierra cada gate)
47
+ Ver `.claude/state/README.md` § "Quién escribe qué". El `build-orchestrator` es el único que
48
+ transiciona `phase` y archiva; los reviewers solo tocan su propio gate.
@@ -0,0 +1,156 @@
1
+ ---
2
+ name: openspec-apply-change
3
+ description: Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
4
+ license: MIT
5
+ compatibility: Requires openspec CLI.
6
+ metadata:
7
+ author: openspec
8
+ version: "1.0"
9
+ generatedBy: "1.0.2"
10
+ ---
11
+
12
+ Implement tasks from an OpenSpec change.
13
+
14
+ **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
15
+
16
+ **Steps**
17
+
18
+ 1. **Select the change**
19
+
20
+ If a name is provided, use it. Otherwise:
21
+ - Infer from conversation context if the user mentioned a change
22
+ - Auto-select if only one active change exists
23
+ - If ambiguous, run `openspec list --json` to get available changes and use the **AskUserQuestion tool** to let the user select
24
+
25
+ Always announce: "Using change: <name>" and how to override (e.g., `/opsx:apply <other>`).
26
+
27
+ 2. **Check status to understand the schema**
28
+ ```bash
29
+ openspec status --change "<name>" --json
30
+ ```
31
+ Parse the JSON to understand:
32
+ - `schemaName`: The workflow being used (e.g., "spec-driven")
33
+ - Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
34
+
35
+ 3. **Get apply instructions**
36
+
37
+ ```bash
38
+ openspec instructions apply --change "<name>" --json
39
+ ```
40
+
41
+ This returns:
42
+ - Context file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
43
+ - Progress (total, complete, remaining)
44
+ - Task list with status
45
+ - Dynamic instruction based on current state
46
+
47
+ **Handle states:**
48
+ - If `state: "blocked"` (missing artifacts): show message, suggest using openspec-continue-change
49
+ - If `state: "all_done"`: congratulate, suggest archive
50
+ - Otherwise: proceed to implementation
51
+
52
+ 4. **Read context files**
53
+
54
+ Read the files listed in `contextFiles` from the apply instructions output.
55
+ The files depend on the schema being used:
56
+ - **spec-driven**: proposal, specs, design, tasks
57
+ - Other schemas: follow the contextFiles from CLI output
58
+
59
+ 5. **Show current progress**
60
+
61
+ Display:
62
+ - Schema being used
63
+ - Progress: "N/M tasks complete"
64
+ - Remaining tasks overview
65
+ - Dynamic instruction from CLI
66
+
67
+ 6. **Implement tasks (loop until done or blocked)**
68
+
69
+ For each pending task:
70
+ - Show which task is being worked on
71
+ - Make the code changes required
72
+ - Keep changes minimal and focused
73
+ - Mark task complete in the tasks file: `- [ ]` → `- [x]`
74
+ - Continue to next task
75
+
76
+ **Pause if:**
77
+ - Task is unclear → ask for clarification
78
+ - Implementation reveals a design issue → suggest updating artifacts
79
+ - Error or blocker encountered → report and wait for guidance
80
+ - User interrupts
81
+
82
+ 7. **On completion or pause, show status**
83
+
84
+ Display:
85
+ - Tasks completed this session
86
+ - Overall progress: "N/M tasks complete"
87
+ - If all done: suggest archive
88
+ - If paused: explain why and wait for guidance
89
+
90
+ **Output During Implementation**
91
+
92
+ ```
93
+ ## Implementing: <change-name> (schema: <schema-name>)
94
+
95
+ Working on task 3/7: <task description>
96
+ [...implementation happening...]
97
+ ✓ Task complete
98
+
99
+ Working on task 4/7: <task description>
100
+ [...implementation happening...]
101
+ ✓ Task complete
102
+ ```
103
+
104
+ **Output On Completion**
105
+
106
+ ```
107
+ ## Implementation Complete
108
+
109
+ **Change:** <change-name>
110
+ **Schema:** <schema-name>
111
+ **Progress:** 7/7 tasks complete ✓
112
+
113
+ ### Completed This Session
114
+ - [x] Task 1
115
+ - [x] Task 2
116
+ ...
117
+
118
+ All tasks complete! Ready to archive this change.
119
+ ```
120
+
121
+ **Output On Pause (Issue Encountered)**
122
+
123
+ ```
124
+ ## Implementation Paused
125
+
126
+ **Change:** <change-name>
127
+ **Schema:** <schema-name>
128
+ **Progress:** 4/7 tasks complete
129
+
130
+ ### Issue Encountered
131
+ <description of the issue>
132
+
133
+ **Options:**
134
+ 1. <option 1>
135
+ 2. <option 2>
136
+ 3. Other approach
137
+
138
+ What would you like to do?
139
+ ```
140
+
141
+ **Guardrails**
142
+ - Keep going through tasks until done or blocked
143
+ - Always read context files before starting (from the apply instructions output)
144
+ - If task is ambiguous, pause and ask before implementing
145
+ - If implementation reveals issues, pause and suggest artifact updates
146
+ - Keep code changes minimal and scoped to each task
147
+ - Update task checkbox immediately after completing each task
148
+ - Pause on errors, blockers, or unclear requirements - don't guess
149
+ - Use contextFiles from CLI output, don't assume specific file names
150
+
151
+ **Fluid Workflow Integration**
152
+
153
+ This skill supports the "actions on a change" model:
154
+
155
+ - **Can be invoked anytime**: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
156
+ - **Allows artifact updates**: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
@@ -0,0 +1,114 @@
1
+ ---
2
+ name: openspec-archive-change
3
+ description: Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.
4
+ license: MIT
5
+ compatibility: Requires openspec CLI.
6
+ metadata:
7
+ author: openspec
8
+ version: "1.0"
9
+ generatedBy: "1.0.2"
10
+ ---
11
+
12
+ Archive a completed change in the experimental workflow.
13
+
14
+ **Input**: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
15
+
16
+ **Steps**
17
+
18
+ 1. **If no change name provided, prompt for selection**
19
+
20
+ Run `openspec list --json` to get available changes. Use the **AskUserQuestion tool** to let the user select.
21
+
22
+ Show only active changes (not already archived).
23
+ Include the schema used for each change if available.
24
+
25
+ **IMPORTANT**: Do NOT guess or auto-select a change. Always let the user choose.
26
+
27
+ 2. **Check artifact completion status**
28
+
29
+ Run `openspec status --change "<name>" --json` to check artifact completion.
30
+
31
+ Parse the JSON to understand:
32
+ - `schemaName`: The workflow being used
33
+ - `artifacts`: List of artifacts with their status (`done` or other)
34
+
35
+ **If any artifacts are not `done`:**
36
+ - Display warning listing incomplete artifacts
37
+ - Use **AskUserQuestion tool** to confirm user wants to proceed
38
+ - Proceed if user confirms
39
+
40
+ 3. **Check task completion status**
41
+
42
+ Read the tasks file (typically `tasks.md`) to check for incomplete tasks.
43
+
44
+ Count tasks marked with `- [ ]` (incomplete) vs `- [x]` (complete).
45
+
46
+ **If incomplete tasks found:**
47
+ - Display warning showing count of incomplete tasks
48
+ - Use **AskUserQuestion tool** to confirm user wants to proceed
49
+ - Proceed if user confirms
50
+
51
+ **If no tasks file exists:** Proceed without task-related warning.
52
+
53
+ 4. **Assess delta spec sync state**
54
+
55
+ Check for delta specs at `openspec/changes/<name>/specs/`. If none exist, proceed without sync prompt.
56
+
57
+ **If delta specs exist:**
58
+ - Compare each delta spec with its corresponding main spec at `openspec/specs/<capability>/spec.md`
59
+ - Determine what changes would be applied (adds, modifications, removals, renames)
60
+ - Show a combined summary before prompting
61
+
62
+ **Prompt options:**
63
+ - If changes needed: "Sync now (recommended)", "Archive without syncing"
64
+ - If already synced: "Archive now", "Sync anyway", "Cancel"
65
+
66
+ If user chooses sync, execute /opsx:sync logic (use the openspec-sync-specs skill). Proceed to archive regardless of choice.
67
+
68
+ 5. **Perform the archive**
69
+
70
+ Create the archive directory if it doesn't exist:
71
+ ```bash
72
+ mkdir -p openspec/changes/archive
73
+ ```
74
+
75
+ Generate target name using current date: `YYYY-MM-DD-<change-name>`
76
+
77
+ **Check if target already exists:**
78
+ - If yes: Fail with error, suggest renaming existing archive or using different date
79
+ - If no: Move the change directory to archive
80
+
81
+ ```bash
82
+ mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
83
+ ```
84
+
85
+ 6. **Display summary**
86
+
87
+ Show archive completion summary including:
88
+ - Change name
89
+ - Schema that was used
90
+ - Archive location
91
+ - Whether specs were synced (if applicable)
92
+ - Note about any warnings (incomplete artifacts/tasks)
93
+
94
+ **Output On Success**
95
+
96
+ ```
97
+ ## Archive Complete
98
+
99
+ **Change:** <change-name>
100
+ **Schema:** <schema-name>
101
+ **Archived to:** openspec/changes/archive/YYYY-MM-DD-<name>/
102
+ **Specs:** ✓ Synced to main specs (or "No delta specs" or "Sync skipped")
103
+
104
+ All artifacts complete. All tasks complete.
105
+ ```
106
+
107
+ **Guardrails**
108
+ - Always prompt for change selection if not provided
109
+ - Use artifact graph (openspec status --json) for completion checking
110
+ - Don't block archive on warnings - just inform and confirm
111
+ - Preserve .openspec.yaml when moving to archive (it moves with the directory)
112
+ - Show clear summary of what happened
113
+ - If sync is requested, use openspec-sync-specs approach (agent-driven)
114
+ - If delta specs exist, always run the sync assessment and show the combined summary before prompting
@@ -0,0 +1,246 @@
1
+ ---
2
+ name: openspec-bulk-archive-change
3
+ description: Archive multiple completed changes at once. Use when archiving several parallel changes.
4
+ license: MIT
5
+ compatibility: Requires openspec CLI.
6
+ metadata:
7
+ author: openspec
8
+ version: "1.0"
9
+ generatedBy: "1.0.2"
10
+ ---
11
+
12
+ Archive multiple completed changes in a single operation.
13
+
14
+ This skill allows you to batch-archive changes, handling spec conflicts intelligently by checking the codebase to determine what's actually implemented.
15
+
16
+ **Input**: None required (prompts for selection)
17
+
18
+ **Steps**
19
+
20
+ 1. **Get active changes**
21
+
22
+ Run `openspec list --json` to get all active changes.
23
+
24
+ If no active changes exist, inform user and stop.
25
+
26
+ 2. **Prompt for change selection**
27
+
28
+ Use **AskUserQuestion tool** with multi-select to let user choose changes:
29
+ - Show each change with its schema
30
+ - Include an option for "All changes"
31
+ - Allow any number of selections (1+ works, 2+ is the typical use case)
32
+
33
+ **IMPORTANT**: Do NOT auto-select. Always let the user choose.
34
+
35
+ 3. **Batch validation - gather status for all selected changes**
36
+
37
+ For each selected change, collect:
38
+
39
+ a. **Artifact status** - Run `openspec status --change "<name>" --json`
40
+ - Parse `schemaName` and `artifacts` list
41
+ - Note which artifacts are `done` vs other states
42
+
43
+ b. **Task completion** - Read `openspec/changes/<name>/tasks.md`
44
+ - Count `- [ ]` (incomplete) vs `- [x]` (complete)
45
+ - If no tasks file exists, note as "No tasks"
46
+
47
+ c. **Delta specs** - Check `openspec/changes/<name>/specs/` directory
48
+ - List which capability specs exist
49
+ - For each, extract requirement names (lines matching `### Requirement: <name>`)
50
+
51
+ 4. **Detect spec conflicts**
52
+
53
+ Build a map of `capability -> [changes that touch it]`:
54
+
55
+ ```
56
+ auth -> [change-a, change-b] <- CONFLICT (2+ changes)
57
+ api -> [change-c] <- OK (only 1 change)
58
+ ```
59
+
60
+ A conflict exists when 2+ selected changes have delta specs for the same capability.
61
+
62
+ 5. **Resolve conflicts agentically**
63
+
64
+ **For each conflict**, investigate the codebase:
65
+
66
+ a. **Read the delta specs** from each conflicting change to understand what each claims to add/modify
67
+
68
+ b. **Search the codebase** for implementation evidence:
69
+ - Look for code implementing requirements from each delta spec
70
+ - Check for related files, functions, or tests
71
+
72
+ c. **Determine resolution**:
73
+ - If only one change is actually implemented -> sync that one's specs
74
+ - If both implemented -> apply in chronological order (older first, newer overwrites)
75
+ - If neither implemented -> skip spec sync, warn user
76
+
77
+ d. **Record resolution** for each conflict:
78
+ - Which change's specs to apply
79
+ - In what order (if both)
80
+ - Rationale (what was found in codebase)
81
+
82
+ 6. **Show consolidated status table**
83
+
84
+ Display a table summarizing all changes:
85
+
86
+ ```
87
+ | Change | Artifacts | Tasks | Specs | Conflicts | Status |
88
+ |---------------------|-----------|-------|---------|-----------|--------|
89
+ | schema-management | Done | 5/5 | 2 delta | None | Ready |
90
+ | project-config | Done | 3/3 | 1 delta | None | Ready |
91
+ | add-oauth | Done | 4/4 | 1 delta | auth (!) | Ready* |
92
+ | add-verify-skill | 1 left | 2/5 | None | None | Warn |
93
+ ```
94
+
95
+ For conflicts, show the resolution:
96
+ ```
97
+ * Conflict resolution:
98
+ - auth spec: Will apply add-oauth then add-jwt (both implemented, chronological order)
99
+ ```
100
+
101
+ For incomplete changes, show warnings:
102
+ ```
103
+ Warnings:
104
+ - add-verify-skill: 1 incomplete artifact, 3 incomplete tasks
105
+ ```
106
+
107
+ 7. **Confirm batch operation**
108
+
109
+ Use **AskUserQuestion tool** with a single confirmation:
110
+
111
+ - "Archive N changes?" with options based on status
112
+ - Options might include:
113
+ - "Archive all N changes"
114
+ - "Archive only N ready changes (skip incomplete)"
115
+ - "Cancel"
116
+
117
+ If there are incomplete changes, make clear they'll be archived with warnings.
118
+
119
+ 8. **Execute archive for each confirmed change**
120
+
121
+ Process changes in the determined order (respecting conflict resolution):
122
+
123
+ a. **Sync specs** if delta specs exist:
124
+ - Use the openspec-sync-specs approach (agent-driven intelligent merge)
125
+ - For conflicts, apply in resolved order
126
+ - Track if sync was done
127
+
128
+ b. **Perform the archive**:
129
+ ```bash
130
+ mkdir -p openspec/changes/archive
131
+ mv openspec/changes/<name> openspec/changes/archive/YYYY-MM-DD-<name>
132
+ ```
133
+
134
+ c. **Track outcome** for each change:
135
+ - Success: archived successfully
136
+ - Failed: error during archive (record error)
137
+ - Skipped: user chose not to archive (if applicable)
138
+
139
+ 9. **Display summary**
140
+
141
+ Show final results:
142
+
143
+ ```
144
+ ## Bulk Archive Complete
145
+
146
+ Archived 3 changes:
147
+ - schema-management-cli -> archive/2026-01-19-schema-management-cli/
148
+ - project-config -> archive/2026-01-19-project-config/
149
+ - add-oauth -> archive/2026-01-19-add-oauth/
150
+
151
+ Skipped 1 change:
152
+ - add-verify-skill (user chose not to archive incomplete)
153
+
154
+ Spec sync summary:
155
+ - 4 delta specs synced to main specs
156
+ - 1 conflict resolved (auth: applied both in chronological order)
157
+ ```
158
+
159
+ If any failures:
160
+ ```
161
+ Failed 1 change:
162
+ - some-change: Archive directory already exists
163
+ ```
164
+
165
+ **Conflict Resolution Examples**
166
+
167
+ Example 1: Only one implemented
168
+ ```
169
+ Conflict: specs/auth/spec.md touched by [add-oauth, add-jwt]
170
+
171
+ Checking add-oauth:
172
+ - Delta adds "OAuth Provider Integration" requirement
173
+ - Searching codebase... found src/auth/oauth.ts implementing OAuth flow
174
+
175
+ Checking add-jwt:
176
+ - Delta adds "JWT Token Handling" requirement
177
+ - Searching codebase... no JWT implementation found
178
+
179
+ Resolution: Only add-oauth is implemented. Will sync add-oauth specs only.
180
+ ```
181
+
182
+ Example 2: Both implemented
183
+ ```
184
+ Conflict: specs/api/spec.md touched by [add-rest-api, add-graphql]
185
+
186
+ Checking add-rest-api (created 2026-01-10):
187
+ - Delta adds "REST Endpoints" requirement
188
+ - Searching codebase... found src/api/rest.ts
189
+
190
+ Checking add-graphql (created 2026-01-15):
191
+ - Delta adds "GraphQL Schema" requirement
192
+ - Searching codebase... found src/api/graphql.ts
193
+
194
+ Resolution: Both implemented. Will apply add-rest-api specs first,
195
+ then add-graphql specs (chronological order, newer takes precedence).
196
+ ```
197
+
198
+ **Output On Success**
199
+
200
+ ```
201
+ ## Bulk Archive Complete
202
+
203
+ Archived N changes:
204
+ - <change-1> -> archive/YYYY-MM-DD-<change-1>/
205
+ - <change-2> -> archive/YYYY-MM-DD-<change-2>/
206
+
207
+ Spec sync summary:
208
+ - N delta specs synced to main specs
209
+ - No conflicts (or: M conflicts resolved)
210
+ ```
211
+
212
+ **Output On Partial Success**
213
+
214
+ ```
215
+ ## Bulk Archive Complete (partial)
216
+
217
+ Archived N changes:
218
+ - <change-1> -> archive/YYYY-MM-DD-<change-1>/
219
+
220
+ Skipped M changes:
221
+ - <change-2> (user chose not to archive incomplete)
222
+
223
+ Failed K changes:
224
+ - <change-3>: Archive directory already exists
225
+ ```
226
+
227
+ **Output When No Changes**
228
+
229
+ ```
230
+ ## No Changes to Archive
231
+
232
+ No active changes found. Use `/opsx:new` to create a new change.
233
+ ```
234
+
235
+ **Guardrails**
236
+ - Allow any number of changes (1+ is fine, 2+ is the typical use case)
237
+ - Always prompt for selection, never auto-select
238
+ - Detect spec conflicts early and resolve by checking codebase
239
+ - When both changes are implemented, apply specs in chronological order
240
+ - Skip spec sync only when implementation is missing (warn user)
241
+ - Show clear per-change status before confirming
242
+ - Use single confirmation for entire batch
243
+ - Track and report all outcomes (success/skip/fail)
244
+ - Preserve .openspec.yaml when moving to archive
245
+ - Archive directory target uses current date: YYYY-MM-DD-<name>
246
+ - If archive target exists, fail that change but continue with others