OverviewFilesCommitsIssuesDocsReleasesPeers

knowledge-ratchet commits / bdbfd6b

Move loop briefing to UserPromptSubmit with additionalContext injection
SessionStart stderr output was invisible to Claude. Now briefing fires on first UserPromptSubmit as additionalContext JSON — Claude reads the loop history, danger files, and learned rules before responding. Flag file prevents re-injection on subsequent prompts. SessionStart clears the flag so each new session gets briefed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
bdbfd6bb328bfe97fc13d9ff424a685b4a5437fd
by plankatron <fleeky@gmail.com> · 2026-04-07T21:04:40.000Z

Changed files (1) +16 -1

loop-briefing.js +16 -1
……@@ -31,6 +31,16 @@ function classifyProject (cwd) {
3131}
3232
3333function main () {
34 // Only inject on first prompt of session — check if briefing already delivered
35 const BRIEFING_FLAG = '/tmp/claude-briefing-delivered.flag'
36 if (fs.existsSync(BRIEFING_FLAG)) {
37 // Check if flag is from current session (less than 1 hour old)
38 try {
39 const age = Date.now() - fs.statSync(BRIEFING_FLAG).mtimeMs
40 if (age < 3600000) return // already briefed this session
41 } catch {}
42 }
43
3444 const cwd = process.cwd()
3545 const project = classifyProject(cwd)
3646 if (!project) return // not a known project — no briefing needed
……@@ -125,7 +135,12 @@ function main () {
125135 lines.push('═'.repeat(50))
126136 lines.push('')
127137
128 process.stderr.write(lines.join('\n'))
138 // Mark as delivered so we don't repeat
139 fs.writeFileSync(BRIEFING_FLAG, new Date().toISOString())
140
141 // Output as additionalContext JSON — Claude sees this as system context
142 const output = { additionalContext: lines.join('\n') }
143 process.stdout.write(JSON.stringify(output))
129144}
130145
131146main()