devflow-kit 1.6.0 → 1.7.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 (39) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +4 -1
  3. package/dist/commands/init.js +7 -3
  4. package/dist/commands/uninstall.d.ts +9 -0
  5. package/dist/commands/uninstall.js +60 -4
  6. package/dist/utils/post-install.js +0 -1
  7. package/package.json +1 -1
  8. package/plugins/devflow-accessibility/.claude-plugin/plugin.json +1 -1
  9. package/plugins/devflow-ambient/.claude-plugin/plugin.json +1 -1
  10. package/plugins/devflow-ambient/agents/skimmer.md +71 -21
  11. package/plugins/devflow-ambient/skills/ambient-router/SKILL.md +4 -1
  12. package/plugins/devflow-audit-claude/.claude-plugin/plugin.json +1 -1
  13. package/plugins/devflow-code-review/.claude-plugin/plugin.json +1 -1
  14. package/plugins/devflow-core-skills/.claude-plugin/plugin.json +1 -1
  15. package/plugins/devflow-core-skills/skills/docs-framework/SKILL.md +0 -1
  16. package/plugins/devflow-debug/.claude-plugin/plugin.json +1 -1
  17. package/plugins/devflow-frontend-design/.claude-plugin/plugin.json +1 -1
  18. package/plugins/devflow-go/.claude-plugin/plugin.json +1 -1
  19. package/plugins/devflow-implement/.claude-plugin/plugin.json +1 -1
  20. package/plugins/devflow-implement/agents/skimmer.md +71 -21
  21. package/plugins/devflow-implement/commands/implement-teams.md +1 -1
  22. package/plugins/devflow-implement/commands/implement.md +1 -1
  23. package/plugins/devflow-java/.claude-plugin/plugin.json +1 -1
  24. package/plugins/devflow-python/.claude-plugin/plugin.json +1 -1
  25. package/plugins/devflow-react/.claude-plugin/plugin.json +1 -1
  26. package/plugins/devflow-resolve/.claude-plugin/plugin.json +1 -1
  27. package/plugins/devflow-rust/.claude-plugin/plugin.json +1 -1
  28. package/plugins/devflow-self-review/.claude-plugin/plugin.json +1 -1
  29. package/plugins/devflow-specify/.claude-plugin/plugin.json +1 -1
  30. package/plugins/devflow-specify/agents/skimmer.md +71 -21
  31. package/plugins/devflow-specify/commands/specify-teams.md +1 -1
  32. package/plugins/devflow-specify/commands/specify.md +1 -1
  33. package/plugins/devflow-typescript/.claude-plugin/plugin.json +1 -1
  34. package/scripts/hooks/ambient-prompt +5 -4
  35. package/scripts/hooks/background-memory-update +114 -85
  36. package/scripts/hooks/session-start-memory +1 -17
  37. package/shared/agents/skimmer.md +71 -21
  38. package/shared/skills/ambient-router/SKILL.md +4 -1
  39. package/shared/skills/docs-framework/SKILL.md +0 -1
@@ -53,7 +53,7 @@ Spawn Skimmer agent for codebase overview:
53
53
  ```
54
54
  Task(subagent_type="Skimmer"):
55
55
  "Orient in codebase for: {task description}
56
- Use skim to identify relevant files, functions, integration points"
56
+ Run rskim on source directories (NOT repo root) to identify relevant files, functions, integration points"
57
57
  ```
58
58
 
59
59
  ### Phase 3: Explore (Parallel)
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "Dean0x"
6
6
  },
7
- "version": "1.6.0",
7
+ "version": "1.7.0",
8
8
  "homepage": "https://github.com/dean0x/devflow",
9
9
  "repository": "https://github.com/dean0x/devflow",
10
10
  "license": "MIT",
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "Dean0x"
6
6
  },
7
- "version": "1.6.0",
7
+ "version": "1.7.0",
8
8
  "homepage": "https://github.com/dean0x/devflow",
9
9
  "repository": "https://github.com/dean0x/devflow",
10
10
  "license": "MIT",
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "Dean0x"
6
6
  },
7
- "version": "1.6.0",
7
+ "version": "1.7.0",
8
8
  "homepage": "https://github.com/dean0x/devflow",
9
9
  "repository": "https://github.com/dean0x/devflow",
10
10
  "license": "MIT",
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "Dean0x"
6
6
  },
7
- "version": "1.6.0",
7
+ "version": "1.7.0",
8
8
  "homepage": "https://github.com/dean0x/devflow",
9
9
  "repository": "https://github.com/dean0x/devflow",
10
10
  "license": "MIT",
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "Dean0x"
6
6
  },
7
- "version": "1.6.0",
7
+ "version": "1.7.0",
8
8
  "homepage": "https://github.com/dean0x/devflow",
9
9
  "repository": "https://github.com/dean0x/devflow",
10
10
  "license": "MIT",
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "Dean0x"
6
6
  },
7
- "version": "1.6.0",
7
+ "version": "1.7.0",
8
8
  "homepage": "https://github.com/dean0x/devflow",
9
9
  "repository": "https://github.com/dean0x/devflow",
10
10
  "license": "MIT",
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "Dean0x"
6
6
  },
7
- "version": "1.6.0",
7
+ "version": "1.7.0",
8
8
  "homepage": "https://github.com/dean0x/devflow",
9
9
  "repository": "https://github.com/dean0x/devflow",
10
10
  "license": "MIT",
@@ -1,39 +1,88 @@
1
1
  ---
2
2
  name: Skimmer
3
- description: Codebase orientation using skim to identify relevant files, functions, and patterns for a feature or task
3
+ description: Codebase orientation using rskim to identify relevant files, functions, and patterns for a feature or task
4
+ tools: ["Bash", "Read"]
4
5
  skills: knowledge-persistence
5
6
  model: inherit
6
7
  ---
7
8
 
8
9
  # Skimmer Agent
9
10
 
10
- You are a codebase orientation specialist using `skim` to efficiently understand codebases. Extract structure without implementation noise - find entry points, data flow, and integration points quickly.
11
+ You are a codebase orientation specialist. You use `npx rskim` exclusively for code exploration — never Grep, Glob, or manual file searches. Your output gives implementation agents a clear map of relevant files, functions, and integration points.
11
12
 
12
13
  ## Input Context
13
14
 
14
15
  You receive from orchestrator:
15
16
  - **TASK_DESCRIPTION**: What feature/task needs to be implemented or understood
16
17
 
17
- ## Responsibilities
18
+ ## Workflow
18
19
 
19
- 1. **Get project overview** - Identify project type, entry points, source directories
20
- 2. **Skim key directories** - Extract structure from src/, lib/, or app/ with `npx rskim --mode structure --show-stats`
21
- 3. **Search for task-relevant code** - Find files matching task keywords
22
- 4. **Identify integration points** - Exports, entry points, import patterns
23
- 5. **Generate orientation summary** - Structured output for implementation planning
24
- 6. **Check project knowledge** - If `.memory/knowledge/decisions.md` exists, read its `<!-- TL;DR: ... -->` first-line comment and include active decision count in orientation under "### Active Decisions". Only the TL;DR is read here (not full entries) — this is intentional for token efficiency; agents that need full entries read the file themselves.
20
+ Execute these steps in order. Do NOT skip steps or reorder.
25
21
 
26
- ## Tool Invocation
22
+ ### Step 1: Project Overview
27
23
 
28
- Always invoke skim via `npx rskim`. This works whether or not skim is globally installed npx downloads and caches it transparently.
24
+ Run `ls` on the project root via Bash to identify source directories and project type. Then Read the project manifest (`package.json`, `Cargo.toml`, `go.mod`, `pyproject.toml`, etc.) to understand the project.
29
25
 
30
- ## Skim Modes
26
+ **CRITICAL**: Never run `npx rskim .` or `npx rskim` on the repo root — it scans ALL files including `node_modules/` and produces millions of tokens. Always target specific source directories.
31
27
 
