Watch Daemon
Background process that keeps your context warm without any manual commands.
Starting the Watcher
$contxt watch# Foreground mode (Ctrl+C to stop)$contxt watch --daemon# Background daemon$contxt watch:stop# Stop the daemon$contxt watch:status# Check if running
Automatic Setup with contxt init
You don't need to start the watcher manually. contxt init sets everything up automatically at the end of project initialization:
- ✓Watch daemon started
The background daemon is launched immediately so passive capture begins the moment your project is created.
- ✓Auto-sync enabled
The project config is written with
autoSync: true. After every 30-second file flush the daemon automatically callscontxt sync push— no manual push needed. - ✓MCP config written
Both
.mcp.json(Claude Code) and.cursor/mcp.jsonare created so your AI editors can immediately access the Contxt MCP server. - ✓Git hooks installed
post-commitandpre-pushhooks are added to.git/hooks/to sync context on every commit and push. - ✓Claude Code hook registered
A
UserPromptSubmithook is added to~/.claude/settings.jsonso Claude silently loads project context at the start of every session.
contxt init ✓ Project "my-app" created ✓ Git hooks installed ✓ MCP config written (.mcp.json, .cursor/mcp.json) ✓ Claude Code hook registered ✓ Watch daemon started (auto-sync enabled)
If the daemon is ever stopped, restart it with contxt watch --daemon. Use contxt watch:status to confirm it's running.
What It Monitors
Updates context.files with a 30-second debounce to avoid noise during active editing sessions. Respects .contxtignore and .gitignore.
Automatically runs contxt rules sync whenever the file is saved. Edit the markdown file in your IDE and memory updates within seconds.
Detects branch switches and updates the active memory branch to match. Complements the post-checkout hook for teams who prefer not to install git hooks.
Tracks work sessions with a 30-minute inactivity timeout. Session data informs context summaries and the pre-push hook report.
When a file containing Contxt annotations is modified, runs an incremental re-scan of just that file — not the entire project. New or changed tags become drafts immediately.
Foreground Output
When running in foreground mode, the watcher prints a live activity log with timestamps and event types:
contxt watch — monitoring my-app (main)14:32filessrc/api/billing.ts, src/lib/stripe.ts14:35scan+DECISION "Use Stripe Connect" (draft)14:52contextsession active — 20 min, 4 files15:22sessionended — 50 min, 6 files touched15:22rulesrules.md changed — syncing 2 updates
Daemon Mode
When started with --daemon, the watcher detaches from your terminal and runs as a background process. Its state is tracked via two files:
.contxt/.watch.pidContains the process ID of the running daemon. Deleted automatically when the daemon stops cleanly.
.contxt/watch.logRolling log of all watcher events. Rotated at 5MB. Review with
tail -f .contxt/watch.log.
Resource Usage
The watcher is designed to be invisible in the background:
- Memory: under 50MB RAM
- Polling: native OS file events via chokidar (1s fallback)
- Ignored automatically:
node_modules,dist,build, and.contxtignorepatterns