[FEATURE] Memory-backed constraint enforcement and pre-action gating
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
Claude Code's file-based memory system (~/.claude/memory/) allows users to document critical project constraints, but those constraints are not reliably applied before actions are taken. Users working on complex multi-session engineering projects must repeatedly re-teach the same constraints after violations — constraints that are already documented in memory. The burden of compensating for memory gaps falls entirely on the user, consuming time that should be spent on engineering work.
Specific recurring failures:
- Hard constraints (e.g. "this binary is ARM-only, never run locally") are violated even when documented
- Claude acts before consulting memory, or consults memory but fails to apply what it contains
- The same mistake recurs across sessions even after correction and re-documentation
Proposed Solution
- Constraint enforcement: Allow memory entries to be marked as hard constraints that automatically gate related actions. Before executing any build/deploy/commit/push, Claude should surface and check relevant constraints without requiring the user to prompt it.
- Pre-action memory read: Before any irreversible action (git push, file deletion, deployment), Claude should automatically consult memory entries relevant to that action category.
- Failure pattern recognition: If Claude has made a specific type of error in this project before (documented in memory as a correction), it should recognize and flag that pattern before attempting the same class of action again.
Alternative Solutions
Currently working around this by:
- Adding increasingly emphatic formatting to memory entries ( NEVER DO THIS )
- Re-documenting constraints after each violation
- Manually reminding Claude of constraints before each relevant action
These are not sustainable for long-running projects.
Priority
High - Significant impact on productivity
Feature Category
Other
Use Case Example
- Developer documents in memory: "gearbox-binary is ARM-only — never attempt to build or run locally"
- In a later session, Claude is asked to run tests
- Current behavior: Claude attempts to run the ARM binary on the local x86 machine, fails, wastes time
- Desired behavior: Before attempting to run, Claude checks memory, finds the ARM constraint, and immediately redirects to the correct approach (deploy to target hardware) without needing to be told
Additional Context
Related bug filed separately: post-compaction autopilot executing irreversible git operations without user approval. These issues share the same root cause — memory exists but doesn't reliably gate behavior.
Claude Code CLI version: 2.1.85, Model: claude-sonnet-4-6 (1M context)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