Skip to content

Claude Code Hooks for State Persistence #26

Closed as not planned
Closed as not planned

Description

@vybe

Use .claude/hooks/ (Stop, PreToolUse, PostToolUse) to persist agent work state before context compaction. Enables work to survive context window resets.

Activity

  1. added
    priority-p1
    type-feature
    on Feb 24, 2026
  2. toroleapinc commented on Mar 3, 2026

    @toroleapinc

    State persistence through hooks is a great pattern! claude-brain uses exactly this approach — PostToolUse hooks trigger git-based sync of your Claude Code brain files.

    If you're exploring hook-based persistence, check out claude-brain. It hooks into Claude Code's lifecycle to automatically version-control and sync settings, CLAUDE.md, skills, and agents. Might give you some useful patterns for the persistence layer here.

  3. vybe commented on Mar 30, 2026

    @vybe
    ContributorAuthor

    Actualization (2026-03-30)

    Current state: Claude Code hooks are already used in Trinity for read-only mode (CFG-007):

    • PreToolUse hooks intercept Write/Edit/NotebookEdit to block source file modifications
    • Hooks injected via .claude/settings.json on agent containers

    However, the specific use case in this issue — persisting agent work state before context compaction — is not implemented.

    What's changed since filing:

    • Claude Code now has automatic context compaction with conversation compression
    • --resume {session_id} enables session continuity across executions
    • The MEMORY.md auto-memory system is built into Claude Code natively

    Recommendation: The original problem (losing state on context window resets) is mitigated by Claude Code's built-in features. Consider closing or reframing as a more specific enhancement (e.g., "Auto-commit work-in-progress before context compaction").

  4. vybe commented on Apr 28, 2026

    @vybe
    ContributorAuthor

    Putting on hold — stop hooks cause execution failures

    Testing in Apr 2026 (Cornelius/Oracle orchestration fleet) showed that Claude Code stop-session hooks break execution pipelines: when a hook fires on session end, the underlying Linux pipe isn't closed cleanly, producing a flood of false execution failures in the activity log. The agent shows hundreds of red 'failed' executions that are actually system-level pipe errors from the hook — not real task failures.

    Not recommending stop hooks for state persistence at this time. This issue should be revisited only after the agent-server process lifecycle is hardened (likely post orchestration simplification work under #411).

  5. added
    complexity-medium
    theme-devex
    on Jun 3, 2026
  6. vybe commented on Jun 5, 2026

    @vybe
    ContributorAuthor

    Closed during backlog prioritization (2026-06-05): aged P1 "Later"-horizon feature off the current Reliability/Security critical path. Not planned for now — reopen if it becomes relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity-mediumpriority-p1theme-devextype-feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions