Codebase Bindings

Link decisions and patterns to code paths using glob patterns. When AI agents edit files, bound context surfaces automatically — no manual prompting and no loading the entire knowledge base.

Why bindings?

Without bindings, you'd need to remind your AI about each relevant decision in every prompt. With bindings, touching the file is enough.

Creating bindings

You: "Bind the SQLAlchemy decision to the data layer, the JWT auth
      decision to the auth module, and the error handling pattern to
      all route files"

AI:  Bindings created:
     Decision #24 (SQLAlchemy ORM) → src/db/**/*.py
     Decision #7  (JWT auth)       → src/auth/**/*.py
     Pattern #5  (Error handling)  → src/api/routes/**/*.py

Context follows the code

You: "Add a new route in src/api/routes/medications.py that
      queries src/db/repositories/medications.py"

AI:  Checking context for files being edited...

     src/api/routes/medications.py is bound to:
     ✓ Pattern #5: Structured error handling
     ✓ Decision #7: JWT auth required on all routes
     ✓ Decision #14: Rate limiting at 1000 req/min

     src/db/repositories/medications.py is bound to:
     ✓ Decision #24: Use SQLAlchemy for all DB operations
     ✓ Decision #23: PostgreSQL is the primary database

     Implementing with SQLAlchemy queries, JWT middleware,
     rate limiting, and structured error responses...

Binding management

Bindings can become stale when files are moved or deleted. Use verify_bindings and get_stale_bindings to audit, and suggest_bindings to automatically propose new bindings based on pattern analysis.

MCP tools

  • bind_code_to_item — create a binding (supports glob patterns)
  • get_bindings_for_item — list all bindings for a decision or pattern
  • get_context_for_files — retrieve all context bound to a set of files
  • verify_bindings — check whether bound paths still exist
  • get_stale_bindings — list bindings with non-existent paths
  • suggest_bindings — propose bindings based on analysis
  • unbind_code_from_item — remove a binding