From 406b998d456666ecd9a6d974dcdd9ab6cbf0045c Mon Sep 17 00:00:00 2001 From: Tom Boucher Date: Mon, 16 Mar 2026 10:51:04 -0400 Subject: [PATCH] feat(hooks): add config option to disable context window warnings (#1073) Add hooks.context_warnings config option (default: true) that allows users to disable the context monitor hook's advisory messages. When set to false, the hook exits silently, allowing Claude Code to reach auto-compact naturally without being interrupted. This is useful for long unattended runs where users prefer Claude to auto-compact and continue rather than stopping to warn about context. Changes: - hooks/gsd-context-monitor.js: Check config before emitting warnings - get-shit-done/templates/config.json: Add hooks.context_warnings default - get-shit-done/workflows/settings.md: Add UI for the new setting Fixes #976 --- get-shit-done/templates/config.json | 3 +++ get-shit-done/workflows/settings.md | 13 +++++++++++++ hooks/gsd-context-monitor.js | 14 ++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/get-shit-done/templates/config.json b/get-shit-done/templates/config.json index dde3cf787..462e63628 100644 --- a/get-shit-done/templates/config.json +++ b/get-shit-done/templates/config.json @@ -33,5 +33,8 @@ "safety": { "always_confirm_destructive": true, "always_confirm_external_services": true + }, + "hooks": { + "context_warnings": true } } diff --git a/get-shit-done/workflows/settings.md b/get-shit-done/workflows/settings.md index 08859d263..65bbe0188 100644 --- a/get-shit-done/workflows/settings.md +++ b/get-shit-done/workflows/settings.md @@ -126,6 +126,15 @@ AskUserQuestion([ { label: "Per Phase", description: "Create branch for each phase (gsd/phase-{N}-{name})" }, { label: "Per Milestone", description: "Create branch for entire milestone (gsd/{version}-{name})" } ] + }, + { + question: "Enable context window warnings? (injects advisory messages when context is getting full)", + header: "Ctx Warnings", + multiSelect: false, + options: [ + { label: "Yes (Recommended)", description: "Warn when context usage exceeds 65%. Helps avoid losing work." }, + { label: "No", description: "Disable warnings. Allows Claude to reach auto-compact naturally. Good for long unattended runs." } + ] } ]) ``` @@ -149,6 +158,9 @@ Merge new settings into existing config.json: }, "git": { "branching_strategy": "none" | "phase" | "milestone" + }, + "hooks": { + "context_warnings": true/false } } ``` @@ -220,6 +232,7 @@ Display: | UI Phase | {On/Off} | | UI Safety Gate | {On/Off} | | Git Branching | {None/Per Phase/Per Milestone} | +| Context Warnings | {On/Off} | | Saved as Defaults | {Yes/No} | These settings apply to future /gsd:plan-phase and /gsd:execute-phase runs. diff --git a/hooks/gsd-context-monitor.js b/hooks/gsd-context-monitor.js index 4bb216e3b..3f65a75cd 100644 --- a/hooks/gsd-context-monitor.js +++ b/hooks/gsd-context-monitor.js @@ -43,6 +43,20 @@ process.stdin.on('end', () => { process.exit(0); } + // Check if context warnings are disabled via config + const cwd = data.cwd || process.cwd(); + const configPath = path.join(cwd, '.planning', 'config.json'); + if (fs.existsSync(configPath)) { + try { + const config = JSON.parse(fs.readFileSync(configPath, 'utf8')); + if (config.hooks?.context_warnings === false) { + process.exit(0); + } + } catch (e) { + // Ignore config parse errors + } + } + const tmpDir = os.tmpdir(); const metricsPath = path.join(tmpDir, `claude-ctx-${sessionId}.json`);