Watch Mode

Real-time documentation updates as you code

PRO FEATURE

Watch Mode is the ultimate productivity booster for developers who value up-to-date documentation. CodeContext monitors your code changes in real-time and automatically updates your documentation as you work. No more context switching, no more forgetting to update docs.

Watch Mode Benefits

Real-Time Updates

Docs update as you save files

Zero Friction

No manual commands needed

Smart Detection

Only updates what changed

How Watch Mode Works

1

Start Watch Mode

Run CodeContext in watch mode to begin monitoring:

$ codecontext update --watch
2

File Monitoring

CodeContext watches your project files for changes, using efficient file system watchers that don't impact performance.

3

Smart Debouncing

Changes are intelligently batched to avoid excessive updates. Waits for you to finish typing before processing.

4

Automatic Updates

Documentation is regenerated and saved automatically. You'll see a notification when updates complete.

Watch Mode in Action

Terminal
$ codecontext update --watch
🔍 CodeContext Watch Mode
Watching for changes in: /Users/dev/my-project
Ignoring: node_modules, dist, *.test.js
Press Ctrl+C to stop watching
⚡ Change detected: src/api/users.ts
Waiting for changes to settle...
📝 Updating documentation...
• Analyzing changes
• Updating README.md
• Updating API.md
✅ Documentation updated successfully!
Time: 2.3s | Files: 2 updated
👀 Waiting for changes...

Watch Mode Configuration

Customize watch mode behavior to match your workflow:

{
  "watch": {
    "enabled": true,
    "debounce": 2000,           // Wait 2 seconds after last change
    "paths": [                  // Directories to watch
      "src/**",
      "lib/**",
      "api/**"
    ],
    "ignore": [                 // Patterns to ignore
      "node_modules/**",
      "dist/**",
      "*.test.{js,ts}",
      "*.spec.{js,ts}",
      "**/__tests__/**",
      ".git/**"
    ],
    "fileTypes": [              // File extensions to watch
      ".js", ".jsx",
      ".ts", ".tsx",
      ".py", ".java",
      ".go", ".rs"
    ],
    "updateTypes": {            // What to update
      "readme": true,
      "changelog": true,
      "api": true
    },
    "notifications": {
      "success": true,
      "errors": true,
      "sound": false
    }
  }
}

Performance Optimization

Efficient Watching

  • Uses native file system events
  • Minimal CPU and memory usage
  • Intelligent file filtering
  • Batches multiple changes

Smart Updates

  • Only updates affected docs
  • Caches unchanged content
  • Incremental processing
  • Parallel documentation generation

Advanced Watch Mode Features

Custom Triggers

Define custom events that trigger documentation updates:

watch.triggers: ["save", "test-pass", "commit"]

Selective Updates

Update only specific documentation based on file changes:

watch.rules: [{"pattern": "api/**", "update": ["api-docs"]}]

Team Sync

Broadcast updates to team members in real-time:

watch.broadcast: true

IDE Integration

Get notifications directly in your editor:

watch.ide: "vscode" | "intellij" | "sublime"

Perfect For

API Development

Keep API documentation in sync as you develop endpoints:

  • • Auto-update endpoint docs
  • • Reflect parameter changes
  • • Update response examples
  • • Track breaking changes

Library Development

Maintain accurate docs while building libraries:

  • • Update method signatures
  • • Reflect new features
  • • Keep examples current
  • • Track deprecations

Team Projects

Ensure documentation stays current across teams:

  • • Real-time doc updates
  • • No forgotten updates
  • • Consistent documentation
  • • Reduced review burden

Open Source

Keep community docs up-to-date:

  • • Auto-update contributor docs
  • • Maintain accurate setup guides
  • • Update feature lists
  • • Track project evolution

Watch Mode Tips

  • Use .magicignore: Create a .magicignore file for project-specific ignore patterns
  • Adjust debounce time: Increase for large projects, decrease for quick feedback
  • Use focused watching: Only watch directories you're actively working on
  • Combine with git hooks: Use watch mode locally, hooks for CI/CD
  • Monitor the logs: Check terminal output for any issues or warnings

Troubleshooting

High CPU usage

Increase debounce time or reduce watched paths. Check for recursive symlinks.

Updates not triggering

Check ignore patterns and ensure files are in watched paths. Verify file permissions.

Too many updates

Increase debounce time or use more specific file patterns. Consider selective updates.

Related Topics

);