Skip to content

Commit fca84e6

Browse files
author
StackMemory Bot (CLI)
committed
feat(skills): add spec generator + linear task runner with agent prompt consolidation
- Add SpecGeneratorSkill: 4-doc system (ONE_PAGER → DEV_SPEC → PROMPT_PLAN → AGENTS.md) with progressive context - Add LinearTaskRunner: bridges Linear tasks → RLM orchestrator → status updates - Add /spec and /linear-run Claude Code skills (.claude/skills/) - Wire skills into CLI (stackmemory skills spec/linear-run), hooks (on-task-complete auto-updates PROMPT_PLAN), and skill-rules.json - Rewrite all 8 RLM subagent system prompts with structured JSON output specs and project constraints - Update model IDs to latest family (sonnet-4-5, haiku-4-5, opus-4-6) and pricing table - Rewrite buildAgentPrompt() with structured template + spec context injection - Fix async command registration race condition (await lazy imports before program.parse) - Fix skills.ts version.js import (lazy resolution from package.json) - Consolidate tests from 518 → 498 without losing coverage
1 parent 5fda90b commit fca84e6

15 files changed

Lines changed: 1830 additions & 284 deletions

File tree

.claude/hooks/on-task-complete.js

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77

88
import { ChromaDBContextSaver, TRIGGER_EVENTS } from './chromadb-save-hook.js';
99
import fs from 'fs';
10+
import path from 'path';
1011

1112
async function onTaskComplete() {
1213
try {
1314
// Read Claude's input about the completed task
1415
const input = JSON.parse(fs.readFileSync(0, 'utf-8'));
15-
16+
1617
const saver = new ChromaDBContextSaver();
17-
18+
1819
// Save context about task completion
1920
await saver.saveContext(TRIGGER_EVENTS.TASK_COMPLETE, {
2021
task: input.task || input.description || 'Unknown task',
@@ -24,19 +25,53 @@ async function onTaskComplete() {
2425
summary: input.summary || '',
2526
nextSteps: input.nextSteps || [],
2627
});
27-
28+
2829
// Also update Linear if it's a STA task
2930
if (input.task && input.task.includes('STA-')) {
30-
const { LinearUpdateSkill } = await import('../../../scripts/claude-linear-skill.js');
31+
const { LinearUpdateSkill } =
32+
await import('../../../scripts/claude-linear-skill.js');
3133
const skill = new LinearUpdateSkill();
32-
34+
3335
if (skill.apiKey) {
3436
await skill.processUpdate(`${input.task} is completed`, {
3537
comment: input.summary,
3638
});
3739
}
3840
}
39-
41+
42+
// Auto-update PROMPT_PLAN checkboxes if spec exists
43+
const promptPlanPath = path.join(
44+
process.cwd(),
45+
'docs',
46+
'specs',
47+
'PROMPT_PLAN.md'
48+
);
49+
if (fs.existsSync(promptPlanPath) && input.task) {
50+
try {
51+
let content = fs.readFileSync(promptPlanPath, 'utf-8');
52+
// Find unchecked items matching the task title (fuzzy match on keywords)
53+
const taskWords = input.task.split(/\s+/).filter((w) => w.length > 3);
54+
const lines = content.split('\n');
55+
let updated = false;
56+
for (let i = 0; i < lines.length; i++) {
57+
if (
58+
lines[i].includes('- [ ]') &&
59+
taskWords.some((w) =>
60+
lines[i].toLowerCase().includes(w.toLowerCase())
61+
)
62+
) {
63+
lines[i] = lines[i].replace('- [ ]', '- [x]');
64+
updated = true;
65+
break; // Only check off one item per task completion
66+
}
67+
}
68+
if (updated) {
69+
fs.writeFileSync(promptPlanPath, lines.join('\n'));
70+
}
71+
} catch (_e) {
72+
// Silently fail - PROMPT_PLAN update is best-effort
73+
}
74+
}
4075
} catch (error) {
4176
// Silently fail to not block Claude
4277
fs.appendFileSync(
@@ -46,4 +81,4 @@ async function onTaskComplete() {
4681
}
4782
}
4883

49-
onTaskComplete();
84+
onTaskComplete();

.claude/hooks/skill-rules.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,36 @@
239239
],
240240
"contentPatterns": ["performance\\.now", "console\\.time", "profiler"]
241241
}
242+
},
243+
"spec-generator": {
244+
"description": "Iterative spec document generation (one-pager, dev-spec, prompt-plan, agents)",
245+
"priority": 8,
246+
"triggers": {
247+
"keywords": ["spec", "one-pager", "dev-spec", "prompt-plan", "agents.md", "scaffold"],
248+
"keywordPatterns": ["\\bspec\\b", "one.pager", "dev.spec", "prompt.plan"],
249+
"pathPatterns": ["docs/specs/**", "**/AGENTS.md", "**/ONE_PAGER.md", "**/PROMPT_PLAN.md"],
250+
"intentPatterns": [
251+
"(?:generate|create).*(?:spec|one-pager|dev-spec)",
252+
"(?:spec).*(?:generate|validate|update|list)"
253+
],
254+
"contentPatterns": ["SpecGeneratorSkill", "ONE_PAGER", "DEV_SPEC", "PROMPT_PLAN"]
255+
},
256+
"relatedSkills": ["linear-task-runner"]
257+
},
258+
"linear-task-runner": {
259+
"description": "Execute Linear tasks via RLM orchestrator",
260+
"priority": 8,
261+
"triggers": {
262+
"keywords": ["linear-run", "run task", "execute task", "task runner", "ralph linear"],
263+
"keywordPatterns": ["linear.run", "run.*task", "task.*runner"],
264+
"pathPatterns": ["**/linear-task-runner.ts"],
265+
"intentPatterns": [
266+
"(?:run|execute).*(?:linear|task)",
267+
"(?:linear).*(?:run|execute|next|all)"
268+
],
269+
"contentPatterns": ["LinearTaskRunner", "runNext", "runAll", "runTask"]
270+
},
271+
"relatedSkills": ["spec-generator", "linear-integration"]
242272
}
243273
}
244274
}

