Skip to main content

Novyx Hygiene

PyPI version License: MIT

Automatic context persistence for Claude Code. One command to install, then it just works.

Your sessions survive /compact, /clear, and restarts — no export, no paste, no manual steps.


How It Works

pip install novyx-hygiene
hygiene install

That's it. From now on:

  1. Before /compact: Hygiene auto-saves your session (task, decisions, files, git state)
  2. After compact/clear/resume: Hygiene injects your context back into Claude automatically
  3. On disk: A .claude/hygiene.md file keeps Claude oriented between sessions

No commands to remember. No context to paste. Claude just knows where you left off.


The Problem

Context fills up. You /compact or /clear. Now Claude has amnesia.

The manual workaround:

  1. /export to copy everything
  2. /clear to reset
  3. Paste context back
  4. Re-establish where you were
  5. Repeat every time

Worse: if compaction hits automatically, you lose context without warning.

Novyx Hygiene makes this automatic.


Commands

hygiene install

Wire up Claude Code hooks. Run once per project (or --user for all projects).

hygiene install          # Project-level (.claude/settings.local.json)
hygiene install --user   # User-level (~/.claude/settings.json)

Installs hooks for:

  • PreCompact — auto-save before context compaction
  • SessionStart — auto-inject after compact, clear, or resume

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"

Options:

  • -d / --decision — Record a key decision (repeatable)
  • -s / --status — Set status (default: "In progress")
  • -i / --session-id — Custom session ID
  • --no-md — Skip writing .claude/hygiene.md

hygiene resume [session-id]

Print session context for pasting (useful without hooks installed).

hygiene resume                    # Most recent session
hygiene resume auth-flow-0309     # Specific session

hygiene inject

Emit context to stdout — used by Claude Code hooks internally. You don't need to call this directly.

hygiene score [session-id]

Check context health: freshness, file sprawl, decision tracking, mixed concerns.

$ 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 sessions

hygiene list

List all saved sessions.

hygiene list
hygiene list -n 5

hygiene uninstall

Remove hooks.

hygiene uninstall
hygiene uninstall --user

hygiene config

hygiene config set api_key nram_xxx    # Enable cloud sync
hygiene config show

What Gets Saved

Every session snapshot captures:

  • Task description — what you're working on
  • Key decisions — architectural choices, tradeoffs
  • Status — where you left off
  • Git state — branch, modified/staged/untracked files, recent commits
  • Working directory — so you resume in the right place
  • Timestamp — for freshness scoring

Cloud 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_here

How Hooks Work

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 hook runs hygiene save --auto before compaction, capturing your current state
  • SessionStart hooks run hygiene inject which outputs your last session context to stdout — Claude reads this automatically
  • Hooks are additive: they won't overwrite your existing Claude Code hooks

License

MIT


Built by Novyx Labs. Stop exporting and start shipping.

Release files for novyx-hygiene 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for novyx-hygiene 2.0.0
File Size Uploaded
novyx_hygiene-2.0.0.tar.gz 18.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for novyx-hygiene 2.0.0
File Interpreter ABI Platform
novyx_hygiene-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size:33.3 kB

Release files / novyx_hygiene-2.0.0.tar.gz

Download URL novyx_hygiene-2.0.0.tar.gz
Size 18.6 kB
Tags Source
SHA-256 checksum
How to use checksums
6b6ef8860a104df6943471e9989f635de7bd2f855a95e802c5209733dead66dd
BLAKE2b-256 checksum
How to use checksums
822d06b0e7a91e25ac719e3df8981ddb8d93536ef0f80beb04c8616aeee6671b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / novyx_hygiene-2.0.0-py3-none-any.whl

Download URL novyx_hygiene-2.0.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
52068610cae95f44dc7c966431e778f8349d95099908cca6db7378c37e0bce94
BLAKE2b-256 checksum
How to use checksums
ca037ae8aaa02b61fef38a4b8746b609bede3ec2c42372029fcacdd321a31bcd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page