@kynetic-ai/spec 0.3.0 → 0.4.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 (111) hide show
  1. package/dist/cli/batch-exec.d.ts +0 -9
  2. package/dist/cli/batch-exec.d.ts.map +1 -1
  3. package/dist/cli/batch-exec.js +16 -4
  4. package/dist/cli/batch-exec.js.map +1 -1
  5. package/dist/cli/commands/derive.d.ts.map +1 -1
  6. package/dist/cli/commands/derive.js +2 -1
  7. package/dist/cli/commands/derive.js.map +1 -1
  8. package/dist/cli/commands/log.d.ts.map +1 -1
  9. package/dist/cli/commands/log.js +5 -4
  10. package/dist/cli/commands/log.js.map +1 -1
  11. package/dist/cli/commands/meta.d.ts.map +1 -1
  12. package/dist/cli/commands/meta.js +2 -1
  13. package/dist/cli/commands/meta.js.map +1 -1
  14. package/dist/cli/commands/plan-import.d.ts.map +1 -1
  15. package/dist/cli/commands/plan-import.js +50 -19
  16. package/dist/cli/commands/plan-import.js.map +1 -1
  17. package/dist/cli/commands/ralph.d.ts.map +1 -1
  18. package/dist/cli/commands/ralph.js +18 -7
  19. package/dist/cli/commands/ralph.js.map +1 -1
  20. package/dist/cli/commands/session.d.ts.map +1 -1
  21. package/dist/cli/commands/session.js +6 -7
  22. package/dist/cli/commands/session.js.map +1 -1
  23. package/dist/cli/commands/setup.d.ts.map +1 -1
  24. package/dist/cli/commands/setup.js +41 -7
  25. package/dist/cli/commands/setup.js.map +1 -1
  26. package/dist/cli/commands/skill-install.d.ts +4 -1
  27. package/dist/cli/commands/skill-install.d.ts.map +1 -1
  28. package/dist/cli/commands/skill-install.js +62 -5
  29. package/dist/cli/commands/skill-install.js.map +1 -1
  30. package/dist/cli/commands/task.d.ts.map +1 -1
  31. package/dist/cli/commands/task.js +35 -24
  32. package/dist/cli/commands/task.js.map +1 -1
  33. package/dist/cli/commands/tasks.d.ts.map +1 -1
  34. package/dist/cli/commands/tasks.js +2 -4
  35. package/dist/cli/commands/tasks.js.map +1 -1
  36. package/dist/cli/commands/triage.d.ts.map +1 -1
  37. package/dist/cli/commands/triage.js +12 -98
  38. package/dist/cli/commands/triage.js.map +1 -1
  39. package/dist/cli/output.d.ts.map +1 -1
  40. package/dist/cli/output.js +4 -2
  41. package/dist/cli/output.js.map +1 -1
  42. package/dist/daemon/routes/triage.ts +4 -70
  43. package/dist/parser/config.d.ts +106 -0
  44. package/dist/parser/config.d.ts.map +1 -1
  45. package/dist/parser/config.js +47 -0
  46. package/dist/parser/config.js.map +1 -1
  47. package/dist/parser/plan-document.d.ts +8 -0
  48. package/dist/parser/plan-document.d.ts.map +1 -1
  49. package/dist/parser/plan-document.js +1 -0
  50. package/dist/parser/plan-document.js.map +1 -1
  51. package/dist/ralph/events.d.ts.map +1 -1
  52. package/dist/ralph/events.js +24 -0
  53. package/dist/ralph/events.js.map +1 -1
  54. package/dist/ralph/index.d.ts +1 -1
  55. package/dist/ralph/index.d.ts.map +1 -1
  56. package/dist/ralph/index.js +1 -1
  57. package/dist/ralph/index.js.map +1 -1
  58. package/dist/ralph/subagent.d.ts +12 -1
  59. package/dist/ralph/subagent.d.ts.map +1 -1
  60. package/dist/ralph/subagent.js +22 -3
  61. package/dist/ralph/subagent.js.map +1 -1
  62. package/dist/schema/batch.d.ts +2 -0
  63. package/dist/schema/batch.d.ts.map +1 -1
  64. package/dist/schema/common.d.ts +6 -0
  65. package/dist/schema/common.d.ts.map +1 -1
  66. package/dist/schema/common.js +8 -0
  67. package/dist/schema/common.js.map +1 -1
  68. package/dist/sessions/store.d.ts +8 -0
  69. package/dist/sessions/store.d.ts.map +1 -1
  70. package/dist/sessions/store.js +219 -37
  71. package/dist/sessions/store.js.map +1 -1
  72. package/dist/strings/errors.d.ts +4 -0
  73. package/dist/strings/errors.d.ts.map +1 -1
  74. package/dist/strings/errors.js +2 -0
  75. package/dist/strings/errors.js.map +1 -1
  76. package/dist/triage/actions.d.ts +27 -0
  77. package/dist/triage/actions.d.ts.map +1 -0
  78. package/dist/triage/actions.js +95 -0
  79. package/dist/triage/actions.js.map +1 -0
  80. package/dist/triage/constants.d.ts +6 -0
  81. package/dist/triage/constants.d.ts.map +1 -0
  82. package/dist/triage/constants.js +7 -0
  83. package/dist/triage/constants.js.map +1 -0
  84. package/dist/triage/index.d.ts +3 -0
  85. package/dist/triage/index.d.ts.map +1 -0
  86. package/dist/triage/index.js +3 -0
  87. package/dist/triage/index.js.map +1 -0
  88. package/package.json +1 -1
  89. package/plugin/.claude-plugin/marketplace.json +1 -1
  90. package/plugin/.claude-plugin/plugin.json +1 -1
  91. package/plugin/plugins/kspec/skills/create-workflow/SKILL.md +235 -0
  92. package/plugin/plugins/kspec/skills/observations/SKILL.md +143 -0
  93. package/plugin/plugins/kspec/skills/plan/SKILL.md +343 -0
  94. package/plugin/plugins/kspec/skills/reflect/SKILL.md +161 -0
  95. package/plugin/plugins/kspec/skills/review/SKILL.md +193 -0
  96. package/plugin/plugins/kspec/skills/task-work/SKILL.md +303 -0
  97. package/plugin/plugins/kspec/skills/triage-automation/SKILL.md +140 -0
  98. package/plugin/plugins/kspec/skills/triage-inbox/SKILL.md +232 -0
  99. package/plugin/plugins/kspec/skills/writing-specs/SKILL.md +340 -0
  100. package/templates/agents-sections/03-task-lifecycle.md +2 -2
  101. package/templates/agents-sections/04-pr-workflow.md +3 -3
  102. package/templates/skills/create-workflow/SKILL.md +228 -0
  103. package/templates/skills/manifest.yaml +45 -0
  104. package/templates/skills/observations/SKILL.md +137 -0
  105. package/templates/skills/plan/SKILL.md +336 -0
  106. package/templates/skills/reflect/SKILL.md +155 -0
  107. package/templates/skills/review/SKILL.md +186 -0
  108. package/templates/skills/task-work/SKILL.md +296 -0
  109. package/templates/skills/triage-automation/SKILL.md +134 -0
  110. package/templates/skills/triage-inbox/SKILL.md +225 -0
  111. package/templates/skills/writing-specs/SKILL.md +333 -0