.claude/skills/linear-run.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Linear Task Runner Skill
2+
3+
## Description
4+
Execute Linear tasks using the RLM (Recursive Language Model) orchestrator.
5+
Pulls tasks from Linear, decomposes via subagents, executes, and updates status.
6+
7+
## Usage
8+
9+
### Run next task
10+
```
11+
/linear-run next
12+
/linear-run next --priority high
13+
/linear-run next --tag backend
14+
```
15+
16+
### Run all tasks
17+
```
18+
/linear-run all
19+
/linear-run all --dry-run
20+
/linear-run all --maxConcurrent 3
21+
```
22+
23+
### Run specific task
24+
```
25+
/linear-run task STA-123
26+
/linear-run task <task-id>
27+
```
28+
29+
### Preview execution plan
30+
```
31+
/linear-run preview
32+
/linear-run preview STA-123
33+
```
34+
35+
## Execution Flow
36+
37+
1. Fetch todo tasks from Linear (sorted by priority)
38+
2. Mark task as `in_progress`
39+
3. RLM Orchestrator decomposes task into subagent tree
40+
- Planning agent breaks down the work
41+
- Code/Test/Review subagents execute in parallel
42+
- Multi-stage quality review
43+
4. On success: mark task `done`, sync to Linear
44+
5. On failure: leave as `in_progress`, log error
45+
6. If PROMPT_PLAN exists, auto-check completed items
46+
47+
## Options
48+
- `--priority <level>` — Filter tasks: urgent, high, medium, low
49+
- `--tag <tag>` — Filter tasks by tag
50+
- `--dry-run` — Show plan without executing
51+
- `--maxConcurrent <n>` — Parallel task limit (default: 1, sequential)
52+
53+
## Integration
54+
- **Linear**: Reads tasks, updates status, syncs changes
55+
- **RLM Orchestrator**: Decomposes and executes via Claude Code subagents
56+
- **Spec Generator**: Auto-updates PROMPT_PLAN checkboxes on completion
57+
58+
## CLI Equivalent
59+
```bash
60+
stackmemory ralph linear next
61+
stackmemory ralph linear all
62+
stackmemory ralph linear preview STA-123
63+
```

.claude/skills/spec.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Spec Generator Skill
2+
3+
## Description
4+
Generate iterative spec documents following the 4-doc VibeScaffold pattern:
5+
ONE_PAGER → DEV_SPEC → PROMPT_PLAN → AGENTS.md
6+
7+
Later documents automatically read earlier ones from disk (progressive context).
8+
All specs are written to `docs/specs/` and tracked in git.
9+
10+
## Usage
11+
12+
### Generate a spec
13+
```
14+
/spec one-pager "Photo Captioner App"
15+
/spec dev-spec
16+
/spec prompt-plan
17+
/spec agents
18+
```
19+
20+
### Interactive mode (no arguments)
21+
```
22+
/spec
23+
```
24+
Prompts for spec type and title interactively.
25+
26+
### List existing specs
27+
```
28+
/spec list
29+
```
30+
31+
### Update (check off items)
32+
```
33+
/spec update prompt-plan "Initialize repository and tooling"
34+
/spec update prompt-plan "Stage A:1"
35+
```
36+
37+
### Validate completeness
38+
```
39+
/spec validate prompt-plan
40+
/spec validate dev-spec
41+
```
42+
43+
## Spec Types
44+
45+
| Type | Output | Reads From |
46+
|------|--------|------------|
47+
| `one-pager` | `docs/specs/ONE_PAGER.md` ||
48+
| `dev-spec` | `docs/specs/DEV_SPEC.md` | ONE_PAGER |
49+
| `prompt-plan` | `docs/specs/PROMPT_PLAN.md` | ONE_PAGER, DEV_SPEC |
50+
| `agents` | `AGENTS.md` | ONE_PAGER, DEV_SPEC, PROMPT_PLAN |
51+
52+
## Sections
53+
54+
### ONE_PAGER
55+
Problem, Audience, Platform, Core Flow, MVP Features, Non-Goals, Metrics
56+
57+
### DEV_SPEC
58+
Architecture, Tech Stack, API Contracts, Data Models, Auth, Error Handling, Deployment
59+
60+
### PROMPT_PLAN
61+
Stages A-G with `- [ ]` TDD checkboxes per prompt. Check off as tasks complete.
62+
63+
### AGENTS.md
64+
Repo Files, Responsibilities, Guardrails, Testing, When to Ask
65+
66+
## Options
67+
- `--force` — Overwrite existing spec file
68+
69+
## Workflow
70+
1. Start with `/spec one-pager "My App"` to capture the idea
71+
2. Generate `/spec dev-spec` — reads ONE_PAGER for context
72+
3. Generate `/spec prompt-plan` — creates implementation checklist
73+
4. Generate `/spec agents` — creates agent configuration
74+
5. As tasks complete, `/spec update prompt-plan "task name"` checks items off
75+
6. `/spec validate prompt-plan` verifies all items done

0 commit comments

Comments
 (0)