Skip to content

Commit 034c997

Browse files
author
StackMemory Bot (CLI)
committed
docs(readme): add skills, hooks, and spec system usage guidelines
Update README with Skills System (/spec, /linear-run), Hooks (automatic task tracking, skill-eval, PROMPT_PLAN auto-progress), and Prompt Forge sections. Add hook templates for on-task-complete, skill-eval, and skill-rules.json to auto-install during npm install. Update package.json keywords and description for npm discoverability.
1 parent 5efbcd3 commit 034c997

8 files changed

Lines changed: 979 additions & 57 deletions

File tree

README.md

Lines changed: 136 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ StackMemory is a **production-ready memory runtime** for AI coding tools that pr
1414
- **Full Linear integration** with bidirectional sync
1515
- **Context persistence** that survives /clear operations
1616
- **Hierarchical frame organization** (nested call stack model)
17-
- **490 tests passing** with comprehensive coverage
17+
- **Skills system** with `/spec` and `/linear-run` for Claude Code
18+
- **Automatic hooks** for task tracking, Linear sync, and spec progress
19+
- **498 tests passing** with comprehensive coverage
1820

1921
Instead of a linear chat log, StackMemory organizes memory as a **call stack** of scoped work (frames), with intelligent LLM-driven retrieval and team collaboration features.
2022

@@ -34,13 +36,13 @@ Tools forget decisions and constraints between sessions. StackMemory makes conte
3436

3537
## Features (at a glance)
3638

37-
- MCP tools for Claude Code: 26+ tools; context on every request
38-
- Safe branches: worktree isolation with `--worktree` or `-w`
39-
- Persistent context: frames, anchors, decisions, retrieval
40-
- Optional boosts: model routing, prompt optimization (GEPA)
41-
- Integrations: Linear, Greptile, DiffMem, Browser MCP
42-
43-
See the docs directory for deeper feature guides.
39+
- **MCP tools** for Claude Code: 26+ tools; context on every request
40+
- **Skills**: `/spec` (iterative spec generation), `/linear-run` (task execution via RLM)
41+
- **Hooks**: automatic context save, task tracking, Linear sync, PROMPT_PLAN updates
42+
- **Prompt Forge**: watches AGENTS.md and CLAUDE.md for prompt optimization (GEPA)
43+
- **Safe branches**: worktree isolation with `--worktree` or `-w`
44+
- **Persistent context**: frames, anchors, decisions, retrieval
45+
- **Integrations**: Linear, Greptile, DiffMem, Browser MCP
4446

4547
---
4648

@@ -131,13 +133,127 @@ Env defaults (optional):
131133

132134
---
133135

134-
## Quick Start
136+
## Skills System
137+
138+
StackMemory ships Claude Code skills that integrate directly into your workflow. Skills are invoked via `/skill-name` in Claude Code or `stackmemory skills <name>` from the CLI.
139+
140+
### Spec Generator (`/spec`)
141+
142+
Generates iterative spec documents following a 4-doc progressive chain. Each document reads previous ones from disk for context.
143+
144+
```
145+
ONE_PAGER.md → DEV_SPEC.md → PROMPT_PLAN.md → AGENTS.md
146+
(standalone) (reads 1) (reads 1+2) (reads 1+2+3)
147+
```
148+
149+
```bash
150+
# Generate specs in order
151+
/spec one-pager "My App" # Problem, audience, core flow, MVP
152+
/spec dev-spec # Architecture, tech stack, APIs
153+
/spec prompt-plan # TDD stages A-G with checkboxes
154+
/spec agents # Agent guardrails and responsibilities
155+
156+
# Manage progress
157+
/spec list # Show existing specs
158+
/spec update prompt-plan "auth" # Check off matching items
159+
/spec validate prompt-plan # Check completion status
160+
161+
# CLI equivalent
162+
stackmemory skills spec one-pager "My App"
163+
```
164+
165+
Output goes to `docs/specs/`. Use `--force` to regenerate an existing spec.
166+
167+
### Linear Task Runner (`/linear-run`)
168+
169+
Pulls tasks from Linear, executes them via the RLM orchestrator (8 subagent types), and syncs results back.
170+
171+
```bash
172+
/linear-run next # Execute next todo task
173+
/linear-run next --priority high # Filter by priority
174+
/linear-run all # Execute all pending tasks
175+
/linear-run all --dry-run # Preview without executing
176+
/linear-run task STA-123 # Run a specific task
177+
/linear-run preview # Show execution plan
178+
179+
# CLI equivalent
180+
stackmemory ralph linear next
181+
```
182+
183+
On task completion:
184+
1. Marks the Linear task as `done`
185+
2. Auto-checks matching PROMPT_PLAN items
186+
3. Syncs metrics (tokens, cost, tests) back to Linear
187+
188+
Options: `--priority <level>`, `--tag <tag>`, `--dry-run`, `--maxConcurrent <n>`
189+
190+
---
191+
192+
## Hooks (Automatic)
193+
194+
StackMemory installs Claude Code hooks that run automatically during your session. Hooks are non-blocking and fail silently to never interrupt your workflow.
195+
196+
### Installed Hooks
197+
198+
| Hook | Trigger | What it does |
199+
|------|---------|-------------|
200+
| `on-task-complete` | Task marked done | Saves context, syncs Linear (STA-* tasks), auto-checks PROMPT_PLAN items |
201+
| `on-startup` | Session start | Loads StackMemory context, initializes frame |
202+
| `on-clear` | `/clear` command | Persists context before clearing |
203+
| `skill-eval` | User prompt | Scores prompt against 28 skill patterns, recommends relevant skills |
204+
| `tool-use-trace` | Tool invocation | Logs tool usage for context tracking |
205+
206+
### Skill Evaluation
207+
208+
When you type a prompt, the `skill-eval` hook scores it against `skill-rules.json` (28 mapped skills with keyword, pattern, intent, and directory matching). Skills scoring above the threshold (default: 3) are recommended.
209+
210+
```json
211+
// Example: user types "generate a spec for the auth system"
212+
// skill-eval recommends:
213+
{
214+
"recommendedSkills": [
215+
{ "skillName": "spec-generator", "score": 8 },
216+
{ "skillName": "frame-management", "score": 5 }
217+
]
218+
}
219+
```
220+
221+
### Hook Installation
222+
223+
Hooks install automatically during `npm install` (with user consent). To install or reinstall manually:
224+
225+
```bash
226+
# Automatic (prompted during npm install)
227+
npm install -g @stackmemoryai/stackmemory
228+
229+
# Manual install
230+
stackmemory hooks install
135231

136-
See above for install and minimal usage. For advanced options, see Setup.
232+
# Skip hooks (CI/non-interactive)
233+
STACKMEMORY_AUTO_HOOKS=true npm install -g @stackmemoryai/stackmemory
234+
```
235+
236+
Hooks are stored in `~/.claude/hooks/` and configured via `~/.claude/hooks.json`.
237+
238+
### PROMPT_PLAN Auto-Progress
239+
240+
When a task completes (via hook or `/linear-run`), StackMemory fuzzy-matches the task title against unchecked `- [ ]` items in `docs/specs/PROMPT_PLAN.md` and checks them off automatically. One item per task completion, best-effort.
137241

