Skip to content

Commit ae16bf3

Browse files
committed
V6.6.1 - Context pressure gate, Tailwind v4 reference, plan-level security flag, stub scan, and cleaner docs paths.
### New Features **Context pressure gate** — The skill-activator hook (and its Codex adapter) now reads the live session JSONL to estimate context window usage, and hard-blocks plan-execution prompts when the last assistant turn exceeded 60% of the 200K window. When triggered, the hook replaces all skill hints with a compact-first instruction telling the model to save state.md via context-management, run /compact, and resume from state.md. This prevents Auto Compact from firing mid-implementation and destroying file paths, variable names, and discovered facts at the worst possible moment. Pressure is computed from `input + cache_creation + cache_read` of the last assistant turn — that is the actual current context size, not a cumulative sum across turns. **Tailwind v4 reference (`skills/frontend-design/tailwind-v4.md`)** — A dedicated companion file with v4 install commands, `@theme` config syntax, renamed class scales, and new features. Frontend-design's training data is biased toward v3, which leads to broken setups when scaffolding for current Tailwind and it leads to not getting the latest and greatest for your UI designs. The skill now routes to this file before any Tailwind work on greenfield or version-unknown projects. ### Changes **Writing-plans: security flag per task** — Every task in a plan now carries a `Security flag: none | security` line. Setting it to `security` (for tasks handling auth, credentials, input validation, permissions, crypto, or data-access boundaries) triggers a pre-implementation security review before the implementer is dispatched. Catches the class of bug where security-relevant work ships without anyone explicitly checking it. **Writing-plans: scope-reduction scan** — Plan self-review now searches the plan for "v1", "basic", "simple", "for now", "placeholder", "initial version", and "minimal", and verifies each hit was explicitly sanctioned by the user. Catches quiet scope downgrades where the model promises less than what was asked for without flagging it. **Writing-plans: execution auto-selection** — Replaces the open "Which approach?" question with deterministic logic: ≥60% context or ≥5 tasks → subagent-driven; heavy inter-task state sharing → inline; default → subagent. The "Ready to execute" framing and explicit "Stop here" instruction give the user a real redirect window instead of the model chaining straight into execution. **Verification-before-completion: stub scan** — Implementation tasks now require a grep pass for `TODO`, `FIXME`, `placeholder`, and `NotImplementedError` (excluding test files) before any "done" claim. Any hit in a file the task created or modified blocks completion until the stub is removed or explicitly justified. Catches the common failure mode of declaring success while leaving stub code in production. **Frontend-design: framework & version awareness** — Before scaffolding any CSS framework, the skill now requires inspecting `package.json` and CSS entry files to detect the existing version (or stating the chosen version explicitly on greenfield). Mixing v3 config syntax with v4 CSS directives produces broken builds; this gate prevents that class of error. **Dependency-management trigger refinement** — Removed "version bump" from the dependency-management trigger keywords. It was overlapping with the dedicated `version-bump` skill, causing the wrong workflow to load on plain version-bump requests. **Cleaner docs output paths** — Brainstorming specs and writing-plans plans now save to `docs/specs/` and `docs/plans/` instead of `docs/superpowers-optimized/specs/` and `docs/superpowers-optimized/plans/`. The plugin name no longer surfaces in the folder structure of every project that uses these skills. CLAUDE.md, both skill files, both reviewer prompt templates, the autoimprove fixture, and all integration tests were updated. The `stop-reminders` decision-log detection was unaffected — its regex already matched any `specs/` or `plans/` parent folder rather than the plugin-namespaced one, so existing repos with the old path continue triggering reminders correctly. **Test coverage** — ~290 lines of new tests in `test-skill-activator.js` cover the context pressure gate: execution-trigger pattern matching, Windows/Unix `cwdToProjectDir` encoding, JSONL pressure parsing, threshold behavior, and the block message format.
1 parent 3229d61 commit ae16bf3

27 files changed

Lines changed: 1061 additions & 40 deletions