32
- | Mode | Use When | Command |
33
- |------|----------|---------|
34
- | `structure` | High-level overview | `npx rskim src/ --mode structure` |
35
- | `signatures` | Need API/function details | `npx rskim src/ --mode signatures` |
36
- | `types` | Working with type definitions | `npx rskim src/ --mode types` |
28
+ ### Step 2: Primary Source Skim
29
+
30
+ Run rskim on the main source directory with a token budget:
31
+
32
+ ```bash
33
+ npx rskim src/ --tokens 15000 --show-stats
34
+ ```
35
+
36
+ The `--tokens` flag auto-cascades through modes (full → minimal → structure → signatures → types) to fit within the budget. Let it choose the mode — do not specify `--mode` when using `--tokens`.
37
+
38
+ If `--tokens` flag errors (older rskim version), fall back to:
39
+ ```bash
40
+ npx rskim src/ --mode structure --show-stats
41
+ ```
42
+
43
+ ### Step 3: Secondary Directories (if relevant to task)
44
+
45
+ Skim additional directories with smaller budgets:
46
+
47
+ ```bash
48
+ npx rskim tests/ --tokens 5000 --show-stats
49
+ npx rskim scripts/ --tokens 5000 --show-stats
50
+ ```
51
+
52
+ Only skim directories relevant to the task description.
53
+
54
+ ### Step 4: Deep Inspection
55
+
56
+ For specific files needing detailed view, use rskim with full mode:
57
+
58
+ ```bash
59
+ npx rskim path/to/file.ts --mode full
60
+ ```
61
+
62
+ Use this instead of Read for code files.
63
+
64
+ ### Step 5: Project Knowledge
65
+
66
+ If `.memory/knowledge/decisions.md` exists, Read its `<!-- TL;DR: ... -->` first-line comment and include active decision count in orientation under "### Active Decisions". Only the TL;DR is read here — this is intentional for token efficiency.
67
+
68
+ ### Step 6: Generate Summary
69
+
70
+ Produce the orientation summary in the output format below.
71
+
72
+ ## rskim Reference
73
+
74
+ | Flag | Effect |
75
+ |------|--------|
76
+ | `--tokens N` | Token budget — auto-selects best mode to fit within N tokens |
77
+ | `--mode minimal` | Maximum compression (~85-90% reduction) |
78
+ | `--mode structure` | Architecture overview (~60-70% reduction) |
79
+ | `--mode signatures` | API/function details (~85-92% reduction) |
80
+ | `--mode types` | Type definitions only (~90-95% reduction) |
81
+ | `--mode full` | Complete file content (0% reduction) |
82
+ | `--show-stats` | Show original vs skimmed token counts |
83
+ | `--max-lines N` | AST-aware truncation (keeps types/signatures over imports/bodies) |
84
+
85
+ **Preferred**: Use `--tokens N` instead of choosing modes manually.
37
86
 
38
87
  ## Output
39
88
 
@@ -41,10 +90,10 @@ Always invoke skim via `npx rskim`. This works whether or not skim is globally i
41
90
  ## Codebase Orientation
42
91
 
43
92
  ### Project Type
44
- {Language/framework from package.json, Cargo.toml, etc.}
93
+ {Language/framework from manifest}
45
94
 
46
95
  ### Token Statistics
47
- {From skim --show-stats: original vs skimmed tokens}
96
+ {From rskim --show-stats: original vs skimmed tokens}
48
97
 
49
98
  ### Directory Structure
50
99
  | Directory | Purpose |
@@ -78,16 +127,17 @@ Always invoke skim via `npx rskim`. This works whether or not skim is globally i
78
127
  1. **Speed over depth** - Get oriented quickly, don't deep dive everything
79
128
  2. **Pattern discovery first** - Find existing patterns before recommending approaches
80
129
  3. **Be decisive** - Make confident recommendations about where to integrate