138242
---
139243

140-
## 2. Detailed Setup
244+
## Prompt Forge (GEPA)
245+
246+
When launching via `claude-sm`, StackMemory watches `CLAUDE.md`, `AGENT.md`, and `AGENTS.md` for changes. On file modification, the GEPA optimizer analyzes content and suggests improvements for prompt clarity and structure. Runs as a detached background process.
247+
248+
```bash
249+
# Launch with Prompt Forge active
250+
claude-sm
251+
252+
# Status shown in terminal:
253+
# Prompt Forge: watching CLAUDE.md, AGENTS.md for optimization
254+
```
255+
256+
---
141257

142258
### Install
143259

@@ -180,15 +296,11 @@ stackmemory doctor
180296

181297
Checks project initialization, database integrity, MCP config, and suggests fixes.
182298

183-
---
184-
185-
## 3. Advanced Setup
186-
187-
See https://github.com/stackmemoryai/stackmemory/blob/main/docs/setup.md for advanced options (hosted mode, ChromaDB, manual MCP config, and available tools).
299+
See [docs/setup.md](https://github.com/stackmemoryai/stackmemory/blob/main/docs/setup.md) for advanced options (hosted mode, ChromaDB, manual MCP config).
188300

189301
---
190302

191-
## 2. Open-Source Local Mode
303+
## Open-Source Local Mode
192304

193305
### Step 1: Clone & Build
194306

@@ -285,35 +397,17 @@ StackMemory implements an intelligent two-tier storage architecture:
285397

286398
## Claude Code Integration
287399

288-
StackMemory can automatically save context when using Claude Code, so your AI assistant has access to previous context and decisions.
289-
290-
### Quick Setup
400+
StackMemory integrates with Claude Code via MCP tools, skills, and hooks. See the [Hooks](#hooks-automatic) and [Skills](#skills-system) sections above.
291401

292402
```bash
293-
# Add alias
294-
echo 'alias claude="~/Dev/stackmemory/scripts/claude-code-wrapper.sh"' >> ~/.zshrc
295-
source ~/.zshrc
296-
297-
# Use: claude (saves context on exit)
298-
```
299-
300-
### Integration Methods
301-
302-
```bash
303-
# 1. Shell wrapper (recommended)
304-
claude [--auto-sync] [--sync-interval=10]
305-
306-
# 2. Linear auto-sync daemon
307-
./scripts/linear-auto-sync.sh start [interval]
308-
309-
# 3. Background daemon
310-
./scripts/stackmemory-daemon.sh [interval] &
311-
312-
# 4. Git hooks
313-
./scripts/setup-git-hooks.sh
403+
# Full setup (one-time)
404+
npm install -g @stackmemoryai/stackmemory # installs hooks automatically
405+
cd your-project && stackmemory init # init project
406+
stackmemory setup-mcp # configure MCP
407+
stackmemory doctor # verify everything works
314408
```
315409

316-
**Features:** Auto-save on exit, Linear sync, runs only in StackMemory projects, configurable sync intervals.
410+
Additional integration methods: shell wrapper (`claude-sm`), Linear auto-sync daemon, background daemon, git hooks. See [docs/setup.md](https://github.com/stackmemoryai/stackmemory/blob/main/docs/setup.md).
317411

318412
## RLM (Recursive Language Model) Orchestration
319413

package.json

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@stackmemoryai/stackmemory",
33
"version": "0.5.67",
4-
"description": "Project-scoped memory for AI coding tools. Durable context across sessions with MCP integration, frames, and smart retrieval.",
4+
"description": "Project-scoped memory for AI coding tools. Durable context across sessions with MCP integration, frames, smart retrieval, Claude Code skills, and automatic hooks.",
55
"engines": {
66
"node": ">=20.0.0",
77
"npm": ">=10.0.0"
@@ -42,12 +42,17 @@
4242
"llm",
4343
"mcp",
4444
"claude",
45+
"claude-code",
4546
"coding",
4647
"persistence",
47-
"code-review",
48-
"predictive-edit",
48+
"skills",
49+
"hooks",
50+
"spec-generator",
51+
"linear",
52+
"task-runner",
4953
"prompt-optimization",
50-
"model-routing"
54+
"model-routing",
55+
"agent-orchestration"
5156
],
5257
"scripts": {
5358
"start": "node dist/src/integrations/mcp/server.js",

scripts/install-claude-hooks-auto.js

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ async function askForConsent() {
5858
console.log(' - Track tool usage for better context');
5959
console.log(' - Enable session persistence across restarts');
6060
console.log(' - Sync context with Linear (optional)');
61+
console.log(' - Auto-update PROMPT_PLAN on task completion');
62+
console.log(' - Recommend relevant skills based on your prompts');
6163
console.log('\nThis will modify files in ~/.claude/\n');
6264

6365
return new Promise((resolve) => {
@@ -89,11 +91,19 @@ async function installClaudeHooks() {
8991
console.log('Created ~/.claude/hooks directory');
9092
}
9193

92-
// Copy hook files
93-
const hookFiles = ['tool-use-trace.js', 'on-startup.js', 'on-clear.js'];
94+
// Copy hook files (scripts + data files)
95+
const hookFiles = [
96+
'tool-use-trace.js',
97+
'on-startup.js',
98+
'on-clear.js',
99+
'on-task-complete.js',
100+
'skill-eval.sh',
101+
'skill-eval.cjs',
102+
];
103+
const dataFiles = ['skill-rules.json'];
94104
let installed = 0;
95105

96-
for (const hookFile of hookFiles) {
106+
for (const hookFile of [...hookFiles, ...dataFiles]) {
97107
const srcPath = join(templatesDir, hookFile);
98108
const destPath = join(claudeHooksDir, hookFile);
99109

@@ -107,12 +117,14 @@ async function installClaudeHooks() {
107117

108118
copyFileSync(srcPath, destPath);
109119

110-
// Make executable
111-
try {
112-
const { execSync } = await import('child_process');
113-
execSync(`chmod +x "${destPath}"`, { stdio: 'ignore' });
114-
} catch {
115-
// Silent fail on chmod
120+
// Make executable (scripts only, not data files)
121+
if (!dataFiles.includes(hookFile)) {
122+
try {
123+
const { execSync } = await import('child_process');
124+
execSync(`chmod +x "${destPath}"`, { stdio: 'ignore' });
125+
} catch {
126+
// Silent fail on chmod
127+
}
116128
}
117129

118130
installed++;
@@ -136,6 +148,8 @@ async function installClaudeHooks() {
136148
'tool-use-approval': join(claudeHooksDir, 'tool-use-trace.js'),
137149
'on-startup': join(claudeHooksDir, 'on-startup.js'),
138150
'on-clear': join(claudeHooksDir, 'on-clear.js'),
151+
'on-task-complete': join(claudeHooksDir, 'on-task-complete.js'),
152+
'user-prompt-submit': join(claudeHooksDir, 'skill-eval.sh'),
139153
};
140154

141155
writeFileSync(claudeConfigFile, JSON.stringify(newHooksConfig, null, 2));

templates/claude-hooks/hooks.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"tool-use-approval": "~/.claude/hooks/tool-use-trace.js",
33
"on-startup": "~/.claude/hooks/on-startup.js",
4-
"on-clear": "~/.claude/hooks/on-clear.js"
5-
}
4+
"on-clear": "~/.claude/hooks/on-clear.js",
5+
"on-task-complete": "~/.claude/hooks/on-task-complete.js",
6+
"user-prompt-submit": "~/.claude/hooks/skill-eval.sh"
7+
}

0 commit comments

Comments
 (0)