unsevered-memory 2.0.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.
- package/LICENSE +21 -0
- package/README.md +238 -0
- package/bin/cli.js +27 -0
- package/package.json +41 -0
- package/setup-global.sh +578 -0
- package/skills/orchestrate/SKILL.md +229 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 blas0
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<img src="Unsevered.jpeg" alt="Unsevered Memory" width="200">
|
|
4
|
+
|
|
5
|
+
# Unsevered Memory
|
|
6
|
+
|
|
7
|
+
   
|
|
8
|
+
|
|
9
|
+
A markdown-based memory system for Claude Code with enforced persistence.
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Changelog
|
|
14
|
+
|
|
15
|
+
- Added support for Claude plugins + npx packaging
|
|
16
|
+
|
|
17
|
+
## What Makes This Different
|
|
18
|
+
|
|
19
|
+
Most memory systems inject context at session start and hope Claude remembers. This doesn't work because:
|
|
20
|
+
|
|
21
|
+
1. Context compaction loses early instructions
|
|
22
|
+
2. Claude has no obligation to follow suggestions
|
|
23
|
+
3. Long sessions forget the protocol
|
|
24
|
+
|
|
25
|
+
**Unsevered Memory solves this with enforcement:**
|
|
26
|
+
|
|
27
|
+
| Hook | When | Purpose |
|
|
28
|
+
|------|------|---------|
|
|
29
|
+
| `SessionStart` | Session begins | Load full context |
|
|
30
|
+
| `UserPromptSubmit` | Every prompt | Inject state reminder |
|
|
31
|
+
| `SessionEnd` | Session ends | Archive + remind |
|
|
32
|
+
|
|
33
|
+
The `UserPromptSubmit` hook survives context compaction by being injected fresh on every message.
|
|
34
|
+
|
|
35
|
+
## Architecture
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
Enforcement Layer
|
|
39
|
+
├── SessionStart ──────> Load context.md + scratchpad
|
|
40
|
+
├── UserPromptSubmit ──> [Memory] Task: X | Scratchpad: Y lines
|
|
41
|
+
└── SessionEnd ────────> Archive scratchpad, remind to update
|
|
42
|
+
|
|
43
|
+
File Structure
|
|
44
|
+
├── .claude/memory/ # Dynamic (every session)
|
|
45
|
+
│ ├── context.md # Current state, next steps
|
|
46
|
+
│ ├── scratchpad.md # Live session operations
|
|
47
|
+
│ ├── decisions.md # Architectural choices
|
|
48
|
+
│ └── sessions/ # Daily archives
|
|
49
|
+
│
|
|
50
|
+
└── .ai/ # Static (when patterns emerge)
|
|
51
|
+
├── core/ # Tech stack, architecture
|
|
52
|
+
├── patterns/ # Reusable solutions (after 3+ uses)
|
|
53
|
+
└── workflows/ # Dev processes
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
Choose your preferred method:
|
|
59
|
+
|
|
60
|
+
### Option A: Claude Plugin (Recommended)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Add marketplace
|
|
64
|
+
/plugin marketplace add blas0/UnseveredMemory
|
|
65
|
+
|
|
66
|
+
# Install plugin
|
|
67
|
+
/plugin install unsevered-memory@blas0
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Then per-project:
|
|
71
|
+
```bash
|
|
72
|
+
cd /path/to/your/project
|
|
73
|
+
/unsevered-memory project
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Option B: npx
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Global setup
|
|
80
|
+
npx unsevered-memory init
|
|
81
|
+
|
|
82
|
+
# Per-project setup
|
|
83
|
+
cd /path/to/your/project
|
|
84
|
+
npx unsevered-memory project
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Option C: Manual
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
git clone https://github.com/blas0/UnseveredMemory.git
|
|
91
|
+
cd UnseveredMemory
|
|
92
|
+
./setup-global.sh
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Then per-project:
|
|
96
|
+
```bash
|
|
97
|
+
cd /path/to/your/project
|
|
98
|
+
~/.claude/setup-project.sh
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### What Gets Installed
|
|
102
|
+
|
|
103
|
+
**Global** (`~/.claude/`):
|
|
104
|
+
- `CLAUDE.md` - Global memory protocol
|
|
105
|
+
- `settings.json` - Hook configuration (3 hooks)
|
|
106
|
+
- `hooks/` - memory-load, memory-remind, memory-save
|
|
107
|
+
- `skills/orchestrate/` - Workflow instructions
|
|
108
|
+
- `commands/orchestrate.md` - Orchestrator command
|
|
109
|
+
|
|
110
|
+
**Per-Project**:
|
|
111
|
+
```
|
|
112
|
+
project/
|
|
113
|
+
├── CLAUDE.md # Project instructions
|
|
114
|
+
├── .ai/ # Static documentation
|
|
115
|
+
│ ├── core/
|
|
116
|
+
│ │ ├── technology-stack.md
|
|
117
|
+
│ │ └── architecture.md
|
|
118
|
+
│ ├── patterns/
|
|
119
|
+
│ └── workflows/
|
|
120
|
+
└── .claude/
|
|
121
|
+
└── memory/
|
|
122
|
+
├── context.md # Cross-session state
|
|
123
|
+
├── scratchpad.md # Live session log
|
|
124
|
+
├── decisions.md # Decision log
|
|
125
|
+
└── sessions/ # Daily archives
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Workflow
|
|
129
|
+
|
|
130
|
+
### Session Start
|
|
131
|
+
1. Hook loads `context.md` and `scratchpad.md`
|
|
132
|
+
2. Claude sees current state and any unfinished work
|
|
133
|
+
3. Hook hints about `.ai/` documentation
|
|
134
|
+
|
|
135
|
+
### During Session
|
|
136
|
+
Every prompt shows:
|
|
137
|
+
```
|
|
138
|
+
[Memory] Task: Fix auth bug | Scratchpad: 24 lines | .ai/ updated: 2024-01-15
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Claude writes to `scratchpad.md` as it works:
|
|
142
|
+
```markdown
|
|
143
|
+
## Session: 2024-01-15 14:30
|
|
144
|
+
|
|
145
|
+
### Operations
|
|
146
|
+
- [14:35] Found issue in validateToken() at src/auth.ts:142
|
|
147
|
+
- [14:40] Fixed: was comparing wrong field
|
|
148
|
+
|
|
149
|
+
### Decisions
|
|
150
|
+
- Keep backward compatibility by checking both fields
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Claude updates `.ai/` when patterns emerge (3+ uses).
|
|
154
|
+
|
|
155
|
+
### Session End
|
|
156
|
+
1. Hook archives scratchpad to `sessions/YYYY-MM-DD.md`
|
|
157
|
+
2. Hook reminds to update `context.md`
|
|
158
|
+
3. Claude updates context with current state
|
|
159
|
+
|
|
160
|
+
## Orchestrator Mode
|
|
161
|
+
|
|
162
|
+
For complex multi-step tasks:
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
/orchestrate Implement user authentication with JWT
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
The orchestrator:
|
|
169
|
+
1. Reads all memory files
|
|
170
|
+
2. Breaks task into subtasks
|
|
171
|
+
3. Delegates to specialized agents
|
|
172
|
+
4. Updates memory after each step
|
|
173
|
+
5. Never loses context
|
|
174
|
+
|
|
175
|
+
## File Purposes
|
|
176
|
+
|
|
177
|
+
| File | Content | Update Frequency |
|
|
178
|
+
|------|---------|------------------|
|
|
179
|
+
| `context.md` | Current state, next steps | End of session |
|
|
180
|
+
| `scratchpad.md` | Operations, findings | During session |
|
|
181
|
+
| `decisions.md` | Architectural choices | When decisions made |
|
|
182
|
+
| `.ai/core/` | Tech stack, architecture | When they change |
|
|
183
|
+
| `.ai/patterns/` | Reusable solutions | After 3+ uses |
|
|
184
|
+
|
|
185
|
+
## Repository Structure
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
UnseveredMemory/
|
|
189
|
+
├── .claude-plugin/ # Plugin manifest
|
|
190
|
+
│ ├── plugin.json
|
|
191
|
+
│ └── marketplace.json
|
|
192
|
+
├── package.json # npm package
|
|
193
|
+
├── bin/cli.js # npx entry point
|
|
194
|
+
├── src/commands/ # CLI commands
|
|
195
|
+
├── setup-global.sh # Manual installer
|
|
196
|
+
├── scripts/ # Hook scripts (plugin)
|
|
197
|
+
├── hooks/ # Hook scripts + hooks.json
|
|
198
|
+
├── skills/
|
|
199
|
+
│ └── orchestrate/
|
|
200
|
+
│ └── SKILL.md
|
|
201
|
+
├── commands/
|
|
202
|
+
│ └── orchestrate.md
|
|
203
|
+
└── templates/
|
|
204
|
+
└── [all templates]
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
## Philosophy
|
|
208
|
+
|
|
209
|
+
- **Enforced** - UserPromptSubmit hook survives context compaction
|
|
210
|
+
- **Simple** - Bash + markdown, no databases, no APIs
|
|
211
|
+
- **Offline** - Everything is local files
|
|
212
|
+
- **Native** - Uses Claude Code's built-in hooks system
|
|
213
|
+
- **Proactive** - Claude updates .ai/ during work, not after
|
|
214
|
+
|
|
215
|
+
## Enforcement Levels
|
|
216
|
+
|
|
217
|
+
| Approach | Reliability |
|
|
218
|
+
|----------|-------------|
|
|
219
|
+
| CLAUDE.md only | ~30% |
|
|
220
|
+
| + SessionStart | ~50% |
|
|
221
|
+
| + UserPromptSubmit | ~75% |
|
|
222
|
+
| + /orchestrate orchestrator | ~95% |
|
|
223
|
+
|
|
224
|
+
## Uninstall
|
|
225
|
+
|
|
226
|
+
```bash
|
|
227
|
+
# npx
|
|
228
|
+
npx unsevered-memory uninstall
|
|
229
|
+
|
|
230
|
+
# Manual
|
|
231
|
+
rm -rf ~/.claude/hooks/memory-*.sh
|
|
232
|
+
rm -rf ~/.claude/skills/orchestrate
|
|
233
|
+
rm -rf ~/.claude/commands/orchestrate.md
|
|
234
|
+
|
|
235
|
+
# Project files (optional)
|
|
236
|
+
rm -rf .claude/memory
|
|
237
|
+
rm -rf .ai
|
|
238
|
+
```
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const { program } = require('commander');
|
|
4
|
+
const { init, project, uninstall } = require('../src/commands');
|
|
5
|
+
|
|
6
|
+
program
|
|
7
|
+
.name('unsevered-memory')
|
|
8
|
+
.description('Persistent memory system for Claude Code')
|
|
9
|
+
.version('2.0.0');
|
|
10
|
+
|
|
11
|
+
program
|
|
12
|
+
.command('init')
|
|
13
|
+
.description('Install globally to ~/.claude/')
|
|
14
|
+
.action(init);
|
|
15
|
+
|
|
16
|
+
program
|
|
17
|
+
.command('project')
|
|
18
|
+
.description('Set up memory in current project')
|
|
19
|
+
.option('-p, --path <path>', 'Project path', '.')
|
|
20
|
+
.action(project);
|
|
21
|
+
|
|
22
|
+
program
|
|
23
|
+
.command('uninstall')
|
|
24
|
+
.description('Remove global installation')
|
|
25
|
+
.action(uninstall);
|
|
26
|
+
|
|
27
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "unsevered-memory",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Persistent memory system for Claude Code with enforced context",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"unsevered-memory": "./bin/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/blas0/UnseveredMemory.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"claude",
|
|
18
|
+
"claude-code",
|
|
19
|
+
"memory",
|
|
20
|
+
"orchestrate",
|
|
21
|
+
"claude-skills",
|
|
22
|
+
"claude-plugins",
|
|
23
|
+
"skills",
|
|
24
|
+
"plugins",
|
|
25
|
+
"ai",
|
|
26
|
+
"management",
|
|
27
|
+
"state",
|
|
28
|
+
"stateless",
|
|
29
|
+
"context",
|
|
30
|
+
"persistence"
|
|
31
|
+
],
|
|
32
|
+
"author": "blas0",
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/blas0/UnseveredMemory/issues"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/blas0/UnseveredMemory#readme",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"commander": "^12.0.0"
|
|
40
|
+
}
|
|
41
|
+
}
|
package/setup-global.sh
ADDED
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Unsevered Memory - Global Setup
|
|
3
|
+
# Installs memory system to ~/.claude/
|
|
4
|
+
# https://github.com/blas0/UnseveredMemory
|
|
5
|
+
|
|
6
|
+
set -e
|
|
7
|
+
|
|
8
|
+
# Colors (no emojis)
|
|
9
|
+
RED='\033[0;31m'
|
|
10
|
+
GREEN='\033[0;32m'
|
|
11
|
+
YELLOW='\033[1;33m'
|
|
12
|
+
BLUE='\033[0;34m'
|
|
13
|
+
NC='\033[0m' # No Color
|
|
14
|
+
|
|
15
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
16
|
+
CLAUDE_DIR="$HOME/.claude"
|
|
17
|
+
|
|
18
|
+
print_header() {
|
|
19
|
+
echo ""
|
|
20
|
+
echo -e "${BLUE}==========================================${NC}"
|
|
21
|
+
echo -e "${BLUE} Unsevered Memory - Global Setup${NC}"
|
|
22
|
+
echo -e "${BLUE}==========================================${NC}"
|
|
23
|
+
echo ""
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
print_step() {
|
|
27
|
+
echo -e "${YELLOW}[*]${NC} $1"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
print_success() {
|
|
31
|
+
echo -e "${GREEN}[+]${NC} $1"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
print_error() {
|
|
35
|
+
echo -e "${RED}[!]${NC} $1"
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
print_header
|
|
39
|
+
|
|
40
|
+
# 1. Create ~/.claude/ directory structure
|
|
41
|
+
print_step "Creating ~/.claude/ directory structure..."
|
|
42
|
+
mkdir -p "$CLAUDE_DIR/hooks"
|
|
43
|
+
mkdir -p "$CLAUDE_DIR/skills/orchestrate"
|
|
44
|
+
mkdir -p "$CLAUDE_DIR/commands"
|
|
45
|
+
print_success "Directory structure created"
|
|
46
|
+
|
|
47
|
+
# 2. Install hooks
|
|
48
|
+
print_step "Installing hooks..."
|
|
49
|
+
cp "$SCRIPT_DIR/hooks/memory-load.sh" "$CLAUDE_DIR/hooks/"
|
|
50
|
+
cp "$SCRIPT_DIR/hooks/memory-remind.sh" "$CLAUDE_DIR/hooks/"
|
|
51
|
+
cp "$SCRIPT_DIR/hooks/memory-save.sh" "$CLAUDE_DIR/hooks/"
|
|
52
|
+
cp "$SCRIPT_DIR/hooks/memory-precompact.sh" "$CLAUDE_DIR/hooks/"
|
|
53
|
+
cp "$SCRIPT_DIR/scripts/memory-manifest.sh" "$CLAUDE_DIR/hooks/"
|
|
54
|
+
chmod +x "$CLAUDE_DIR/hooks/"*.sh
|
|
55
|
+
print_success "Hooks installed (memory-load, memory-remind, memory-save, memory-precompact, memory-manifest)"
|
|
56
|
+
|
|
57
|
+
# 3. Install skill
|
|
58
|
+
print_step "Installing harness skill..."
|
|
59
|
+
cp "$SCRIPT_DIR/skills/orchestrate/SKILL.md" "$CLAUDE_DIR/skills/orchestrate/"
|
|
60
|
+
print_success "Skill installed"
|
|
61
|
+
|
|
62
|
+
# 4. Install command
|
|
63
|
+
print_step "Installing /orchestrate command..."
|
|
64
|
+
cp "$SCRIPT_DIR/commands/orchestrate.md" "$CLAUDE_DIR/commands/"
|
|
65
|
+
print_success "Command installed"
|
|
66
|
+
|
|
67
|
+
# 5. Configure settings.json (MERGE, don't overwrite)
|
|
68
|
+
print_step "Configuring hooks in settings.json..."
|
|
69
|
+
|
|
70
|
+
SETTINGS_FILE="$CLAUDE_DIR/settings.json"
|
|
71
|
+
|
|
72
|
+
if [ -f "$SETTINGS_FILE" ]; then
|
|
73
|
+
# Backup existing settings
|
|
74
|
+
cp "$SETTINGS_FILE" "$SETTINGS_FILE.backup"
|
|
75
|
+
print_step "Backed up existing settings.json"
|
|
76
|
+
|
|
77
|
+
# Check if jq is available for merging
|
|
78
|
+
if command -v jq &> /dev/null; then
|
|
79
|
+
# Merge hooks into existing settings using matcher format (empty string = match all)
|
|
80
|
+
TEMP_FILE=$(mktemp)
|
|
81
|
+
jq '.hooks.SessionStart = [{"matcher": "", "hooks": [{"type": "command", "command": "~/.claude/hooks/memory-load.sh"}]}] |
|
|
82
|
+
.hooks.UserPromptSubmit = [{"matcher": "", "hooks": [{"type": "command", "command": "~/.claude/hooks/memory-remind.sh"}]}] |
|
|
83
|
+
.hooks.PreCompact = [{"matcher": "", "hooks": [{"type": "command", "command": "~/.claude/hooks/memory-precompact.sh"}]}] |
|
|
84
|
+
.hooks.SessionEnd = [{"matcher": "", "hooks": [{"type": "command", "command": "~/.claude/hooks/memory-save.sh"}]}]' \
|
|
85
|
+
"$SETTINGS_FILE" > "$TEMP_FILE" && mv "$TEMP_FILE" "$SETTINGS_FILE"
|
|
86
|
+
print_success "Merged hooks into existing settings.json"
|
|
87
|
+
else
|
|
88
|
+
print_error "jq not found - cannot merge settings.json safely"
|
|
89
|
+
print_step "Please manually add hooks to settings.json"
|
|
90
|
+
print_step "See ~/.claude/settings.json.backup for original"
|
|
91
|
+
|
|
92
|
+
# Create a separate hooks file for reference
|
|
93
|
+
cat > "$CLAUDE_DIR/hooks-config.json" << 'HOOKS'
|
|
94
|
+
{
|
|
95
|
+
"hooks": {
|
|
96
|
+
"SessionStart": [{"matcher": "", "hooks": [{"type": "command", "command": "~/.claude/hooks/memory-load.sh"}]}],
|
|
97
|
+
"UserPromptSubmit": [{"matcher": "", "hooks": [{"type": "command", "command": "~/.claude/hooks/memory-remind.sh"}]}],
|
|
98
|
+
"PreCompact": [{"matcher": "", "hooks": [{"type": "command", "command": "~/.claude/hooks/memory-precompact.sh"}]}],
|
|
99
|
+
"SessionEnd": [{"matcher": "", "hooks": [{"type": "command", "command": "~/.claude/hooks/memory-save.sh"}]}]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
HOOKS
|
|
103
|
+
print_step "Hook configuration saved to ~/.claude/hooks-config.json"
|
|
104
|
+
fi
|
|
105
|
+
else
|
|
106
|
+
# No existing settings, create new
|
|
107
|
+
cat > "$SETTINGS_FILE" << 'SETTINGS'
|
|
108
|
+
{
|
|
109
|
+
"hooks": {
|
|
110
|
+
"SessionStart": [{"matcher": "", "hooks": [{"type": "command", "command": "~/.claude/hooks/memory-load.sh"}]}],
|
|
111
|
+
"UserPromptSubmit": [{"matcher": "", "hooks": [{"type": "command", "command": "~/.claude/hooks/memory-remind.sh"}]}],
|
|
112
|
+
"PreCompact": [{"matcher": "", "hooks": [{"type": "command", "command": "~/.claude/hooks/memory-precompact.sh"}]}],
|
|
113
|
+
"SessionEnd": [{"matcher": "", "hooks": [{"type": "command", "command": "~/.claude/hooks/memory-save.sh"}]}]
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
SETTINGS
|
|
117
|
+
print_success "Created settings.json with hooks"
|
|
118
|
+
fi
|
|
119
|
+
|
|
120
|
+
# 6. Install or update CLAUDE.md
|
|
121
|
+
print_step "Installing global CLAUDE.md..."
|
|
122
|
+
|
|
123
|
+
if [ -f "$CLAUDE_DIR/CLAUDE.md" ]; then
|
|
124
|
+
# Check if our marker exists
|
|
125
|
+
if grep -q "Unsevered Memory" "$CLAUDE_DIR/CLAUDE.md"; then
|
|
126
|
+
print_step "Updating existing CLAUDE.md..."
|
|
127
|
+
else
|
|
128
|
+
# Backup and append
|
|
129
|
+
cp "$CLAUDE_DIR/CLAUDE.md" "$CLAUDE_DIR/CLAUDE.md.backup"
|
|
130
|
+
print_step "Backed up existing CLAUDE.md"
|
|
131
|
+
fi
|
|
132
|
+
fi
|
|
133
|
+
|
|
134
|
+
cp "$SCRIPT_DIR/templates/CLAUDE.md.template" "$CLAUDE_DIR/CLAUDE.md"
|
|
135
|
+
print_success "Global CLAUDE.md installed"
|
|
136
|
+
|
|
137
|
+
# 7. Create project setup script
|
|
138
|
+
print_step "Creating project setup script..."
|
|
139
|
+
|
|
140
|
+
cat > "$CLAUDE_DIR/setup-project.sh" << 'PROJECT_SETUP'
|
|
141
|
+
#!/bin/bash
|
|
142
|
+
# Unsevered Memory - Project Setup
|
|
143
|
+
# Run this in any project directory to add memory support
|
|
144
|
+
|
|
145
|
+
set -e
|
|
146
|
+
|
|
147
|
+
RED='\033[0;31m'
|
|
148
|
+
GREEN='\033[0;32m'
|
|
149
|
+
YELLOW='\033[1;33m'
|
|
150
|
+
BLUE='\033[0;34m'
|
|
151
|
+
NC='\033[0m'
|
|
152
|
+
|
|
153
|
+
PROJECT_DIR="${1:-.}"
|
|
154
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
155
|
+
|
|
156
|
+
print_header() {
|
|
157
|
+
echo ""
|
|
158
|
+
echo -e "${BLUE}==========================================${NC}"
|
|
159
|
+
echo -e "${BLUE} Unsevered Memory - Project Setup${NC}"
|
|
160
|
+
echo -e "${BLUE}==========================================${NC}"
|
|
161
|
+
echo ""
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
print_step() {
|
|
165
|
+
echo -e "${YELLOW}[*]${NC} $1"
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
print_success() {
|
|
169
|
+
echo -e "${GREEN}[+]${NC} $1"
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
print_header
|
|
173
|
+
|
|
174
|
+
# Resolve project directory
|
|
175
|
+
PROJECT_DIR="$(cd "$PROJECT_DIR" && pwd)"
|
|
176
|
+
echo "Project: $PROJECT_DIR"
|
|
177
|
+
echo ""
|
|
178
|
+
|
|
179
|
+
# 1. Create .claude/memory/ structure
|
|
180
|
+
print_step "Creating .claude/memory/ structure..."
|
|
181
|
+
mkdir -p "$PROJECT_DIR/.claude/memory/sessions"
|
|
182
|
+
mkdir -p "$PROJECT_DIR/.claude/memory/checkpoints"
|
|
183
|
+
|
|
184
|
+
# Create memory files from templates or defaults
|
|
185
|
+
if [ ! -f "$PROJECT_DIR/.claude/memory/context.md" ]; then
|
|
186
|
+
cat > "$PROJECT_DIR/.claude/memory/context.md" << 'CONTEXT'
|
|
187
|
+
# Project Context
|
|
188
|
+
|
|
189
|
+
## Current State
|
|
190
|
+
|
|
191
|
+
[Project initialized with Unsevered Memory]
|
|
192
|
+
|
|
193
|
+
## Current Task
|
|
194
|
+
|
|
195
|
+
[No active task]
|
|
196
|
+
|
|
197
|
+
## Last Session
|
|
198
|
+
|
|
199
|
+
- Date: N/A
|
|
200
|
+
- Accomplished: Initial setup
|
|
201
|
+
- Stopped at: N/A
|
|
202
|
+
|
|
203
|
+
## Next Steps
|
|
204
|
+
|
|
205
|
+
1. Define project goals
|
|
206
|
+
2. Set up development environment
|
|
207
|
+
3. Begin implementation
|
|
208
|
+
|
|
209
|
+
## Notes
|
|
210
|
+
|
|
211
|
+
[Add project-specific notes here]
|
|
212
|
+
CONTEXT
|
|
213
|
+
print_success "Created context.md"
|
|
214
|
+
fi
|
|
215
|
+
|
|
216
|
+
if [ ! -f "$PROJECT_DIR/.claude/memory/scratchpad.md" ]; then
|
|
217
|
+
CURRENT_DATE=$(date '+%Y-%m-%d %H:%M')
|
|
218
|
+
cat > "$PROJECT_DIR/.claude/memory/scratchpad.md" << SCRATCHPAD
|
|
219
|
+
# Scratchpad
|
|
220
|
+
|
|
221
|
+
Session: $CURRENT_DATE
|
|
222
|
+
|
|
223
|
+
## Operations
|
|
224
|
+
|
|
225
|
+
- Project initialized with Unsevered Memory
|
|
226
|
+
|
|
227
|
+
## Findings
|
|
228
|
+
|
|
229
|
+
- N/A
|
|
230
|
+
|
|
231
|
+
## Decisions
|
|
232
|
+
|
|
233
|
+
- N/A
|
|
234
|
+
|
|
235
|
+
## Blockers
|
|
236
|
+
|
|
237
|
+
- None
|
|
238
|
+
|
|
239
|
+
## Next Steps
|
|
240
|
+
|
|
241
|
+
- Begin work
|
|
242
|
+
SCRATCHPAD
|
|
243
|
+
print_success "Created scratchpad.md"
|
|
244
|
+
fi
|
|
245
|
+
|
|
246
|
+
if [ ! -f "$PROJECT_DIR/.claude/memory/decisions.md" ]; then
|
|
247
|
+
cat > "$PROJECT_DIR/.claude/memory/decisions.md" << 'DECISIONS'
|
|
248
|
+
# Decision Log
|
|
249
|
+
|
|
250
|
+
Architectural and significant decisions for this project.
|
|
251
|
+
|
|
252
|
+
---
|
|
253
|
+
|
|
254
|
+
## Template
|
|
255
|
+
|
|
256
|
+
```markdown
|
|
257
|
+
## YYYY-MM-DD: [Decision Title]
|
|
258
|
+
|
|
259
|
+
**Context**: Why was this decision needed?
|
|
260
|
+
|
|
261
|
+
**Options Considered**:
|
|
262
|
+
1. Option A - pros/cons
|
|
263
|
+
2. Option B - pros/cons
|
|
264
|
+
|
|
265
|
+
**Decision**: What was chosen
|
|
266
|
+
|
|
267
|
+
**Rationale**: Why this option was selected
|
|
268
|
+
|
|
269
|
+
**Consequences**: What this means going forward
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Decisions
|
|
275
|
+
|
|
276
|
+
[Decisions will be appended below]
|
|
277
|
+
DECISIONS
|
|
278
|
+
print_success "Created decisions.md"
|
|
279
|
+
fi
|
|
280
|
+
|
|
281
|
+
# 2. Create .ai/ documentation structure
|
|
282
|
+
print_step "Creating .ai/ documentation structure..."
|
|
283
|
+
mkdir -p "$PROJECT_DIR/.ai/core"
|
|
284
|
+
mkdir -p "$PROJECT_DIR/.ai/patterns"
|
|
285
|
+
mkdir -p "$PROJECT_DIR/.ai/workflows"
|
|
286
|
+
|
|
287
|
+
if [ ! -f "$PROJECT_DIR/.ai/README.md" ]; then
|
|
288
|
+
cat > "$PROJECT_DIR/.ai/README.md" << 'AI_README'
|
|
289
|
+
# Project Documentation
|
|
290
|
+
|
|
291
|
+
Static documentation for this project.
|
|
292
|
+
|
|
293
|
+
## Structure
|
|
294
|
+
|
|
295
|
+
```
|
|
296
|
+
.ai/
|
|
297
|
+
├── core/ # Technology stack, architecture
|
|
298
|
+
├── patterns/ # Reusable implementation patterns
|
|
299
|
+
└── workflows/ # Development workflows
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Two Sources of Truth
|
|
303
|
+
|
|
304
|
+
| Location | Type | Updates |
|
|
305
|
+
|----------|------|---------|
|
|
306
|
+
| `.ai/` | Static docs | When architecture/patterns change |
|
|
307
|
+
| `.claude/memory/` | Dynamic state | Every session |
|
|
308
|
+
|
|
309
|
+
## Guidelines
|
|
310
|
+
|
|
311
|
+
- Each fact exists in ONE location
|
|
312
|
+
- Cross-reference, never duplicate
|
|
313
|
+
- Version numbers ONLY in `core/technology-stack.md`
|
|
314
|
+
- Update patterns after 3+ uses of same solution
|
|
315
|
+
AI_README
|
|
316
|
+
print_success "Created .ai/README.md"
|
|
317
|
+
fi
|
|
318
|
+
|
|
319
|
+
if [ ! -f "$PROJECT_DIR/.ai/core/technology-stack.md" ]; then
|
|
320
|
+
cat > "$PROJECT_DIR/.ai/core/technology-stack.md" << 'TECH'
|
|
321
|
+
# Technology Stack
|
|
322
|
+
|
|
323
|
+
> Single source of truth for all versions.
|
|
324
|
+
|
|
325
|
+
## Runtime
|
|
326
|
+
|
|
327
|
+
- Language: [e.g., TypeScript 5.x]
|
|
328
|
+
- Runtime: [e.g., Node.js 20.x]
|
|
329
|
+
|
|
330
|
+
## Frameworks
|
|
331
|
+
|
|
332
|
+
- Backend: [e.g., Express 4.x]
|
|
333
|
+
- Frontend: [e.g., React 18.x]
|
|
334
|
+
|
|
335
|
+
## Database
|
|
336
|
+
|
|
337
|
+
- Primary: [e.g., PostgreSQL 16]
|
|
338
|
+
- Cache: [e.g., Redis 7.x]
|
|
339
|
+
|
|
340
|
+
## Infrastructure
|
|
341
|
+
|
|
342
|
+
- Hosting: [e.g., AWS, Vercel]
|
|
343
|
+
- CI/CD: [e.g., GitHub Actions]
|
|
344
|
+
|
|
345
|
+
## Key Dependencies
|
|
346
|
+
|
|
347
|
+
| Package | Version | Purpose |
|
|
348
|
+
|---------|---------|---------|
|
|
349
|
+
| [name] | [x.x.x] | [purpose] |
|
|
350
|
+
TECH
|
|
351
|
+
print_success "Created .ai/core/technology-stack.md"
|
|
352
|
+
fi
|
|
353
|
+
|
|
354
|
+
if [ ! -f "$PROJECT_DIR/.ai/core/architecture.md" ]; then
|
|
355
|
+
cat > "$PROJECT_DIR/.ai/core/architecture.md" << 'ARCH'
|
|
356
|
+
# Architecture
|
|
357
|
+
|
|
358
|
+
## Overview
|
|
359
|
+
|
|
360
|
+
[High-level description of system architecture]
|
|
361
|
+
|
|
362
|
+
## Layers
|
|
363
|
+
|
|
364
|
+
### Presentation
|
|
365
|
+
[UI components, API endpoints]
|
|
366
|
+
|
|
367
|
+
### Business Logic
|
|
368
|
+
[Services, domain logic]
|
|
369
|
+
|
|
370
|
+
### Data
|
|
371
|
+
[Database access, repositories]
|
|
372
|
+
|
|
373
|
+
## Components
|
|
374
|
+
|
|
375
|
+
[Add component descriptions as they are built]
|
|
376
|
+
|
|
377
|
+
## Data Flow
|
|
378
|
+
|
|
379
|
+
[How data moves through the system]
|
|
380
|
+
ARCH
|
|
381
|
+
print_success "Created .ai/core/architecture.md"
|
|
382
|
+
fi
|
|
383
|
+
|
|
384
|
+
if [ ! -f "$PROJECT_DIR/.ai/patterns/README.md" ]; then
|
|
385
|
+
cat > "$PROJECT_DIR/.ai/patterns/README.md" << 'PATTERNS'
|
|
386
|
+
# Patterns
|
|
387
|
+
|
|
388
|
+
Reusable implementation patterns for this project.
|
|
389
|
+
|
|
390
|
+
## Adding Patterns
|
|
391
|
+
|
|
392
|
+
After using the same solution 3+ times, add it here.
|
|
393
|
+
|
|
394
|
+
## Pattern Template
|
|
395
|
+
|
|
396
|
+
```markdown
|
|
397
|
+
## [Pattern Name]
|
|
398
|
+
|
|
399
|
+
**Use Case**: When to use this pattern
|
|
400
|
+
|
|
401
|
+
**Implementation**:
|
|
402
|
+
```[language]
|
|
403
|
+
// Code example
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**Rationale**: Why we use this pattern
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
## Patterns
|
|
410
|
+
|
|
411
|
+
[Add patterns below as they emerge]
|
|
412
|
+
PATTERNS
|
|
413
|
+
print_success "Created .ai/patterns/README.md"
|
|
414
|
+
fi
|
|
415
|
+
|
|
416
|
+
if [ ! -f "$PROJECT_DIR/.ai/workflows/README.md" ]; then
|
|
417
|
+
cat > "$PROJECT_DIR/.ai/workflows/README.md" << 'WORKFLOWS'
|
|
418
|
+
# Workflows
|
|
419
|
+
|
|
420
|
+
Development workflows for this project.
|
|
421
|
+
|
|
422
|
+
## Workflow Template
|
|
423
|
+
|
|
424
|
+
```markdown
|
|
425
|
+
## [Workflow Name]
|
|
426
|
+
|
|
427
|
+
**Purpose**: What this workflow accomplishes
|
|
428
|
+
|
|
429
|
+
**Steps**:
|
|
430
|
+
1. Step one
|
|
431
|
+
2. Step two
|
|
432
|
+
|
|
433
|
+
**Verification**: How to confirm success
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
## Workflows
|
|
437
|
+
|
|
438
|
+
[Add workflows below as they are established]
|
|
439
|
+
WORKFLOWS
|
|
440
|
+
print_success "Created .ai/workflows/README.md"
|
|
441
|
+
fi
|
|
442
|
+
|
|
443
|
+
# 3. Create project CLAUDE.md if missing
|
|
444
|
+
if [ ! -f "$PROJECT_DIR/CLAUDE.md" ]; then
|
|
445
|
+
print_step "Creating project CLAUDE.md..."
|
|
446
|
+
cat > "$PROJECT_DIR/CLAUDE.md" << 'PROJECT_CLAUDE'
|
|
447
|
+
# Project Instructions
|
|
448
|
+
|
|
449
|
+
## Overview
|
|
450
|
+
|
|
451
|
+
[Brief description of this project]
|
|
452
|
+
|
|
453
|
+
## Tech Stack
|
|
454
|
+
|
|
455
|
+
See `.ai/core/technology-stack.md` for versions.
|
|
456
|
+
|
|
457
|
+
## Architecture
|
|
458
|
+
|
|
459
|
+
See `.ai/core/architecture.md` for system design.
|
|
460
|
+
|
|
461
|
+
## Development
|
|
462
|
+
|
|
463
|
+
### Setup
|
|
464
|
+
```bash
|
|
465
|
+
[setup commands]
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Run
|
|
469
|
+
```bash
|
|
470
|
+
[run commands]
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
### Test
|
|
474
|
+
```bash
|
|
475
|
+
[test commands]
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
## Conventions
|
|
479
|
+
|
|
480
|
+
- [Convention 1]
|
|
481
|
+
- [Convention 2]
|
|
482
|
+
|
|
483
|
+
## Memory
|
|
484
|
+
|
|
485
|
+
This project uses Unsevered Memory. See:
|
|
486
|
+
- `.claude/memory/` for session state
|
|
487
|
+
- `.ai/` for patterns and architecture
|
|
488
|
+
PROJECT_CLAUDE
|
|
489
|
+
print_success "Created project CLAUDE.md"
|
|
490
|
+
fi
|
|
491
|
+
|
|
492
|
+
# 4. Update .gitignore
|
|
493
|
+
print_step "Updating .gitignore..."
|
|
494
|
+
GITIGNORE="$PROJECT_DIR/.gitignore"
|
|
495
|
+
|
|
496
|
+
if [ ! -f "$GITIGNORE" ]; then
|
|
497
|
+
touch "$GITIGNORE"
|
|
498
|
+
fi
|
|
499
|
+
|
|
500
|
+
if ! grep -q "# Unsevered Memory" "$GITIGNORE" 2>/dev/null; then
|
|
501
|
+
echo "" >> "$GITIGNORE"
|
|
502
|
+
echo "# Unsevered Memory" >> "$GITIGNORE"
|
|
503
|
+
echo ".claude/memory/scratchpad.md" >> "$GITIGNORE"
|
|
504
|
+
print_success "Updated .gitignore"
|
|
505
|
+
else
|
|
506
|
+
print_step ".gitignore already configured"
|
|
507
|
+
fi
|
|
508
|
+
|
|
509
|
+
# Done
|
|
510
|
+
echo ""
|
|
511
|
+
echo -e "${GREEN}==========================================${NC}"
|
|
512
|
+
echo -e "${GREEN} Project Setup Complete${NC}"
|
|
513
|
+
echo -e "${GREEN}==========================================${NC}"
|
|
514
|
+
echo ""
|
|
515
|
+
echo "Structure created:"
|
|
516
|
+
echo " .claude/memory/"
|
|
517
|
+
echo " - context.md (cross-session state)"
|
|
518
|
+
echo " - scratchpad.md (live session log)"
|
|
519
|
+
echo " - decisions.md (architectural decisions)"
|
|
520
|
+
echo " - sessions/ (daily archives)"
|
|
521
|
+
echo " - checkpoints/ (compaction saves)"
|
|
522
|
+
echo ""
|
|
523
|
+
echo " .ai/"
|
|
524
|
+
echo " - core/ (tech stack, architecture)"
|
|
525
|
+
echo " - patterns/ (reusable solutions)"
|
|
526
|
+
echo " - workflows/ (dev processes)"
|
|
527
|
+
echo ""
|
|
528
|
+
echo "Next steps:"
|
|
529
|
+
echo " 1. Edit CLAUDE.md with project details"
|
|
530
|
+
echo " 2. Fill in .ai/core/ with project info"
|
|
531
|
+
echo " 3. Run 'claude' to start working"
|
|
532
|
+
echo ""
|
|
533
|
+
echo ""
|
|
534
|
+
echo -e "${BLUE}==========================================${NC}"
|
|
535
|
+
echo -e "${BLUE} Bootstrap Prompt${NC}"
|
|
536
|
+
echo -e "${BLUE}==========================================${NC}"
|
|
537
|
+
echo ""
|
|
538
|
+
echo "To initialize this project with comprehensive documentation:"
|
|
539
|
+
echo ""
|
|
540
|
+
cat << 'BOOTSTRAP_PROMPT'
|
|
541
|
+
Conduct a comprehensive documentation audit and integration project for this codebase by systematically analyzing, organizing, and consolidating all text-based materials into the existing @.ai/ folder documentation framework. Begin by thoroughly examining the current @.ai/ folder structure to understand the existing documentation system, including what files are present, how information is organized, and where specific types of content should be appended or integrated. Next, perform an in-depth analysis of the project's actual codebase, treating the working code as the authoritative source of truth about functionality, architecture, and purpose, then use these insights to enhance and complete the @.ai/ documentation system with accurate technical specifications and operational context. Following the code analysis, systematically search throughout the entire project directory to locate and catalog all documentation-related files and folders, including .txt, .md, .pdf documents, research materials, diagnostic reports, project plans, notes, and any other relevant documentation (excluding claude.md). Once all documentation materials have been identified, carefully review their contents and strategically append the relevant information to the appropriate corresponding files within the established @.ai/ folder system, ensuring that data is integrated logically without creating new files or folders. After completing the integration process, create a new folder named "olddoccontext" in the project root directory and relocate all the original documentation files and folders that were processed during the audit, effectively centralizing these materials while maintaining the enhanced @.ai/ documentation system as the primary source of project information. Throughout this entire process, utilize the @agent-orchestrator tool to maximize efficiency and ensure systematic completion of each phase, ultimately delivering a comprehensive, well-organized documentation framework that accurately captures all technical specifications, operational contexts, and project details within the existing @.ai/ folder structure.
|
|
542
|
+
BOOTSTRAP_PROMPT
|
|
543
|
+
echo ""
|
|
544
|
+
echo "Run this in your project with: /orchestrate"
|
|
545
|
+
echo ""
|
|
546
|
+
PROJECT_SETUP
|
|
547
|
+
|
|
548
|
+
chmod +x "$CLAUDE_DIR/setup-project.sh"
|
|
549
|
+
print_success "Project setup script created"
|
|
550
|
+
|
|
551
|
+
# Done
|
|
552
|
+
echo ""
|
|
553
|
+
echo -e "${GREEN}==========================================${NC}"
|
|
554
|
+
echo -e "${GREEN} Global Setup Complete${NC}"
|
|
555
|
+
echo -e "${GREEN}==========================================${NC}"
|
|
556
|
+
echo ""
|
|
557
|
+
echo "Installed to ~/.claude/:"
|
|
558
|
+
echo " - CLAUDE.md (global instructions)"
|
|
559
|
+
echo " - settings.json (hook configuration)"
|
|
560
|
+
echo " - hooks/"
|
|
561
|
+
echo " - memory-load.sh (SessionStart)"
|
|
562
|
+
echo " - memory-remind.sh (UserPromptSubmit)"
|
|
563
|
+
echo " - memory-precompact.sh (PreCompact)"
|
|
564
|
+
echo " - memory-save.sh (SessionEnd)"
|
|
565
|
+
echo " - memory-manifest.sh (MANIFEST generator)"
|
|
566
|
+
echo " - skills/orchestrate/"
|
|
567
|
+
echo " - SKILL.md (workflow instructions)"
|
|
568
|
+
echo " - commands/"
|
|
569
|
+
echo " - orchestrate.md (/orchestrate command)"
|
|
570
|
+
echo " - setup-project.sh (per-project setup)"
|
|
571
|
+
echo ""
|
|
572
|
+
echo "To add memory to a project:"
|
|
573
|
+
echo " cd /path/to/project"
|
|
574
|
+
echo " ~/.claude/setup-project.sh"
|
|
575
|
+
echo ""
|
|
576
|
+
echo "To use orchestrator mode:"
|
|
577
|
+
echo " /orchestrate [task description]"
|
|
578
|
+
echo ""
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
# Unsevered Memory - Workflow Skill
|
|
2
|
+
|
|
3
|
+
You are operating with persistent memory. This skill defines how to maintain context across sessions.
|
|
4
|
+
|
|
5
|
+
## Memory Architecture
|
|
6
|
+
|
|
7
|
+
### Two Sources of Truth
|
|
8
|
+
|
|
9
|
+
| Location | Type | Purpose | Update Frequency |
|
|
10
|
+
|----------|------|---------|------------------|
|
|
11
|
+
| `.claude/memory/` | Dynamic | Session state, decisions | Every session |
|
|
12
|
+
| `.ai/` | Static | Architecture, patterns | When patterns emerge |
|
|
13
|
+
|
|
14
|
+
### File Purposes
|
|
15
|
+
|
|
16
|
+
| File | Content | When to Update |
|
|
17
|
+
|------|---------|----------------|
|
|
18
|
+
| `context.md` | Current state, next steps | End of session |
|
|
19
|
+
| `scratchpad.md` | Live session operations | During session |
|
|
20
|
+
| `decisions.md` | Architectural choices | When decisions made |
|
|
21
|
+
| `.ai/core/` | Tech stack, architecture | When they change |
|
|
22
|
+
| `.ai/patterns/` | Reusable solutions | After 3+ uses |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Session Workflow
|
|
27
|
+
|
|
28
|
+
### On Session Start
|
|
29
|
+
|
|
30
|
+
1. Memory hook automatically loads `context.md`
|
|
31
|
+
2. Review the current state and task
|
|
32
|
+
3. Check `scratchpad.md` for unfinished work
|
|
33
|
+
4. Reference `.ai/` for patterns and architecture
|
|
34
|
+
|
|
35
|
+
### During Session
|
|
36
|
+
|
|
37
|
+
**Write to scratchpad.md as you work:**
|
|
38
|
+
|
|
39
|
+
```markdown
|
|
40
|
+
## Session: 2024-01-15 14:30
|
|
41
|
+
|
|
42
|
+
### Operations
|
|
43
|
+
- [14:31] Read context.md - last session worked on auth
|
|
44
|
+
- [14:32] User asked to fix login bug
|
|
45
|
+
- [14:35] Found issue in validateToken() at src/auth.ts:142
|
|
46
|
+
- [14:40] Fixed: was comparing wrong field
|
|
47
|
+
|
|
48
|
+
### Findings
|
|
49
|
+
- Token validation was checking user.id instead of user.uid
|
|
50
|
+
- Only affects users created after migration
|
|
51
|
+
|
|
52
|
+
### Decisions
|
|
53
|
+
- Keep backward compatibility by checking both fields
|
|
54
|
+
|
|
55
|
+
### Blockers
|
|
56
|
+
(none)
|
|
57
|
+
|
|
58
|
+
### Next Steps
|
|
59
|
+
- Add regression test for token validation
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Update .ai/ when patterns emerge:**
|
|
63
|
+
|
|
64
|
+
After implementing the same solution 3+ times, add it to `.ai/patterns/`.
|
|
65
|
+
|
|
66
|
+
### On Session End
|
|
67
|
+
|
|
68
|
+
1. Hook archives scratchpad to `sessions/YYYY-MM-DD.md`
|
|
69
|
+
2. Update `context.md` with:
|
|
70
|
+
- What was accomplished
|
|
71
|
+
- Current state
|
|
72
|
+
- Next steps
|
|
73
|
+
3. Append architectural decisions to `decisions.md`
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Live Documentation Updates
|
|
78
|
+
|
|
79
|
+
### When to Update .ai/
|
|
80
|
+
|
|
81
|
+
During your session, proactively update `.ai/` when you encounter:
|
|
82
|
+
|
|
83
|
+
| Trigger | Location | Example |
|
|
84
|
+
|---------|----------|---------|
|
|
85
|
+
| Pattern used 3+ times | `.ai/patterns/` | Error handling, API structure |
|
|
86
|
+
| Architecture change | `.ai/core/architecture.md` | New service layer |
|
|
87
|
+
| Stack change | `.ai/core/technology-stack.md` | New dependency |
|
|
88
|
+
| Workflow improvement | `.ai/workflows/` | Better test process |
|
|
89
|
+
|
|
90
|
+
### How to Update
|
|
91
|
+
|
|
92
|
+
Do not wait for session end. Update as you go:
|
|
93
|
+
|
|
94
|
+
1. Notice a pattern emerging
|
|
95
|
+
2. Add/update relevant `.ai/` file immediately
|
|
96
|
+
3. Log the update in scratchpad
|
|
97
|
+
4. Continue working
|
|
98
|
+
|
|
99
|
+
Example scratchpad entry:
|
|
100
|
+
```markdown
|
|
101
|
+
### Operations
|
|
102
|
+
- [14:35] Implemented error handling in 3 endpoints
|
|
103
|
+
- [14:40] Pattern detected - created .ai/patterns/error-handling.md
|
|
104
|
+
- [14:45] Applied pattern to remaining endpoints
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Decision Tree: Where Does This Go?
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
Is this information:
|
|
113
|
+
|
|
114
|
+
[Specific to today's work?]
|
|
115
|
+
YES --> scratchpad.md
|
|
116
|
+
|
|
117
|
+
[An architectural decision?]
|
|
118
|
+
YES --> decisions.md (also update .ai/ if changes architecture)
|
|
119
|
+
|
|
120
|
+
[A reusable pattern?]
|
|
121
|
+
YES --> .ai/patterns/
|
|
122
|
+
|
|
123
|
+
[About the tech stack?]
|
|
124
|
+
YES --> .ai/core/technology-stack.md
|
|
125
|
+
|
|
126
|
+
[Current project state?]
|
|
127
|
+
YES --> context.md
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
## File Templates
|
|
133
|
+
|
|
134
|
+
### context.md
|
|
135
|
+
|
|
136
|
+
```markdown
|
|
137
|
+
# Project Context
|
|
138
|
+
|
|
139
|
+
## Current State
|
|
140
|
+
[What is the current state of the project/feature?]
|
|
141
|
+
|
|
142
|
+
## Current Task
|
|
143
|
+
[What are we working on right now?]
|
|
144
|
+
|
|
145
|
+
## Last Session
|
|
146
|
+
- Date: YYYY-MM-DD
|
|
147
|
+
- Accomplished: [summary]
|
|
148
|
+
- Stopped at: [where we left off]
|
|
149
|
+
|
|
150
|
+
## Next Steps
|
|
151
|
+
1. [First thing to do]
|
|
152
|
+
2. [Second thing to do]
|
|
153
|
+
|
|
154
|
+
## Active Branches
|
|
155
|
+
- feature/xxx - [purpose]
|
|
156
|
+
|
|
157
|
+
## Notes
|
|
158
|
+
[Any context the next session needs]
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### scratchpad.md
|
|
162
|
+
|
|
163
|
+
```markdown
|
|
164
|
+
# Scratchpad
|
|
165
|
+
|
|
166
|
+
Session: YYYY-MM-DD HH:MM
|
|
167
|
+
|
|
168
|
+
## Operations
|
|
169
|
+
- [HH:MM] Action taken
|
|
170
|
+
|
|
171
|
+
## Findings
|
|
172
|
+
- What was discovered
|
|
173
|
+
|
|
174
|
+
## Decisions
|
|
175
|
+
- Choices made and rationale
|
|
176
|
+
|
|
177
|
+
## Blockers
|
|
178
|
+
- Issues encountered
|
|
179
|
+
|
|
180
|
+
## Next Steps
|
|
181
|
+
- What to do if session ends
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### decisions.md
|
|
185
|
+
|
|
186
|
+
```markdown
|
|
187
|
+
# Decision Log
|
|
188
|
+
|
|
189
|
+
## YYYY-MM-DD: [Decision Title]
|
|
190
|
+
|
|
191
|
+
**Context**: [Why was this decision needed?]
|
|
192
|
+
|
|
193
|
+
**Options Considered**:
|
|
194
|
+
1. Option A - pros/cons
|
|
195
|
+
2. Option B - pros/cons
|
|
196
|
+
|
|
197
|
+
**Decision**: [What was chosen]
|
|
198
|
+
|
|
199
|
+
**Rationale**: [Why this option]
|
|
200
|
+
|
|
201
|
+
**Consequences**: [What this means going forward]
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Enforcement
|
|
207
|
+
|
|
208
|
+
The `UserPromptSubmit` hook displays memory state on every prompt:
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
[Memory] Task: Fix auth bug | Scratchpad: 24 lines | .ai/ updated: 2024-01-15
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
This reminder survives context compaction. Use it to stay oriented.
|
|
215
|
+
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
## Commands
|
|
219
|
+
|
|
220
|
+
### /orchestrate
|
|
221
|
+
|
|
222
|
+
Activates orchestrator mode for complex tasks. The orchestrator:
|
|
223
|
+
1. Reads all memory files
|
|
224
|
+
2. Breaks task into subtasks
|
|
225
|
+
3. Delegates to specialized agents
|
|
226
|
+
4. Updates memory after each step
|
|
227
|
+
5. Never loses context
|
|
228
|
+
|
|
229
|
+
Use for multi-step tasks requiring persistent state management.
|