81
- 4. **Token efficiency** - Use skim stats to show compression ratio
130
+ 4. **Token efficiency** - Use rskim token budgets and stats to show compression ratio
82
131
  5. **Task-focused** - Only explore what's relevant to the task
83
132
 
84
133
  ## Boundaries
85
134
 
86
135
  **Handle autonomously:**
87
- - Directory structure exploration
136
+ - Directory structure exploration via rskim
88
137
  - Pattern identification
89
138
  - Generating orientation summaries
90
139
 
91
140
  **Escalate to orchestrator:**
141
+ - If `npx rskim` fails, report the error (do not attempt manual fallbacks with other tools) — orchestrators should spawn an ad-hoc Explore agent if Skimmer reports rskim failure
92
142
  - No source directories found (ask user for structure)
93
143
  - Ambiguous project structure (report findings, ask for clarification)
@@ -53,7 +53,7 @@ Spawn Skimmer agent for codebase context:
53
53
  ```
54
54
  Task(subagent_type="Skimmer"):
55
55
  "Orient in codebase for requirements exploration: {feature}
56
- Find: project structure, similar features, patterns, integration points
56
+ Run rskim on source directories (NOT repo root) to find: project structure, similar features, patterns, integration points
57
57
  Return: codebase context for requirements (not implementation details)"
58
58
  ```
59
59
 
@@ -53,7 +53,7 @@ Spawn Skimmer agent for codebase context:
53
53
  ```
54
54
  Task(subagent_type="Skimmer"):
55
55
  "Orient in codebase for requirements exploration: {feature}
56
- Find: project structure, similar features, patterns, integration points
56
+ Run rskim on source directories (NOT repo root) to find: project structure, similar features, patterns, integration points
57
57
  Return: codebase context for requirements (not implementation details)"
58
58
  ```
59
59
 
@@ -4,7 +4,7 @@
4
4
  "author": {
5
5
  "name": "Dean0x"
6
6
  },
7
- "version": "1.6.0",
7
+ "version": "1.7.0",
8
8
  "homepage": "https://github.com/dean0x/devflow",
9
9
  "repository": "https://github.com/dean0x/devflow",
10
10
  "license": "MIT",