.claude-plugin/marketplace.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
{
1111
"name": "superpowers-optimized",
1212
"description": "Agentic development framework for Claude Code — disciplined workflow routing, TDD enforcement, safety hooks, systematic debugging, and code review",
13-
"version": "6.6.0",
13+
"version": "6.6.1",
1414
"source": "./",
1515
"author": {
1616
"name": "REPOZY"

.claude-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "superpowers-optimized",
33
"description": "Agentic development framework for Claude Code — disciplined workflow routing, TDD enforcement, safety hooks, systematic debugging, and code review",
4-
"version": "6.6.0",
4+
"version": "6.6.1",
55
"author": {
66
"name": "Jesse Vincent, forked by REPOZY"
77
},

.codex-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "superpowers-optimized",
3-
"version": "6.6.0",
3+
"version": "6.6.1",
44
"description": "Structured workflow skills for Codex — systematic debugging, TDD, brainstorming, code review, and 30+ expert workflows. Skills work on all platforms. Lifecycle hooks (routing, safety, reminders) require separate setup on macOS/Linux.",
55
"author": {
66
"name": "Jesse Vincent, forked by REPOZY"

.cursor-plugin/plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "superpowers-optimized",
33
"displayName": "Superpowers Optimized",
44
"description": "Agentic development framework — disciplined workflow routing, TDD enforcement, safety hooks, systematic debugging, and code review",
5-
"version": "6.6.0",
5+
"version": "6.6.1",
66
"author": {
77
"name": "Jesse Vincent, forked by REPOZY"
88
},

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,7 @@ skills/ — 24 skills, each in skills/<name>/SKILL.md
255255
hooks/ — 10 hooks (JS) + hooks.json registry + skill-rules.json
256256

257257
## Key Files
258-
hooks/skill-activator.js — UserPromptSubmit: scores prompts against skill-rules.json,
259-
injects skill hints. Micro-task detection (≤8 words + patterns = skip routing).
258+
hooks/skill-activator.js — UserPromptSubmit: context pressure gate (blocks plan execution at ≥60% context, reads session JSONL); skill hints via skill-rules.json; memory recall from session-log.md + known-issues.md. Micro-task detection skips all enrichment.
260259
hooks/skill-rules.json — 22 rules: skill name, keywords, intentPatterns, priority.
261260

262261
## Critical Constraints
@@ -408,7 +407,7 @@ This is the full cross-platform hook inventory for the plugin. Claude Code gets
408407

409408
- **context-engine** (SessionStart) — Runs git commands on every session start and writes `context-snapshot.json`: changed files, blast radius (which other files reference each changed file, filtered to actual import/require references), recent commits, and change stats. Uses per-project watermarks (md5 of cwd) so multiple projects don't interfere, and cross-session diff base so "what changed" reflects changes since your last session, not just the last commit. Zero dependencies. Silent no-op on non-git projects
410409
- **session-start** (SessionStart) — Injects using-superpowers routing into every session; injects `project-map.md` content directly if it exists (full content ≤200 lines, Critical Constraints + Hot Files only above that); checks for available plugin update
411-
- **skill-activator** (UserPromptSubmit) — Micro-task detection + confidence-threshold skill matching + weighted memory recall from session-log.md and known-issues.md (70% keyword density + 30% recency scoring)
410+
- **skill-activator** (UserPromptSubmit) — Context pressure gate: reads session JSONL, blocks plan-execution triggers when context ≥60% of 200K window (fires compact-first instruction instead of skill hints). Also: micro-task detection + confidence-threshold skill matching + weighted memory recall from session-log.md and known-issues.md (70% keyword density + 30% recency scoring)
412411
- **track-edits** (PostToolUse: Edit/Write) — Logs file changes for TDD reminders; auto-adds AI workspace artifacts (`project-map.md`, `session-log.md`, `state.md`) to `.gitignore` on first write
413412
- **track-session-stats** (PostToolUse: Skill) — Tracks skill invocations for progress visibility
414413
- **stop-reminders** (Stop) — Surfaces TDD reminders, commit nudges, and session summary after each response turn

RELEASE-NOTES.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Superpowers Optimized Release Notes
22

3+
## v6.6.1 (2026-05-08)
4+
5+
Context pressure gate, Tailwind v4 reference, plan-level security flag, stub scan, and cleaner docs paths.
6+
7+
### New Features
8+
9+
**Context pressure gate** — The skill-activator hook (and its Codex adapter) now reads the live session JSONL to estimate context window usage, and hard-blocks plan-execution prompts when the last assistant turn exceeded 60% of the 200K window. When triggered, the hook replaces all skill hints with a compact-first instruction telling the model to save state.md via context-management, run /compact, and resume from state.md. This prevents Auto Compact from firing mid-implementation and destroying file paths, variable names, and discovered facts at the worst possible moment. Pressure is computed from `input + cache_creation + cache_read` of the last assistant turn — that is the actual current context size, not a cumulative sum across turns.
10+
11+
**Tailwind v4 reference (`skills/frontend-design/tailwind-v4.md`)** — A dedicated companion file with v4 install commands, `@theme` config syntax, renamed class scales, and new features. Frontend-design's training data is biased toward v3, which leads to broken setups when scaffolding for current Tailwind. The skill now routes to this file before any Tailwind work on greenfield or version-unknown projects.
12+
13+
### Changes
14+
15+
**Writing-plans: security flag per task** — Every task in a plan now carries a `Security flag: none | security` line. Setting it to `security` (for tasks handling auth, credentials, input validation, permissions, crypto, or data-access boundaries) triggers a pre-implementation security review before the implementer is dispatched. Catches the class of bug where security-relevant work ships without anyone explicitly checking it.
16+
17+
**Writing-plans: scope-reduction scan** — Plan self-review now searches the plan for "v1", "basic", "simple", "for now", "placeholder", "initial version", and "minimal", and verifies each hit was explicitly sanctioned by the user. Catches quiet scope downgrades where the model promises less than what was asked for without flagging it.
18+
19+
**Writing-plans: execution auto-selection** — Replaces the open "Which approach?" question with deterministic logic: ≥60% context or ≥5 tasks → subagent-driven; heavy inter-task state sharing → inline; default → subagent. The "Ready to execute" framing and explicit "Stop here" instruction give the user a real redirect window instead of the model chaining straight into execution.
20+
21+
**Verification-before-completion: stub scan** — Implementation tasks now require a grep pass for `TODO`, `FIXME`, `placeholder`, and `NotImplementedError` (excluding test files) before any "done" claim. Any hit in a file the task created or modified blocks completion until the stub is removed or explicitly justified. Catches the common failure mode of declaring success while leaving stub code in production.
22+
23+
**Frontend-design: framework & version awareness** — Before scaffolding any CSS framework, the skill now requires inspecting `package.json` and CSS entry files to detect the existing version (or stating the chosen version explicitly on greenfield). Mixing v3 config syntax with v4 CSS directives produces broken builds; this gate prevents that class of error.
24+
25+
**Dependency-management trigger refinement** — Removed "version bump" from the dependency-management trigger keywords. It was overlapping with the dedicated `version-bump` skill, causing the wrong workflow to load on plain version-bump requests.
26+
27+
**Cleaner docs output paths** — Brainstorming specs and writing-plans plans now save to `docs/specs/` and `docs/plans/` instead of `docs/superpowers-optimized/specs/` and `docs/superpowers-optimized/plans/`. The plugin name no longer surfaces in the folder structure of every project that uses these skills. CLAUDE.md, both skill files, both reviewer prompt templates, the autoimprove fixture, and all integration tests were updated. The `stop-reminders` decision-log detection was unaffected — its regex already matched any `specs/` or `plans/` parent folder rather than the plugin-namespaced one, so existing repos with the old path continue triggering reminders correctly.
28+
29+
**Test coverage**~290 lines of new tests in `test-skill-activator.js` cover the context pressure gate: execution-trigger pattern matching, Windows/Unix `cwdToProjectDir` encoding, JSONL pressure parsing, threshold behavior, and the block message format.
30+
331
## v6.6.0 (2026-04-15)
432

533
Full-stack audit: 3 new skills, smarter cross-session memory, scope gates across 6 skills, and expanded hook coverage.

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.6.0
1+
6.6.1

hooks/codex/user-prompt-submit-adapter.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const {
1212
buildContext, isMicroTask, matchSkills,
1313
extractKeywords, searchSessionLog, buildMemoryContext,
1414
searchKnownIssues, buildKnownIssuesContext,
15+
isExecutionTrigger, getContextPressure, buildContextPressureBlock,
1516
} = require('../skill-activator');
1617
const { readJsonStdin } = require('./utils');
1718

@@ -22,6 +23,20 @@ function evaluatePayload(data) {
2223
if (!prompt || isMicroTask(prompt)) return {};
2324

2425
const cwd = typeof data.cwd === 'string' ? data.cwd : process.cwd();
26+
const sessionId = typeof data.session_id === 'string' ? data.session_id : null;
27+
28+
// Context pressure gate: block plan execution when context ≥60%
29+
if (isExecutionTrigger(prompt)) {
30+
const pressure = getContextPressure(cwd, sessionId);
31+
if (pressure && pressure.overThreshold) {
32+
return {
33+
hookSpecificOutput: {
34+
hookEventName: 'UserPromptSubmit',
35+
additionalContext: buildContextPressureBlock(pressure),
36+
},
37+
};
38+
}
39+
}
2540

2641
const matches = matchSkills(prompt);
2742
const keywords = extractKeywords(prompt);

hooks/skill-activator.js

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,129 @@ function buildKnownIssuesContext(entries) {
365365
].join('\n');
366366
}
367367

368+
// ── Context pressure gate ─────────────────────────────────────────────────────
369+
370+
/**
371+
* Patterns that indicate the user is about to start plan execution
372+
* or heavy implementation work.
373+
*/
374+
const EXECUTION_TRIGGER_PATTERNS = [
375+
/\bexecute\s+(the\s+)?plan\b/i,
376+
/\bstart\s+build(ing)?\b/i,
377+
/\bstart\s+implement(ing|ation)?\b/i,
378+
/\bfollow\s+(the\s+)?plan\b/i,
379+
/\bimplement\s+(the\s+)?plan\b/i,
380+
/\blet'?s\s+(build|implement|execute)\b/i,
381+
/\brun\s+(the\s+)?plan\b/i,
382+
/\bbegin\s+implement(ing|ation)?\b/i,
383+
/\bbegin\s+(the\s+)?plan\b/i,
384+
];
385+
386+
const CONTEXT_WINDOW_SIZE = 200000; // Sonnet 4.6 context window tokens
387+
const CONTEXT_PRESSURE_THRESHOLD = 0.60; // Hard block at 60%
388+
389+
/**
390+
* Returns true if the prompt is triggering plan execution or heavy implementation.
391+
*/
392+
function isExecutionTrigger(prompt) {
393+
if (!prompt || typeof prompt !== 'string') return false;
394+
return EXECUTION_TRIGGER_PATTERNS.some(p => p.test(prompt));
395+
}
396+
397+
/**
398+
* Convert a filesystem cwd path to the Claude Code project directory name.
399+
* Examples:
400+
* Windows: "C:\Users\Tjerk Pieksma\..." → "c--Users-Tjerk-Pieksma-..."
401+
* Unix: "/home/user/projects/foo" → "home-user-projects-foo"
402+
*/
403+
function cwdToProjectDir(cwd) {
404+
return cwd
405+
.replace(/^([A-Za-z]):/, (_, d) => d.toLowerCase() + '-') // C: → c-
406+
.replace(/[/\\]/g, '-') // path separators → -
407+
.replace(/\s/g, '-') // spaces → -
408+
.replace(/-+$/, ''); // trim trailing dashes
409+
}
410+
411+
/**
412+
* Read the current session JSONL and return context pressure info.
413+
* Uses the last assistant turn's total input tokens as the context size estimate —
414+
* this is the most accurate indicator of how much context window is currently occupied.
415+
* Returns null if the JSONL can't be read or has no usable data.
416+
*/
417+
function getContextPressure(cwd, sessionId) {
418+
if (!sessionId) return null;
419+
420+
const projectDir = cwdToProjectDir(cwd);
421+
const homeDir = process.env.USERPROFILE || process.env.HOME || '';
422+
const jsonlPath = path.join(homeDir, '.claude', 'projects', projectDir, sessionId + '.jsonl');
423+
424+
let content;
425+
try {
426+
content = fs.readFileSync(jsonlPath, 'utf8');
427+
} catch {
428+
return null; // File absent or unreadable — silent no-op
429+
}
430+
431+
// Use the last assistant turn's input total as context size.
432+
// input + cache_creation + cache_read = total tokens in context window for that turn.
433+
// Later turns always have more context, so the last value is the current state.
434+
let lastInputTotal = 0;
435+
436+
for (const line of content.split('\n')) {
437+
if (!line.trim()) continue;
438+
try {
439+
const obj = JSON.parse(line);
440+
if (obj.type === 'assistant' && obj.message && obj.message.usage) {
441+
const u = obj.message.usage;
442+
const turnInput = (u.input_tokens || 0)
443+
+ (u.cache_creation_input_tokens || 0)
444+
+ (u.cache_read_input_tokens || 0);
445+
if (turnInput > 0) lastInputTotal = turnInput;
446+
}
447+
} catch {
448+
// Skip malformed lines
449+
}
450+
}
451+
452+
if (lastInputTotal === 0) return null;
453+
454+
const ratio = lastInputTotal / CONTEXT_WINDOW_SIZE;
455+
return {
456+
inputK: Math.round(lastInputTotal / 1000),
457+
percent: Math.round(ratio * 100),
458+
overThreshold: ratio >= CONTEXT_PRESSURE_THRESHOLD,
459+
};
460+
}
461+
462+
/**
463+
* Build the hard block message injected when context pressure ≥60%.
464+
* Returned as additionalContext — Claude sees this instead of skill hints.
465+
*/
466+
function buildContextPressureBlock(pressure) {
467+
return [
468+
'<context-pressure-gate>',
469+
`STOP — Do not start implementation yet.`,
470+
``,
471+
`Context window: ~${pressure.inputK}K tokens consumed (${pressure.percent}% of 200K limit).`,
472+
`Starting implementation at ≥60% risks Auto Compact firing mid-task, destroying`,
473+
`variable names, file paths, and discovered facts at the worst possible moment.`,
474+
``,
475+
`Required actions before proceeding:`,
476+
`1. Invoke the context-management skill to write state.md. Include:`,
477+
` - Path to the plan file`,
478+
` - Starting task number (e.g. "Task 1 — fresh start")`,
479+
` - Any research-phase facts (exact file paths, variable names, non-obvious`,
480+
` constraints) that the plan references but does not spell out explicitly.`,
481+
`2. Tell the user: "Context is at ${pressure.percent}%. Saving state and compacting`,
482+
` before implementation — this prevents Auto Compact firing mid-task."`,
483+
`3. Run /compact.`,
484+
`4. After compaction, read state.md and resume with executing-plans.`,
485+
``,
486+
`Do NOT begin implementation without completing steps 1–3.`,
487+
`</context-pressure-gate>`,
488+
].join('\n');
489+
}
490+
368491
// ── Main ──────────────────────────────────────────────────────────────────────
369492

370493
async function main() {
@@ -375,13 +498,30 @@ async function main() {
375498
const data = JSON.parse(input);
376499
const prompt = data.prompt || '';
377500
const cwd = data.cwd || process.cwd();
501+
const sessionId = data.session_id || null;
378502

379503
// Micro-task fast path: skip all enrichment entirely
380504
if (isMicroTask(prompt)) {
381505
process.stdout.write('{}');
382506
return;
383507
}
384508

509+
// Context pressure gate: if the user is about to start implementation and
510+
// the context window is ≥60% full, block and require compact-first.
511+
// Returns early — pressure block replaces all other hints when it fires.
512+
if (isExecutionTrigger(prompt)) {
513+
const pressure = getContextPressure(cwd, sessionId);
514+
if (pressure && pressure.overThreshold) {
515+
process.stdout.write(JSON.stringify({
516+
hookSpecificOutput: {
517+
hookEventName: 'UserPromptSubmit',
518+
additionalContext: buildContextPressureBlock(pressure),
519+
},
520+
}));
521+
return;
522+
}
523+
}
524+
385525
// Run all pipelines independently
386526
const matches = matchSkills(prompt);
387527
const keywords = extractKeywords(prompt);
@@ -425,9 +565,15 @@ if (require.main === module) {
425565
buildMemoryContext,
426566
searchKnownIssues,
427567
buildKnownIssuesContext,
568+
isExecutionTrigger,
569+
cwdToProjectDir,
570+
getContextPressure,
571+
buildContextPressureBlock,
428572
RULES,
429573
CONFIDENCE_THRESHOLD,
430574
STOP_WORDS,
431575
MAX_MEMORY_ENTRIES,
576+
CONTEXT_WINDOW_SIZE,
577+
CONTEXT_PRESSURE_THRESHOLD,
432578
};
433579
}

skills/brainstorming/SKILL.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Every project goes through this process. A todo list, a single-function utility,
3434
- **Critical** (design fails for a significant user scenario): revise the design before proceeding.
3535
- **Minor** (edge case, acceptable limitation): document as a non-goal in the design.
3636
Do not skip this step. An approach that survives adversarial questioning is an approach worth approving.
37-
9. Save approved design to `docs/superpowers-optimized/specs/YYYY-MM-DD-<topic>-design.md`.
37+
9. Save approved design to `docs/specs/YYYY-MM-DD-<topic>-design.md`.
3838
10. **Spec self-review** — quick inline check for placeholders, contradictions, ambiguity, scope (see Spec Self-Review below). Fix issues inline; no subagent dispatch needed.
3939
11. **User reviews written spec** — ask user to review the spec file before proceeding (see User Review Gate below).
4040
12. Invoke `writing-plans`.
@@ -129,7 +129,7 @@ Apply senior engineering judgment during design:
129129

130130
- User approved the design.
131131
- Failure-mode check completed — critical failure modes resolved, minor ones documented as non-goals.
132-
- Design document exists at the required path (`docs/superpowers-optimized/specs/`).
132+
- Design document exists at the required path (`docs/specs/`).
133133
- Spec self-review completed — placeholders, contradictions, ambiguity, and scope issues resolved.
134134
- User reviewed the written spec and approved.
135135
- `writing-plans` is invoked as the next skill.

0 commit comments

Comments
 (0)