@ai-cortex/daemon
v1.0.1
Published
Transparent API proxy that makes LLM coding agents smarter
Downloads
1,762
Readme
Cortex
Make your AI coding agents smarter — automatically.
Cortex is a local proxy daemon that sits between your coding agent (Claude Code, Cursor, Aider) and the API provider. It watches what you're working on, and when it recognizes a situation it knows about, it injects relevant knowledge directly into the conversation — tips, patterns, debugging guides, fixes — without you lifting a finger.
Your agent gets better answers. You don't change how you work.
What Cortex Does
- Saves tokens — prunes verbose tool outputs that waste your context window
- Injects knowledge — matches conversations against 160+ brain entries and injects the right one at the right time
- Tracks agents — understands main sessions, subagents, and teammates across your workspace
- Shows live status — optional Claude Code statusline with pipeline phase, context usage, and injection count
- Stays out of the way — never modifies API responses, never breaks streaming, zero config changes to your agent
Install
npm install -g @ai-cortex/daemonSetup
cortex setupThe setup wizard walks you through everything: config, model download, Claude Code integration, and API routing. One command, done.
If you use Claude Code, Cortex automatically configures routing and the statusline. Your original settings are backed up and restored when Cortex stops — even on crashes.
Start & Stop
cortex start -d # Start as background daemon
cortex stop # Stop and restore original Claude settings
cortex status # Check if runningOr run in foreground to see live pipeline output:
cortex startBrain — Your Knowledge Library
The brain is a directory of Markdown files. Each file is a piece of knowledge — a solution, pattern, debugging guide, or best practice — that Cortex can inject when it detects a matching situation.
---
id: node-esm-import
title: "Node.js ESM import resolution"
language: javascript
error_types: [ERR_MODULE_NOT_FOUND, "Cannot find module"]
tags: [debugging, imports, node, esm]
---
When you see ERR_MODULE_NOT_FOUND in an ESM project...Cortex ships with 160+ entries. Add your own by dropping .md files into your brain directory.
cortex brain list # See all entries
cortex brain search <query> # Search by keyword
cortex brain import <dir> # Import from a directory
cortex brain sources # Manage knowledge sourcesBrain entries can also come from external sources: cheat.sh, tldr pages, and DevDocs.
Claude Code Statusline
Cortex appends a status line below your existing Claude Code statusline (it never replaces what you already have):
◆ Cortex Snagged a request [████████░░] 72% (12.4k saved) 3 injectedConfigure which elements to show with cortex config edit in the Statusline panel. If you want to remove Cortex and go back to your original statusline, toggle "Revert to Original Statusline" in the same panel.
CLI Reference
cortex start [-d] [--port N] # Start daemon
cortex stop # Stop daemon
cortex status # Show status
cortex setup # Interactive setup wizard
cortex config edit # TUI config editor
cortex config show # Print current config
cortex brain <subcommand> # list | search | stats | import | sources
cortex features list # Show feature toggles
cortex features enable <name> # Enable a feature
cortex features disable <name> # Disable a feature
cortex logs [-n N] [--follow] # View or stream logs
cortex agents topology # Show agent treeConfiguration
Config lives at ~/.cortex/config.yaml. Edit with cortex config edit (interactive) or cortex config set <key> <value>.
Key settings:
| Setting | Default | What it does |
|---------|---------|-------------|
| proxyPort | 9090 | Port Cortex listens on |
| targetBaseUrl | https://api.anthropic.com | Upstream API endpoint |
| dashboardPort | 9091 | Management API / dashboard port |
| brainDir | ./brain/entries | Where brain entries live |
| injectionConfidenceThreshold | 0.9 | Min match score to inject (0–1) |
Environment overrides: CORTEX_PORT, CORTEX_TARGET_URL, CORTEX_DASHBOARD_PORT.
Dashboard
open http://localhost:9091Web dashboard with live pipeline stats, brain summary, agent topology, and SSE log streams.
Requirements
- Node.js 20+
- First run downloads local AI models (~160MB total) to
~/.cortex/models/
How It Handles Your Settings
Cortex modifies ~/.claude/settings.json to route API traffic and register its statusline. It always backs up your original settings first:
- API routing — If you had a custom
ANTHROPIC_BASE_URL, it's saved and restored on stop. If you had none (the default), it's cleanly removed — your settings go back to exactly how they were. - Statusline — If you had an existing statusline, Cortex appends below it rather than replacing. On disable, your original is restored.
- Crash safety — Backups are restored on graceful stop, SIGTERM, SIGINT, and process exit. A hardcoded fallback to
https://api.anthropic.comis used as a last resort if backup data is corrupted.
License
BSL-1.1 (Business Source License)
