Hygiene
Automatic context persistence for Claude Code. One command to install, then it just works.
pip install novyx-hygiene
hygiene installThat's it. Your sessions now survive /compact, /clear, and restarts — no export, no paste, no manual steps.
Before & After
Manual loop
Automatic
Claude just knows where you left off.
pip install novyx-hygiene && hygiene installThat's it. Two commands, zero ongoing effort.
How It Works
Before /compact
Hygiene auto-saves your session — task, decisions, files, git state.
After compact/clear/resume
Hygiene injects your context back into Claude automatically.
On disk
A .claude/hygiene.md file keeps Claude oriented between sessions.
See It in Action
✓ PreCompact: hygiene save --auto
✓ SessionStart: hygiene inject (compact, clear, resume)
Compacting conversation...
✓ Task: Building auth flow - JWT login done, registration next
✓ Branch: feat/auth-flow (3 files modified)
✓ 2 key decisions restored
Hook Workflow
After hygiene install, your .claude/settings.local.json gets:
{
"hooks": {
"PreCompact": [
{
"hooks": [{
"type": "command",
"command": "hygiene save --auto --quiet",
"timeout": 10
}]
}
],
"SessionStart": [
{
"matcher": "compact",
"hooks": [{ "type": "command", "command": "hygiene inject", "timeout": 5 }]
},
{
"matcher": "clear",
"hooks": [{ "type": "command", "command": "hygiene inject", "timeout": 5 }]
},
{
"matcher": "resume",
"hooks": [{ "type": "command", "command": "hygiene inject", "timeout": 5 }]
}
]
}
}PreCompact
Auto-save
Before context is lost
SessionStart
Auto-inject
When session resumes
On disk
.claude/hygiene.md
Claude reads it natively
- ✓Hooks are additive — they won't overwrite your existing Claude Code hooks
What Gets Saved
Example .claude/hygiene.md (auto-generated):
# Session Context
## Task
Building auth flow - JWT login done, registration next
## Key Decisions
- Use Stripe Intents API for payments
- Keep backward compat with v1 tokens
## Status
In progress — registration endpoint scaffolded
## Git State
Branch: feat/auth-flow
Modified: src/auth.py, src/routes/register.py
Staged: src/middleware/jwt.py
Recent: "feat: add JWT login endpoint" (2m ago)
## Working Directory
~/Code/novyx-coreCommands
hygiene install
Wire up Claude Code hooks. Run once per project or globally.
hygiene install # Project-level (.claude/settings.local.json)
hygiene install --user # User-level (~/.claude/settings.json)hygiene save <task>
Manually save session state. Also auto-writes .claude/hygiene.md.
hygiene save "Building auth flow - JWT login done, registration next"
hygiene save "Refactoring payments" -d "Use Stripe Intents API" -d "Keep backward compat"
hygiene save "Bug fix" -s "Root cause found, writing test"hygiene resume [session-id]
Print session context for pasting (useful without hooks installed).
hygiene resume # Most recent session
hygiene resume auth-flow-0309 # Specific sessionhygiene score [session-id]
Check context health: freshness, file sprawl, decision tracking.
$ hygiene score
Context Health: B (80/100)
========================================
Issues:
- 12 files in flight
- Changes span 5 top-level directories — possible mixed concerns
Tips:
- Consider committing completed work before continuing
- Consider splitting into focused sessionshygiene list
List all saved sessions.
hygiene list
hygiene list -n 5hygiene config
Configure cloud sync and other settings.
hygiene config set api_key nram_xxx # Enable cloud sync
hygiene config showCloud Sync (Optional)
By default, sessions are saved locally to ~/.novyx_hygiene/sessions/.
Add a Novyx API key for cloud persistence, semantic search across sessions, and cross-machine sync:
pip install novyx-hygiene[novyx]
hygiene config set api_key nram_your_key_hereFree to start, cloud sync on paid tiers
Local mode works with zero configuration. Cloud sync requires a Novyx API key.
Uninstall
hygiene uninstall # Remove project hooks
hygiene uninstall --user # Remove user-level hooksWhy not just a CLAUDE.md file?
- ✕Written once, goes stale
- ✕Doesn't know your git state
- ✕Lost on /compact
- ✕No session history
- ✕Manual maintenance
- ✓Auto-updates every session
- ✓Captures branch, modified files, staged changes
- ✓Saved before /compact via hooks
- ✓Full session history — resume any state by ID
- ✓Health scoring: freshness, sprawl, mixed concerns
CLAUDE.md is great for project-level instructions. Hygiene handles session-level state that changes every hour.
Stop exporting. Start shipping.
Two commands. Your sessions survive everything. Context that just works.
pip install novyx-hygiene
hygiene install