@@ -0,0 +1,225 @@
1
+ # Inbox Triage
2
+
3
+ Systematically process inbox items using the **record → act** pattern. Records decisions with audit trail, then executes actions.
4
+
5
+ ## When to Use
6
+
7
+ - Processing accumulated inbox items
8
+ - During a triage session (`kspec workflow start @inbox-triage`)
9
+ - When inbox count is growing and needs attention
10
+
11
+ ## Core Concept: Record → Act
12
+
13
+ Triage separates **decision-making** from **execution**:
14
+
15
+ 1. **Record** the decision (what to do + why)
16
+ 2. **Act** on the decision (execute it)
17
+
18
+ This enables review, override, and audit trails.
19
+
20
+ ```bash
21
+ # Step 1: Record what you want to do
22
+ kspec triage record @inbox-ref --action promote --reasoning "Clear feature request"
23
+
24
+ # Step 2: Execute the decision
25
+ kspec triage act @triage-ref
26
+ ```
27
+
28
+ ### Actions
29
+
30
+ | Action | What `act` does |
31
+ |--------|-----------------|
32
+ | `promote` | Creates task from inbox item snapshot |
33
+ | `delete` | Deletes the inbox item |
34
+ | `defer` | Records deferral, no side effect |
35
+ | `spec-gap` | Creates observation tagged spec-gap |
36
+ | `duplicate` | Deletes the inbox item |
37
+
38
+ ### Lifecycle
39
+
40
+ ```
41
+ record (with action) override (optional) act
42
+ → triaged → triaged → acted_on
43
+ ```
44
+
45
+ ## Workflow
46
+
47
+ ### 1. Gather Context
48
+
49
+ ```bash
50
+ kspec session start --full
51
+ kspec inbox list
52
+ ```
53
+
54
+ ### 2. Categorize Items
55
+
56
+ Group inbox items by type:
57
+ - **Bugs** — implementation issues, errors
58
+ - **Spec gaps** — missing or incomplete specs
59
+ - **Quick wins** — small, well-defined improvements
60
+ - **Larger features** — need plan mode to design
61
+ - **Process/workflow** — meta improvements
62
+ - **Delete candidates** — outdated, duplicates, already done
63
+
64
+ Present categories to user for alignment.
65
+
66
+ ### 3. Triage Each Item
67
+
68
+ **Interactive mode** (recommended for multiple items):
69
+
70
+ ```bash
71
+ kspec triage start
72
+ # Presents untriaged items one by one
73
+ # Prompts for action + reasoning
74
+ # Ctrl+C preserves all previously committed records
75
+ ```
76
+
77
+ **Individual recording** (for targeted decisions):
78
+
79
+ ```bash
80
+ kspec triage record @ref --action promote --reasoning "Clear feature request with spec coverage"
81
+ kspec triage record @ref --action delete --reasoning "Already implemented in PR #123"
82
+ kspec triage record @ref --action defer --reasoning "Depends on auth system redesign"
83
+ kspec triage record @ref --action spec-gap --reasoning "No spec covers error handling for this flow"
84
+ kspec triage record @ref --action duplicate --reasoning "Covered by @existing-spec"
85
+ ```
86
+
87
+ ### 4. Review and Execute Decisions
88
+
89
+ ```bash
90
+ # Review what was recorded
91
+ kspec triage list --status triaged
92
+
93
+ # Preview before executing
94
+ kspec triage act @triage-ref --dry-run
95
+
96
+ # Execute decisions
97
+ kspec triage act @triage-ref
98
+ ```
99
+
100
+ ### 5. Override If Needed
101
+
102
+ ```bash
103
+ # Override changes the action while preserving the audit trail
104
+ kspec triage override @triage-ref --action defer --reasoning "Reconsidered - not ready"
105
+
106
+ # Then act on the updated decision
107
+ kspec triage act @triage-ref
108
+ ```
109
+
110
+ ## Spec-First Processing
111
+
112
+ For behavior changes, check spec coverage before promoting:
113
+
114
+ 1. **Check coverage**: `kspec item list | grep <relevant>`
115
+ 2. **Identify gaps**: Does spec have description AND acceptance criteria?
116
+ 3. **Update spec**:
117
+ ```bash
118
+ kspec item set @ref --description "..."
119
+ kspec item ac add @ref --given "..." --when "..." --then "..."
120
+ ```
121
+ 4. **Record and act**:
122
+ ```bash
123
+ kspec triage record @inbox-ref --action promote --reasoning "Spec updated" --evidence @spec-ref
124
+ kspec triage act @triage-ref
125
+ ```
126
+
127
+ ## Plan Mode for Larger Items
128
+
129
+ When an item needs design work:
130
+
131
+ 1. Enter plan mode
132
+ 2. Explore codebase for patterns/context
133
+ 3. Design spec structure and implementation approach
134
+ 4. Write plan, exit for approval
135
+ 5. Execute: create spec, add AC, derive task
136
+
137
+ ## Observation Processing
138
+
139
+ During triage sessions, you may also process pending observations:
140
+
141
+ ```bash
142
+ kspec meta observations --pending-resolution
143
+ ```
144
+
145
+ For each observation:
146
+
147
+ | Type | How to Process |
148
+ |------|----------------|
149
+ | **friction** | Reveals spec gap? → Create spec or inbox item. Already addressed? → Resolve |
150
+ | **success** | Document in relevant spec or AGENTS.md if broadly useful → Resolve |
151
+ | **question** | Answer if you can. Needs investigation? → Promote to task |
152
+ | **idea** | Clear scope? → Inbox or task. Unclear? → Leave or delete if stale |
153
+
154
+ ```bash
155
+ # Promote observation to task
156
+ kspec meta promote @ref --title "Add bulk AC command" --priority 2
157
+
158
+ # Resolve observation
159
+ kspec meta resolve @ref "Resolution notes"
160
+ kspec meta resolve --refs @ref1 @ref2 --resolution "Batch resolution"
161
+
162
+ # Convert inbox item to observation (if it's a pattern, not a task)
163
+ kspec meta observe --from-inbox @ref
164
+ ```
165
+
166
+ ## Export for Context
167
+
168
+ Share triage decisions with other agents or sessions:
169
+
170
+ ```bash
171
+ # Markdown context blocks (for agent handoff)
172
+ kspec triage export --format context
173
+
174
+ # Full structured data
175
+ kspec triage export --format json
176
+ ```
177
+
178
+ ## Bulk Operations with Batch
179
+
180
+ When triaging many items, use `kspec batch` for atomic operations:
181
+
182
+ ```bash
183
+ kspec batch --commands '[
184
+ {"command":"triage record","args":{"ref":"@ref1","action":"delete","reasoning":"Stale"}},
185
+ {"command":"triage record","args":{"ref":"@ref2","action":"promote","reasoning":"Clear scope"}}
186
+ ]'
187
+ ```
188
+
189
+ Use `--dry-run` to preview. See `/kspec:help` for full batch documentation.
190
+
191
+ ## Common Patterns
192
+
193
+ | Pattern | Action |
194
+ |---------|--------|
195
+ | Already implemented | Verify impl exists → check spec gaps → record delete |
196
+ | Duplicate of existing | Verify original covers scope → record duplicate |
197
+ | Small flag/option | Update spec + AC → record promote |
198
+ | New command | Plan mode → design spec → record promote with evidence |
199
+ | Bug report | Check spec coverage → update spec → record promote |
200
+ | Vague idea | Record defer, or leave untriaged for later |
201
+ | Missing spec | Record spec-gap → creates observation for follow-up |
202
+
203
+ ## Key Principles
204
+
205
+ - **Record before act** — Separate decisions from execution for audit trail
206
+ - **Ask one question at a time** — Don't batch decisions in interactive mode
207
+ - **Spec before task** — Fill spec gaps before promoting to tasks
208
+ - **AC is required** — Specs without acceptance criteria are incomplete
209
+ - **Use CLI, not YAML** — All changes through kspec commands
210
+ - **Delete freely** — Outdated or duplicate items should go
211
+
212
+ ## Progress Tracking
213
+
214
+ At session end, provide summary:
215
+ - Items triaged (recorded decisions)
216
+ - Actions executed (promoted, deleted, deferred, spec-gap, duplicate)
217
+ - Tasks created/updated
218
+ - Observations resolved
219
+ - Remaining items
220
+
221
+ ## Integration
222
+
223
+ - **`/kspec:reflect`** — Session reflection may generate inbox items for triage
224
+ - **`/kspec:observations`** — Captures systemic patterns found during triage
225
+ - **`kspec session start`** — Shows inbox count for triage awareness
@@ -0,0 +1,333 @@
1
+ # Writing Specs
2
+
3
+ Create and maintain specification items — the source of truth for what to build. This skill covers spec structure, writing good acceptance criteria, using traits, and organizing specs in the hierarchy.
4
+
5
+ ## When to Use
6
+
7
+ - Creating a new feature, requirement, or constraint spec
8
+ - Adding or refining acceptance criteria
9
+ - Applying traits for cross-cutting behaviors
10
+ - Organizing specs under the right module/parent
11
+ - Reviewing spec quality before deriving tasks
12
+
13
+ **Not for:** Task management (use `/kspec:task-work`), plan-to-spec translation (use `/kspec:plan`), or triage (use `/kspec:triage`).
14
+
15
+ ## Core Principles
16
+
17
+ 1. **Spec defines WHAT, not HOW** — Describe the desired behavior, not the implementation
18
+ 2. **Every spec needs AC** — A spec without acceptance criteria is incomplete
19
+ 3. **Given/When/Then is testable** — Each AC should map to at least one test
20
+ 4. **Traits eliminate duplication** — Cross-cutting concerns belong in traits, not copied across specs
21
+ 5. **Use CLI, not YAML** — All changes through `kspec` commands for auto-commit
22
+
23
+ ## Spec Hierarchy
24
+
25
+ Specs live in modules and form a tree:
26
+
27
+ ```
28
+ module (organizational grouping)
29
+ ├── feature (user-facing capability)
30
+ │ ├── requirement (specific testable behavior)
31
+ │ └── constraint (limitation or boundary)
32
+ ├── feature
33
+ │ └── requirement
34
+ └── decision (architectural choice, ADR-style)
35
+ ```
36
+
37
+ ### Choosing the Right Type
38
+
39
+ | Type | Use when | Example |
40
+ |------|----------|---------|
41
+ | `module` | Grouping related features | "CLI Commands", "Web UI", "Schema" |
42
+ | `feature` | User-facing capability | "JSON Export", "Inbox Triage", "Shadow Sync" |
43
+ | `requirement` | Specific testable behavior within a feature | "Export validates output format", "Triage records audit trail" |
44
+ | `constraint` | Non-functional limit or boundary | "Response time < 200ms", "Max 1000 items per module" |
45
+ | `decision` | Architectural choice with rationale | "Use YAML over JSON for spec files" |
46
+ | `trait` | Reusable AC bundle for cross-cutting behaviors | "JSON output mode", "Confirmation prompts" |
47
+
48
+ **Rule of thumb:** If it has acceptance criteria that a user could verify, it's a feature or requirement. If it constrains how something works, it's a constraint. If multiple specs need the same behavior, extract a trait.
49
+
50
+ ## Writing Acceptance Criteria
51
+
52
+ AC are the heart of a spec. They define what "done" means.
53
+
54
+ ### Format
55
+
56
+ ```
57
+ Given: precondition (state before the action)
58
+ When: action (what triggers the behavior)
59
+ Then: outcome (observable, verifiable result)
60
+ ```
61
+
62
+ ### Good AC Patterns
63
+
64
+ **Specific and testable:**
65
+ ```bash
66
+ kspec item ac add @json-export \
67
+ --given "user has 3 tasks in project" \
68
+ --when "user runs 'kspec tasks list --json'" \
69
+ --then "stdout contains valid JSON array with 3 task objects"
70
+ ```
71
+
72
+ **Covers error cases:**
73
+ ```bash
74
+ kspec item ac add @json-export \
75
+ --given "project has no tasks" \
76
+ --when "user runs 'kspec tasks list --json'" \
77
+ --then "stdout contains empty JSON array []"
78
+ ```
79
+
80
+ **Boundary behavior:**
81
+ ```bash
82
+ kspec item ac add @bulk-delete \
83
+ --given "user passes 50 refs (maximum supported)" \
84
+ --when "user runs bulk delete" \
85
+ --then "all 50 items deleted in single operation"
86
+ ```
87
+
88
+ ### AC Anti-patterns
89
+
90
+ | Anti-pattern | Problem | Better |
91
+ |-------------|---------|--------|
92
+ | "System works correctly" | Not testable | Describe specific observable outcome |
93
+ | "User is happy" | Subjective | Describe what they can do or see |
94
+ | "Fast performance" | Not measurable | "Response returns within 200ms" |
95
+ | "Handles errors" | Vague | Specific error scenario + expected behavior |
96
+ | Duplicating trait AC | Maintenance burden | Apply the trait instead |
97
+
98
+ ### AC Naming Convention
99
+
100
+ AC IDs are auto-generated (`ac-1`, `ac-2`, ...) or can be explicit:
101
+
102
+ ```bash
103
+ # Auto-generated
104
+ kspec item ac add @feature --given "..." --when "..." --then "..."
105
+
106
+ # Explicit ID for clarity
107
+ kspec item ac add @feature --id ac-json-valid --given "..." --when "..." --then "..."
108
+ ```
109
+
110
+ ### How Many ACs?
111
+
112
+ - **Minimum 1** — Every spec needs at least one
113
+ - **Typical: 2-5** — Happy path + key error cases
114
+ - **If 8+** — Consider splitting the spec into smaller requirements
115
+ - **Each AC = one behavior** — Don't combine multiple verifiable outcomes
116
+
117
+ ## Working with Traits
118
+
119
+ Traits are reusable bundles of acceptance criteria. When a spec implements a trait, it inherits all the trait's ACs.
120
+
121
+ ### When to Use Traits
122
+
123
+ Apply a trait when a spec needs a standard cross-cutting behavior:
124
+
125
+ ```bash
126
+ # Discover available traits
127
+ kspec trait list
128
+
129
+ # View trait details (shows ACs that will be inherited)
130
+ kspec trait get @trait-json-output
131
+
132
+ # Apply trait to spec
133
+ kspec item trait add @my-command @trait-json-output
134
+
135
+ # Apply multiple traits
136
+ kspec item trait add @my-command @trait-json-output @trait-dry-run
137
+ ```
138
+
139
+ ### Common Traits
140
+
141
+ | Trait | When to apply |
142
+ |-------|---------------|
143
+ | `@trait-json-output` | Command produces machine-readable output |
144
+ | `@trait-dry-run` | Command supports preview before execution |
145
+ | `@trait-confirmation-prompt` | Command is destructive |
146
+ | `@trait-filterable-list` | Command lists items with filter options |
147
+ | `@trait-shadow-commit` | Command modifies `.kspec/` data |
148
+ | `@trait-semantic-exit-codes` | Command exit code carries meaning |
149
+ | `@trait-error-guidance` | Command gives recovery suggestions on errors |
150
+ | `@trait-multi-ref-batch` | Command accepts multiple references |
151
+ | `@trait-priority-parameter` | Command accepts priority option |
152
+
153
+ ### Creating New Traits
154
+
155
+ If 3+ specs need the same behavior, consider extracting a trait:
156
+
157
+ ```bash
158
+ # Create the trait
159
+ kspec trait add "Pagination Support" --description "Commands that paginate large result sets" --slug trait-pagination
160
+
161
+ # Add ACs to the trait
162
+ kspec item ac add @trait-pagination --given "result set > page size" --when "command runs" --then "first page shown with pagination indicator"
163
+ kspec item ac add @trait-pagination --given "user requests next page" --when "user passes --page 2" --then "second page of results shown"
164
+ ```
165
+
166
+ ### Trait AC Coverage
167
+
168
+ When implementing specs with traits, all inherited ACs must be covered by tests:
169
+
170
+ ```javascript
171
+ // AC: @trait-json-output ac-1
172
+ it('should output valid JSON with --json flag', () => { ... });
173
+ ```
174
+
175
+ Run `kspec validate` to check for uncovered trait ACs.
176
+
177
+ ## Creating Specs
178
+
179
+ ### New Feature Under a Module
180
+
181
+ ```bash
182
+ # 1. Find the right parent module
183
+ kspec item list --type module
184
+
185
+ # 2. Create the feature
186
+ kspec item add --under @cli-module --title "Bulk Operations" --type feature --slug bulk-ops
187
+
188
+ # 3. Add description
189
+ kspec item set @bulk-ops --description "Support batch operations on multiple items in a single command"
190
+
191
+ # 4. Add acceptance criteria
192
+ kspec item ac add @bulk-ops \
193
+ --given "user provides 3 item refs" \
194
+ --when "user runs bulk delete" \
195
+ --then "all 3 items deleted and confirmation shown"
196
+
197
+ kspec item ac add @bulk-ops \
198
+ --given "one of 3 refs is invalid" \
199
+ --when "user runs bulk delete" \
200
+ --then "error reported for invalid ref, valid refs still processed"
201
+
202
+ # 5. Apply relevant traits
203
+ kspec item trait add @bulk-ops @trait-confirmation-prompt @trait-dry-run
204
+
205
+ # 6. Validate
206
+ kspec validate
207
+ ```
208
+
209
+ ### Requirement Under a Feature
210
+
211
+ ```bash
212
+ kspec item add --under @bulk-ops --title "Ref validation in batch mode" --type requirement --slug bulk-ref-validation
213
+ kspec item ac add @bulk-ref-validation \
214
+ --given "batch contains mix of valid and invalid refs" \
215
+ --when "batch executes" \
216
+ --then "report lists each ref with success/failure status"
217
+ ```
218
+
219
+ ### Updating Existing Specs
220
+
221
+ ```bash
222
+ # View current state
223
+ kspec item get @feature-slug
224
+
225
+ # Update description
226
+ kspec item set @feature-slug --description "Updated description"
227
+
228
+ # Add missing AC
229
+ kspec item ac add @feature-slug --given "..." --when "..." --then "..."
230
+
231
+ # Update existing AC
232
+ kspec item ac set @feature-slug ac-2 --then "updated expected outcome"
233
+
234
+ # Mark implementation status
235
+ kspec item set @feature-slug --status implemented
236
+
237
+ # Add relationships
238
+ kspec item set @feature-slug --depends-on @other-feature
239
+ kspec item set @feature-slug --relates-to @related-item
240
+ ```
241
+
242
+ ## Spec Quality Checklist
243
+
244
+ Before deriving a task from a spec, verify:
245
+
246
+ - [ ] **Description** — Explains what and why (not how)
247
+ - [ ] **AC coverage** — At least happy path + primary error case
248
+ - [ ] **AC testability** — Each AC maps to a concrete test
249
+ - [ ] **Traits applied** — Cross-cutting behaviors use traits, not duplicated AC
250
+ - [ ] **Correct parent** — Placed under the right module/feature
251
+ - [ ] **No implementation details** — AC describes behavior, not code structure
252
+ - [ ] **Validation passes** — `kspec validate` reports no errors for this item
253
+
254
+ ## Validation
255
+
256
+ ```bash
257
+ # Full validation
258
+ kspec validate
259
+
260
+ # Completeness check
261
+ kspec validate --completeness
262
+
263
+ # Spec-task alignment
264
+ kspec validate --alignment
265
+
266
+ # Strict mode (warnings → errors)
267
+ kspec validate --strict
268
+ ```
269
+
270
+ **Exit codes:** `0` = success, `4` = errors, `6` = warnings only.
271
+
272
+ Validation catches:
273
+ - Missing acceptance criteria
274
+ - Broken references (`@slug` pointing to nonexistent items)
275
+ - Missing descriptions
276
+ - Orphaned specs (no linked tasks)
277
+ - Uncovered trait ACs
278
+
279
+ ## Command Reference
280
+
281
+ ### Item Management
282
+
283
+ ```bash
284
+ kspec item list [--type <type>] # List items
285
+ kspec item get <ref> # Get item details with ACs and traits
286
+ kspec item add --under <parent> --title "..." --type <type> [--slug <slug>]
287
+ kspec item set <ref> --title "..." # Update fields
288
+ kspec item set <ref> --description "..."
289
+ kspec item set <ref> --status <status> # implementation status
290
+ kspec item set <ref> --depends-on <ref>
291
+ kspec item set <ref> --relates-to <ref>
292
+ kspec item patch <ref> --data '{...}' # Complex updates
293
+ kspec item delete <ref> [--force]
294
+ ```
295
+
296
+ ### Acceptance Criteria
297
+
298
+ ```bash
299
+ kspec item ac list <ref> # List ACs for item
300
+ kspec item ac add <ref> --given "..." --when "..." --then "..."
301
+ kspec item ac add <ref> --id <id> --given "..." --when "..." --then "..."
302
+ kspec item ac set <ref> <ac-id> --then "updated"
303
+ kspec item ac remove <ref> <ac-id> [--force]
304
+ ```
305
+
306
+ ### Traits
307
+
308
+ ```bash
309
+ kspec trait list # All traits with AC counts
310
+ kspec trait get <ref> # Trait details
311
+ kspec trait add "Name" --description "..." [--slug <slug>]
312
+ kspec item trait add <spec> <trait> [<trait2> ...]
313
+ kspec item trait remove <spec> <trait> [<trait2> ...]
314
+ ```
315
+
316
+ ### Deriving Tasks
317
+
318
+ Once a spec is ready, derive a task to track implementation:
319
+
320
+ ```bash
321
+ kspec derive @feature-slug # Create task linked to spec
322
+ kspec derive @feature-slug --priority 2
323
+ ```
324
+
325
+ The derived task gets `spec_ref: @feature-slug` automatically.
326
+
327
+ ## Integration
328
+
329
+ - **`/kspec:plan`** — Plans create specs via import or manual creation
330
+ - **`/kspec:task-work`** — Tasks reference specs; AC guides implementation
331
+ - **`/kspec:triage`** — Inbox items may reveal spec gaps
332
+ - **`/kspec:observations`** — Friction may indicate missing specs
333
+ - **`/kspec:review`** — Reviews check AC coverage