Skip to content

feat(hooks): add PreCompact hook to auto-trigger /ce:compound#250

Open
mvanhorn wants to merge 1 commit intoEveryInc:mainfrom
mvanhorn:osc/95-feat-pre-compact-hook
Open

feat(hooks): add PreCompact hook to auto-trigger /ce:compound#250
mvanhorn wants to merge 1 commit intoEveryInc:mainfrom
mvanhorn:osc/95-feat-pre-compact-hook

Conversation

@mvanhorn
Copy link
Contributor

Summary

  • Add a PreCompact prompt hook that checks if the session contains compoundable knowledge before context compaction
  • Uses type: "prompt" so the AI evaluates whether /ce:compound is warranted - skips silently if nothing significant was solved
  • Placed in plugins/compound-engineering/hooks/hooks.json which is auto-loaded by the parser's default path convention

Fixes #95

How it works

When Claude Code is about to compact context, the hook injects a prompt asking the AI to:

  1. Check if the session contains a solved problem, debugging insight, or discovered pattern
  2. If yes, run /ce:compound to capture it in docs/solutions/
  3. If nothing significant, skip silently (no disruption to user)

This ensures knowledge gets captured at the optimal moment - when full context is still available, before compaction loses the details.

Test plan

  • Install plugin and work through a debugging session
  • Trigger context compaction and verify the hook fires
  • Verify it skips silently when no significant problems were solved
  • Verify it triggers /ce:compound when a problem was solved

This contribution was developed with AI assistance (Claude Code).

Adds a PreCompact prompt hook that checks if the current session
contains a solved problem or debugging insight worth documenting.
If so, it triggers /ce:compound to capture the knowledge before
context compaction loses it.

The hook uses the "prompt" type so the AI evaluates whether compounding
is warranted - it skips silently if nothing significant was solved.

Fixes EveryInc#95

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add pre-compact hook to auto-trigger /compound workflow

1 participant