A Claude Code plugin that notices when you've drifted to a new topic and gently reminds you to save context before moving on.
Long Claude Code sessions accumulate context from multiple tasks. You start fixing a bug in auth, jump to adding a volume feature, then tweak the CI pipeline. By message 40, Claude is carrying context from three unrelated tasks -- slowing things down and wasting tokens.
topic-switch watches what files you're touching. When you drift from one area of your codebase to another, Claude gets a gentle nudge:
You've moved from
cmd/vmtocmd/volume. Want me to save context and compact before continuing?
It also nudges after 30+ messages (configurable), regardless of topic -- because long sessions get heavy.
Detection runs entirely in bash. Three lightweight hooks:
Claude itself decides whether the shift is worth mentioning. False positives get naturally filtered by Claude's judgment.
claude plugin install topic-switch
git clone https://github.com/nusmql/topic-switch.git
claude --plugin-dir /path/to/topic-switch
On first run in a project, you'll see:
[topic-switch] New project detected. Run
/topic-switch:initto set up topic detection.
Run /topic-switch:init and the plugin will:
cmd/*, src/features/*)Takes about 30 seconds.
| Command | What it does |
|---|---|
/topic-switch:init | Set up topic boundaries for your project |
/topic-switch:save-and-compact | Save session summary to memory + compact context |
Stored per-project at .claude/topic-switch.json (not committed to git):
{
"topic_roots": ["internal/verda-cli/cmd/*"],
"ignore": ["internal/verda-cli/cmd/util"],
"message_threshold": 30
}
| Field | Description | Default |
|---|---|---|
topic_roots | Glob patterns defining topic boundaries in your project | (detected by init) |
ignore | Directories to skip (shared utilities, etc.) | [] |
message_threshold | Message count before suggesting a compact | 30 |
The init scan auto-detects common structures:
| Stack | Detected patterns |
|---|---|
| Go | cmd/*, internal/*, pkg/* |
| React / Next.js | src/features/*, src/pages/*, src/components/*, app/* |
| Monorepo | packages/*, apps/*, services/* |
| Python | src/*, root modules with __init__.py |
| Other | Top-level directories with 3+ source files |
You can always adjust the patterns manually or re-run /topic-switch:init.
You edit cmd/vm/create.go, cmd/vm/wizard.go (topic: vm)
You edit cmd/vm/list.go (topic: vm, no shift)
You edit cmd/volume/create.go (topic: volume -- SHIFT!)
|
next prompt gets a gentle reminder
|
Claude asks: "Want to save and compact?"
Runtime state is stored in ~/.cache/topic-switch/ (auto-cleaned, never committed).
bash and jqMIT
Matches all tools
Hooks run on every tool call, not just specific ones
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimBased on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
npx claudepluginhub hi-lei/topic-switchTopic-based automatic memory for Claude Code — never lose context across sessions or compactions.
Automatic context engineering — observes your coding sessions and generates rules, suggestions, skills, and hooks so Claude gets smarter on your codebase over time
Persistent context for AI coding assistants
Track and summarize all files used during a Claude Code session
Cognitive layer for Claude Code — code navigation, conversation recall, safety hooks, behavioral learning
Core skills library for Claude Code: TDD, debugging, collaboration patterns, and proven techniques