Skip to main content

Tidy up your Claude Code environment — sessions, permissions, context, hooks, schedule.

Project description

cc-janitor

Tidy up your Claude Code environment — sessions, permissions, context, hooks.

The first unified TUI/CLI that combines session cleanup, permission pruning, CLAUDE.md/memory inspection, hook debugging (Phase 2), and scheduled maintenance (Phase 2) — all the chores no one else automates, in one tool.

Languages: English / Русский (toggle with F2 in TUI, --lang ru in CLI)

Stack

  • Language: Python 3.11+
  • TUI: Textual (terminal UI framework)
  • CLI: Typer
  • Token estimation: OpenAI tiktoken (cl100k_base, ~5% off for Claude)
  • Tests: pytest + pytest-asyncio + pytest-textual-snapshot
  • Distribution: PyPI via uv tool / pipx

Features (Phase 1 MVP)

Sessions

  • List, search, preview Claude Code sessions in ~/.claude/projects/
  • Soft-delete to recoverable trash; restore from trash via cc-janitor trash restore
  • Inspect compact-summaries and your own indexer markdown summaries

Permissions

  • Discover all rules across global / project, settings.json / .local.json, and ~/.claude.json approvedTools
  • Mark stale rules (no match in last 90 days) by scanning your transcripts
  • Dedupe (subsumed/exact) and prune (stale) — with backups before write

Context inspector

  • Walk CLAUDE.md hierarchy, list memory files, list enabled skills
  • Compute byte/token cost per file + recurring-per-request total
  • Show estimated $ at Opus input rate

Install

⚠️ v0.1.x is not yet on PyPI. Install from source until then:

# Recommended — uv tool from source
uv tool install git+https://github.com/CreatmanCEO/cc-janitor

# Or pipx from source
pipx install git+https://github.com/CreatmanCEO/cc-janitor

# From a local clone for development
git clone https://github.com/CreatmanCEO/cc-janitor && cd cc-janitor
uv sync --all-extras
uv run cc-janitor

PyPI publishing arrives once Trusted Publisher is configured on pypi.org. Track via issue #1 once filed.

Quick start

# Launch TUI
cc-janitor

# CLI: list sessions
cc-janitor session list

# Audit your permission rules
cc-janitor perms audit

# Inspect what your context costs you per request
cc-janitor context cost

# Mutating commands require explicit confirmation:
CC_JANITOR_USER_CONFIRMED=1 cc-janitor session prune --older-than 90d

Safety model

cc-janitor never silently destroys data:

  • CC_JANITOR_USER_CONFIRMED=1 gate: every mutating command refuses to run unless this env var is set. Read-only commands (list, show, audit, cost) are always free to call.
  • Soft-delete: sessions deleted move to ~/.cc-janitor/.trash/<timestamp>/ for 30 days. Restore via cc-janitor trash restore <id>.
  • Backups before write: every settings.json edit creates a timestamped backup in ~/.cc-janitor/backups/<sha-of-path>/.
  • Audit log: every mutating action appends a JSONL record to ~/.cc-janitor/audit.log (rotates at 10 MB).

Windows users: cc-janitor install-hooks writes a POSIX shell snippet (test -f, &&). On native Windows without Git Bash / WSL the hook will fail silently. Cross-platform PowerShell support lands in 0.2.0 (Phase 2). Use Git Bash or WSL in the meantime.

Using from inside Claude Code

cc-janitor is designed to be invoked by both you (TUI / CLI) and Claude Code itself (CLI), but only on your explicit request. See docs/CC_USAGE.md for the reference Claude Code reads when deciding whether a subcommand is safe to call.

Phase 4: Dream safety net

Dream safety net — snapshot before Auto Dream, diff after, rollback if needed. Closes upstream Issues #47959, #50694, #38493, #38461.

# Opt-in: poll lock files and snapshot around every Auto Dream cycle
CC_JANITOR_USER_CONFIRMED=1 cc-janitor watch start --dream

# Review what each Dream cycle changed
cc-janitor dream history
cc-janitor dream diff <pair_id>

# 10 health checks covering stale locks, autoDream flag, disk, hygiene
cc-janitor dream doctor

# Roll back if Dream rewrote something you wanted
CC_JANITOR_USER_CONFIRMED=1 cc-janitor dream rollback <pair_id> --apply

Roadmap

  • Phase 1: sessions / permissions / context inspector / CLI / TUI / safety primitives
  • Phase 2: memory editor, reinject hook, hook debugger with simulation, scheduler (cron / Task Scheduler)
  • Phase 3: monorepo nested .claude/ discovery, auto-reinject watcher, stats dashboard, export/import config
  • Phase 4: Dream safety net — snapshot/diff/doctor/rollback, sleep-hygiene metrics, settings audit hook
  • Phase 5: cross-platform hook fixers, dream fix-stale-lock, deeper TUI for Dream pair review

Contributing

Issues and PRs welcome. See docs/architecture.md for the codebase tour.

License

MIT — see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cc_janitor-0.4.0.tar.gz (305.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cc_janitor-0.4.0-py3-none-any.whl (91.6 kB view details)

Uploaded Python 3

File details

Details for the file cc_janitor-0.4.0.tar.gz.

File metadata

  • Download URL: cc_janitor-0.4.0.tar.gz
  • Upload date:
  • Size: 305.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cc_janitor-0.4.0.tar.gz
Algorithm Hash digest
SHA256 dedcd79af3103cf1955f48c29d64299ec26764ad9251c3ad8051d83fa8fe33ee
MD5 8589c4a2e86a9eef914d1c8fe7b49333
BLAKE2b-256 a1d36fa8193896fbd9927f752abf7fb5d5971f88f7f8648fa0c3d456b4c6cbca

See more details on using hashes here.

Provenance

The following attestation bundles were made for cc_janitor-0.4.0.tar.gz:

Publisher: release.yml on CreatmanCEO/cc-janitor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cc_janitor-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: cc_janitor-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 91.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for cc_janitor-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9070cecb8f43d54ca566f1918f80d3478fc50d115627bf377107388f266c3a68
MD5 d5e620b021bf6666adddf4256d7c0b3a
BLAKE2b-256 a25626bc3484d291427c233b66655f756d4d536c889e7d60abc00bb56a616c8b

See more details on using hashes here.

Provenance

The following attestation bundles were made for cc_janitor-0.4.0-py3-none-any.whl:

Publisher: release.yml on CreatmanCEO/cc-janitor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page