@@ -25,21 +25,22 @@ if [[ "$PROMPT" == /* ]]; then
25
25
  fi
26
26
 
27
27
  # Skip single-word confirmations (< 2 words)
28
- WORD_COUNT=$(echo "$PROMPT" | wc -w | tr -d ' ')
28
+ WORD_COUNT=$(printf '%s' "$PROMPT" | wc -w | tr -d ' ')
29
29
  if [ "$WORD_COUNT" -lt 2 ]; then
30
30
  exit 0
31
31
  fi
32
32
 
33
33
  # Normalize to lowercase for matching
34
- PROMPT_LOWER=$(echo "$PROMPT" | tr '[:upper:]' '[:lower:]')
34
+ PROMPT_LOWER=$(printf '%s' "$PROMPT" | tr '[:upper:]' '[:lower:]')
35
35
 
36
36
  # Fast-path: git operations are always QUICK — skip preamble
37
- if echo "$PROMPT_LOWER" | grep -qE '^(commit|push|pull|merge|rebase|cherry-pick|squash|tag|stash)|create (a )?pr|open (a )?pr'; then
37
+ if printf '%s' "$PROMPT_LOWER" | grep -qE '^(commit|push|pull|merge|rebase|cherry-pick|squash|tag|stash)|create (a )?pr|open (a )?pr'; then
38
38
  exit 0
39
39
  fi
40
40
 
41
41
  # Inject classification preamble
42
- PREAMBLE="AMBIENT MODE ACTIVE: Before responding, silently classify this prompt using the ambient-router skill already in your session context. If QUICK, respond normally without stating classification."
42
+ # SYNC: must match tests/integration/helpers.ts AMBIENT_PREAMBLE
43
+ PREAMBLE="AMBIENT MODE ACTIVE: Before responding, silently classify this prompt using the ambient-router skill already in your session context. If QUICK, respond normally without stating classification. If GUIDED or ORCHESTRATED, you MUST load the selected skills using the Skill tool before proceeding."
43
44
 
44
45
  jq -n --arg ctx "$PREAMBLE" '{
45
46
  "hookSpecificOutput": {
@@ -2,8 +2,9 @@
2
2
 
3
3
  # Background Working Memory Updater
4
4
  # Called by stop-update-memory as a detached background process.
5
- # Resumes the parent session headlessly to update .memory/WORKING-MEMORY.md.
6
- # On failure: logs error, does nothing (no fallback).
5
+ # Reads the last turn from the session transcript, then uses a fresh `claude -p`
6
+ # invocation to update .memory/WORKING-MEMORY.md.
7
+ # On failure: logs error, does nothing (stale memory is better than fake data).
7
8
 
8
9
  set -e
9
10
 
@@ -29,7 +30,7 @@ rotate_log() {
29
30
 
30
31
  # --- Stale Lock Recovery ---
31
32
 
32
- # Portable mtime in epoch seconds (same pattern as stop-update-memory:35-39)
33
+ # Portable mtime in epoch seconds
33
34
  get_mtime() {
34
35
  if stat --version &>/dev/null 2>&1; then
35
36
  stat -c %Y "$1"
@@ -72,11 +73,65 @@ cleanup() {
72
73
  }
73
74
  trap cleanup EXIT
74
75
 
76
+ # --- Transcript Extraction ---
77
+
78
+ extract_last_turn() {
79
+ # Compute transcript path: Claude Code stores transcripts at
80
+ # ~/.claude/projects/{cwd-with-slashes-replaced-by-hyphens}/{session_id}.jsonl
81
+ local encoded_cwd
82
+ encoded_cwd=$(echo "$CWD" | sed 's|^/||' | tr '/' '-')
83
+ local transcript="$HOME/.claude/projects/-${encoded_cwd}/${SESSION_ID}.jsonl"
84
+
85
+ if [ ! -f "$transcript" ]; then
86
+ log "Transcript not found at $transcript"
87
+ return 1
88
+ fi
89
+
90
+ # Extract last user and assistant text from JSONL
91
+ # Each line is a JSON object with "type" field
92
+ local last_user last_assistant
93
+
94
+ last_user=$(grep '"type":"user"' "$transcript" 2>/dev/null \
95
+ | tail -3 \
96
+ | jq -r '
97
+ if .message.content then
98
+ [.message.content[] | select(.type == "text") | .text] | join("\n")
99
+ else ""
100
+ end
101
+ ' 2>/dev/null \
102
+ | tail -1)
103
+
104
+ last_assistant=$(grep '"type":"assistant"' "$transcript" 2>/dev/null \
105
+ | tail -3 \
106
+ | jq -r '
107
+ if .message.content then
108
+ [.message.content[] | select(.type == "text") | .text] | join("\n")
109
+ else ""
110
+ end
111
+ ' 2>/dev/null \
112
+ | tail -1)
113
+
114
+ # Truncate to ~4000 chars total to keep token cost low
115
+ if [ ${#last_user} -gt 2000 ]; then
116
+ last_user="${last_user:0:2000}... [truncated]"
117
+ fi
118
+ if [ ${#last_assistant} -gt 2000 ]; then
119
+ last_assistant="${last_assistant:0:2000}... [truncated]"
120
+ fi
121
+
122
+ if [ -z "$last_user" ] && [ -z "$last_assistant" ]; then
123
+ log "No text content found in transcript"
124
+ return 1
125
+ fi
126
+
127
+ LAST_USER_TEXT="$last_user"
128
+ LAST_ASSISTANT_TEXT="$last_assistant"
129
+ return 0
130
+ }
131
+
75
132
  # --- Main ---
76
133
 
77
- # Wait for parent session to flush transcript.
78
- # 3s provides ~6-10x margin over typical flush times.
79
- # If --resume shows stale transcripts, bump to 5s.
134
+ # Wait for parent session to flush transcript
80
135
  sleep 3
81
136
 
82
137
  log "Starting update for session $SESSION_ID"
@@ -87,7 +142,6 @@ break_stale_lock
87
142
  # Acquire lock (other sessions may be updating concurrently)
88
143
  if ! acquire_lock; then
89
144
  log "Lock timeout after 90s — skipping update for session $SESSION_ID"
90
- # Don't clean up lock we don't own
91
145
  trap - EXIT
92
146
  exit 0
93
147
  fi
@@ -102,97 +156,72 @@ if [ -f "$MEMORY_FILE" ]; then
102
156
  PRE_UPDATE_MTIME=$(get_mtime "$MEMORY_FILE")
103
157
  fi
104
158
 
105
- # Build instruction
106
- if [ -n "$EXISTING_MEMORY" ]; then
107
- PATTERNS_INSTRUCTION=""
108
- PATTERNS_FILE="$CWD/.memory/PROJECT-PATTERNS.md"
109
- EXISTING_PATTERNS=""
110
- if [ -f "$PATTERNS_FILE" ]; then
111
- EXISTING_PATTERNS=$(cat "$PATTERNS_FILE")
112
- PATTERNS_INSTRUCTION="
113
-
114
- Also update $PATTERNS_FILE by APPENDING any new recurring patterns discovered during this session. Do NOT overwrite existing entries — only add new ones. Skip if no new patterns were observed. Format each entry as: - **Pattern name**: Brief description (discovered: YYYY-MM-DD). Keep patterns.md under 40 entries. When approaching the limit, consolidate related patterns into broader entries rather than adding duplicates.
115
-
116
- Existing patterns:
117
- $EXISTING_PATTERNS"
118
- else
119
- PATTERNS_INSTRUCTION="
120
-
121
- If recurring patterns were observed during this session (coding conventions, architectural decisions, team preferences, tooling quirks), create $PATTERNS_FILE with entries formatted as: - **Pattern name**: Brief description (discovered: YYYY-MM-DD). Only create this file if genuine patterns were observed — do not fabricate entries."
159
+ # Gather git state (always available, used as fallback too)
160
+ GIT_STATE=""
161
+ if cd "$CWD" 2>/dev/null && git rev-parse --git-dir >/dev/null 2>&1; then
162
+ GIT_STATUS=$(git status --short 2>/dev/null | head -20)
163
+ GIT_LOG=$(git log --oneline -5 2>/dev/null)
164
+ GIT_DIFF=$(git diff --stat HEAD 2>/dev/null | tail -10)
165
+ GIT_STATE="Branch: $(git branch --show-current 2>/dev/null || echo 'unknown')
166
+ Recent commits:
167
+ ${GIT_LOG}
168
+ Changed files:
169
+ ${GIT_STATUS}
170
+ Diff summary:
171
+ ${GIT_DIFF}"
122
172
  fi
123
173
 
124
- INSTRUCTION="First, Read the file $MEMORY_FILE to satisfy Claude Code's read-before-write requirement. Then update it with working memory from this session. The file already has content — possibly from a concurrent session that just wrote it moments ago. Merge this session's context with the existing content to produce a single unified working memory snapshot. Both this session and the existing content represent fresh, concurrent work — integrate both fully. Working memory captures what's active now, not a changelog. Deduplicate overlapping information. Keep under 120 lines total. Use the same structure: ## Now, ## Progress, ## Decisions, ## Modified Files, ## Context, ## Session Log.
125
-
126
- ## Progress tracks Done (completed items), Remaining (next steps), and Blockers (if any). Keep each sub-list to 1-3 items. This section reflects current work state, not historical logs.
127
-
128
- ## Decisions entries must include date and status. Format: - **[Decision]** — [rationale] (YYYY-MM-DD) [ACTIVE|SUPERSEDED]. Mark superseded decisions rather than deleting them.${PATTERNS_INSTRUCTION}
129
-
130
- Existing content:
131
- $EXISTING_MEMORY"
174
+ # Extract last turn from transcript (or fall back to git-only)
175
+ LAST_USER_TEXT=""
176
+ LAST_ASSISTANT_TEXT=""
177
+ EXCHANGE_SECTION=""
178
+
179
+ if extract_last_turn; then
180
+ log "--- Extracted user text (${#LAST_USER_TEXT} chars) ---"
181
+ log "$LAST_USER_TEXT"
182
+ log "--- Extracted assistant text (${#LAST_ASSISTANT_TEXT} chars) ---"
183
+ log "$LAST_ASSISTANT_TEXT"
184
+ log "--- End transcript extraction ---"
185
+ EXCHANGE_SECTION="Last exchange:
186
+ User: ${LAST_USER_TEXT}
187
+ Assistant: ${LAST_ASSISTANT_TEXT}"
132
188
  else
133
- PATTERNS_INSTRUCTION=""
134
- PATTERNS_FILE="$CWD/.memory/PROJECT-PATTERNS.md"
135
- if [ -f "$PATTERNS_FILE" ]; then
136
- EXISTING_PATTERNS=$(cat "$PATTERNS_FILE")
137
- PATTERNS_INSTRUCTION="
138
-
139
- Also update $PATTERNS_FILE by APPENDING any new recurring patterns discovered during this session. Do NOT overwrite existing entries — only add new ones. Skip if no new patterns were observed. Format each entry as: - **Pattern name**: Brief description (discovered: YYYY-MM-DD). Keep patterns.md under 40 entries. When approaching the limit, consolidate related patterns into broader entries rather than adding duplicates.
140
-
141
- Existing patterns:
142
- $EXISTING_PATTERNS"
143
- else
144
- PATTERNS_INSTRUCTION="
145
-
146
- If recurring patterns were observed during this session (coding conventions, architectural decisions, team preferences, tooling quirks), create $PATTERNS_FILE with entries formatted as: - **Pattern name**: Brief description (discovered: YYYY-MM-DD). Only create this file if genuine patterns were observed — do not fabricate entries."
147
- fi
148
-
149
- INSTRUCTION="First, Read the file $MEMORY_FILE if it exists (to satisfy Claude Code's read-before-write requirement). Then create it with working memory from this session. Keep under 120 lines. Use this structure:
150
-
151
- # Working Memory
152
-
153
- ## Now
154
- <!-- Current focus, status, blockers (1-3 bullets) -->
155
-
156
- ## Progress
157
- <!-- Done: completed items (1-3). Remaining: next steps (1-3). Blockers: if any. -->
189
+ log "Falling back to git-state-only context"
190
+ EXCHANGE_SECTION="(Session transcript not available — using git state only)"
191
+ fi
158
192
 
159
- ## Decisions
160
- <!-- Format: - **[Decision]**[rationale] (YYYY-MM-DD) [ACTIVE|SUPERSEDED] -->
193
+ # Build prompt for fresh claude -p invocation
194
+ PROMPT="You are a working memory updater. Your ONLY job is to update the file at ${MEMORY_FILE} using the Write tool. Do it immediately do not ask questions or explain.
161
195
 
162
- ## Modified Files
163
- <!-- File paths only, most recent first -->
196
+ Current working memory:
197
+ ${EXISTING_MEMORY:-"(no existing content)"}
164
198
 
165
- ## Context
166
- <!-- Branch, PR, architectural context, open questions -->
199
+ ${EXCHANGE_SECTION}
167
200
 
168
- ## Session Log
201
+ Git state:
202
+ ${GIT_STATE:-"(not a git repo)"}
169
203
 
170
- ### Today
171
- <!-- Chronological summary of work done today (2-5 bullets) -->
204
+ Instructions:
205
+ - Use the Write tool to update ${MEMORY_FILE} immediately
206
+ - Keep under 120 lines
207
+ - Use sections: ## Now, ## Progress, ## Decisions, ## Modified Files, ## Context, ## Session Log
208
+ - Integrate new information with existing content
209
+ - Deduplicate overlapping information
210
+ - ## Progress tracks Done (completed), Remaining (next steps), Blockers (if any)
211
+ - ## Decisions entries: format as - **[Decision]** — [rationale] (YYYY-MM-DD) [ACTIVE|SUPERSEDED]"
172
212
 
173
- ### This Week
174
- <!-- Broader multi-day context if relevant -->${PATTERNS_INSTRUCTION}"
175
- fi
213
+ log "--- Full prompt being passed to claude -p ---"
214
+ log "$PROMPT"
215
+ log "--- End prompt ---"
176
216
 
177
- # Resume session headlessly to perform the update
178
- TIMEOUT=120 # Normal runtime 30-60s; 2x margin
217
+ # Run fresh claude -p (no --resume, no conversation confusion)
218
+ TIMEOUT=120
179
219
 
180
- DEVFLOW_BG_UPDATER=1 env -u CLAUDECODE "$CLAUDE_BIN" -p \
181
- --resume "$SESSION_ID" \
220
+ DEVFLOW_BG_UPDATER=1 "$CLAUDE_BIN" -p \
182
221
  --model haiku \
183
- --tools "Read,Write,Bash" \
184
- --allowedTools \
185
- "Read($CWD/.memory/WORKING-MEMORY.md)" \
186
- "Read($CWD/.memory/PROJECT-PATTERNS.md)" \
187
- "Write($CWD/.memory/WORKING-MEMORY.md)" \
188
- "Write($CWD/.memory/PROJECT-PATTERNS.md)" \
189
- "Bash(git status:*)" \
190
- "Bash(git log:*)" \
191
- "Bash(git diff:*)" \
192
- "Bash(git branch:*)" \
193
- --no-session-persistence \
222
+ --dangerously-skip-permissions \
194
223
  --output-format text \
195
- "$INSTRUCTION" \
224
+ "$PROMPT" \
196
225
  >> "$LOG_FILE" 2>&1 &
197
226
  CLAUDE_PID=$!
198
227
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  # SessionStart Hook
4
4
  # Injects working memory AND ambient skill content as additionalContext.
5
- # Memory: restores .memory/WORKING-MEMORY.md + patterns + git state + compact recovery.
5
+ # Memory: restores .memory/WORKING-MEMORY.md + git state + compact recovery.
6
6
  # Ambient: injects ambient-router SKILL.md so Claude has it in context (no Read call needed).
7
7
  # Either section can fire independently — ambient works even without memory files.
8
8
 
@@ -27,13 +27,6 @@ MEMORY_FILE="$CWD/.memory/WORKING-MEMORY.md"
27
27
  if [ -f "$MEMORY_FILE" ]; then
28
28
  MEMORY_CONTENT=$(cat "$MEMORY_FILE")
29
29
 
30
- # Read accumulated patterns if they exist
31
- PATTERNS_FILE="$CWD/.memory/PROJECT-PATTERNS.md"
32
- PATTERNS_CONTENT=""
33
- if [ -f "$PATTERNS_FILE" ]; then
34
- PATTERNS_CONTENT=$(cat "$PATTERNS_FILE")
35
- fi
36
-
37
30
  # Compute staleness warning
38
31
  if stat --version &>/dev/null 2>&1; then
39
32
  FILE_MTIME=$(stat -c %Y "$MEMORY_FILE")
@@ -91,15 +84,6 @@ $BACKUP_MEMORY
91
84
 
92
85
  ${MEMORY_CONTENT}"
93
86
 
94
- # Insert accumulated patterns between working memory and git state
95
- if [ -n "$PATTERNS_CONTENT" ]; then
96
- CONTEXT="${CONTEXT}
97
-
98
- --- PROJECT PATTERNS (accumulated) ---
99
-
100
- ${PATTERNS_CONTENT}"
101
- fi
102
-
103
87
  CONTEXT="${CONTEXT}
104
88
 
105
89
  --- CURRENT GIT STATE ---