npx claudepluginhub crombieman/undercurrent-cortexCompounding intelligence system for Claude Code - session management, health tracking, context injection, and adaptive learning
A Claude Code plugin that works like a living organism — 13 biological systems that learn, adapt, protect, and evolve across your coding sessions.
Imagine a second brain sitting alongside Claude that:
now() in a Postgres migration)All of this happens through bash hooks that fire at specific moments in your Claude Code session.
gh) — optional, but needed for the Sensory system (CI/PR checks)claude plugins marketplace add Undercurrent-Studio/undercurrent-cortex
claude plugins install cortex@undercurrent-studio
Restart Claude Code. On first session start, the plugin bootstraps all hook events into your global ~/.claude/settings.json automatically.
Cortex uses a two-tier hook dispatch system due to a known bug where plugin hooks.json command hooks are unreliable for most events:
| Tier | Location | Events | Why |
|---|---|---|---|
| hooks.json | Plugin manifest | SessionStart only | Proven working; serves as the bootstrap's lifeline |
| Global settings.json | ~/.claude/settings.json | PreToolUse, PostToolUse, PreCompact, Stop, SessionEnd, UserPromptSubmit | Bootstrapped on every session start; the only location proven to reliably fire hooks |
The bootstrap-hooks.sh script runs on every SessionStart and:
~/.claude/settings.json (idempotent — skips if already correct)settings.local.jsonAll bootstrapped entries are tagged with "_cortex_bootstrap": true for identification.
Cortex supports three hook profiles that control which systems are active:
| Profile | Events Injected | Use Case |
|---|---|---|
standard (default) | All 6 events | Full organism — recommended for most projects |
minimal | PreToolUse, PostToolUse, SessionEnd only | Lightweight — enforcement + state tracking only |
strict | All 6 events + proposals auto-surfaced | Full organism with more aggressive adaptation |
Set via CORTEX_PROFILE env var or .claude/cortex/profile.local file in your project.
Think of the plugin as a body. Each system has a specific job, and they work together.
These fire every session and handle the basics.
1. Nervous System — State Tracking Every edit, commit, and tool call gets counted in a session-scoped state file. The nervous system is how the organism "feels" what's happening — it's the raw sensory data that other systems read.
Where: post-dispatch.sh (universal counter), post-edit-dispatch.sh, post-bash-dispatch.sh
State: edits_since_last_commit, commits_count, tool_calls_count, [files_modified] section
2. Immune System — Dangerous Operation Blocking Before certain tools execute, the immune system checks if the operation is safe. If not, it blocks it with an explanation.
Examples of what gets blocked:
now() or CURRENT_DATE in a migration file (PostgreSQL requires IMMUTABLE functions in partial indexes)Where: pre-dispatch.sh routes to migration-linter.sh + plan-file-guard.sh + tdd-guard.sh