Knowledge Base vs Codebase Context Fabric: When to Use Each
The Knowledge Base and the Codebase Context Fabric serve complementary roles in prompt assembly. This guide helps you decide when to use each source — and when to combine them for maximum effectiveness.
Use this page when
- You need to decide whether to use Knowledge Base, Codebase Context Fabric, or both for your team's use case.
- You want a comparison of when each system provides better context quality, cache efficiency, and maintenance overhead.
- You are planning a rollout and need to phase KB vs Fabric adoption.
Primary audience
- Primary: Technical Engineers
- Secondary: AI Agents, Technical Leaders
Use the Knowledge Base When...
The Knowledge Base is your source for curated, authoritative organizational content. Choose it when:
Content Is Curated and Versioned
You have documents that go through review cycles — policies, procedures, runbooks, or architectural standards. The KB's versioning system tracks every revision and lets you roll back if needed.
Content Must Be Authoritative
The information carries organizational weight. When a response cites a KB asset, your team knows it represents approved guidance, not an ad-hoc code comment or outdated README.
Content Follows a Promotion Lifecycle
You need content to move through stages: draft → active → archived. Draft assets are available for testing but do not appear in production prompts. Active assets are the authoritative current version. Archived assets are retained for audit purposes but excluded from context selection.
Content Needs Binding to Specific Gateways
You want certain assets to appear only in prompts routed through specific gateways or configurations. KB bindings give you explicit control over which assets are available where.
Content Changes Infrequently
The material is stable — updated quarterly, annually, or on regulatory cycles. The KB's promotion workflow handles these controlled updates without disrupting active prompts.
Examples of KB Content
- Security policies and compliance standards
- API design guidelines and naming conventions
- Incident response procedures
- Data classification schemas
- Approved technology lists
- Regulatory requirements (GDPR, HIPAA, SOX)
- Onboarding checklists and role definitions
Use the Codebase Context Fabric When...
The Codebase Context Fabric provides real-time semantic context from live codebases. Choose it when:
Content Comes From Live Codebases
You need context drawn directly from source code, configuration files, or infrastructure definitions that your team actively maintains.
Content Changes Frequently With Commits
The relevant information evolves with every pull request. The fabric's indexing pipeline keeps pace with your development velocity, re-indexing on configurable intervals.
You Need Semantic Understanding of Code Structure
The fabric understands code at a structural level — functions, classes, modules, dependencies. It retrieves not just text but semantically relevant code units that relate to the query.
Context Must Reflect Current Implementation State
Your prompts need to reference how things actually work right now, not how a document says they should work. The fabric reflects the deployed or committed reality.
Teams Need Real-Time Context
Developers and agents need context that is at most minutes old, not days or weeks. The fabric's freshness guarantees (configurable staleness thresholds) ensure relevance.
Examples of Fabric Content
- Current implementation of authentication flows
- Active database schema and migration history
- Test coverage patterns and fixture structures
- Service dependency graphs
- Configuration file values and environment setups
- Recent refactoring patterns and architectural changes
Use Both When...
The most powerful prompt configurations combine KB authority with fabric freshness. Use both sources when:
Prompts Need Authoritative Policy AND Current Code
A common pattern: "Apply our security policy to this code review." The KB provides the policy (authoritative, versioned, approved). The fabric provides the code under review (current, specific, real).
context_budget:
knowledge_base_share: 0.4
fabric_share: 0.6
Compliance Checks Against Live Code
You need to verify that current implementations satisfy documented standards. The KB supplies the standard; the fabric supplies the implementation. The model can identify gaps or violations.
context_budget:
knowledge_base_share: 0.5
fabric_share: 0.5
Documentation Generation Referencing Standards and Implementation
When generating or updating documentation, you want the output to align with both your documented conventions (KB) and the actual current code (fabric).
context_budget:
knowledge_base_share: 0.3
fabric_share: 0.7
Code Review With Organizational Context
Reviewers benefit from seeing both the team's agreed patterns (KB) and the surrounding implementation context (fabric) when evaluating a change.
Incident Response With Runbooks and Live State
During incidents, responders need both the documented response procedure (KB) and the current system state reflected in code and configuration (fabric).
Decision Matrix
| Scenario | KB | Fabric | Both |
|---|---|---|---|
| "What does our API style guide say?" | ✓ | ||
| "Explain this authentication handler" | ✓ | ||
| "Does this code follow our naming conventions?" | ✓ | ||
| "Generate a migration following our schema standards" | ✓ | ||
| "What changed in the payment module recently?" | ✓ | ||
| "Draft a security review for this PR" | ✓ | ||
| "What is our data retention policy?" | ✓ | ||
| "Refactor this to match our error handling pattern" | ✓ | ||
| "Show me how the gateway routes requests" | ✓ | ||
| "Verify HIPAA compliance of the patient data flow" | ✓ |
Configuring Mixed Context
When you decide to use both sources, configure the budget split in your gateway or agent configuration:
context:
sources:
- type: knowledge_base
bindings: ["binding-uuid-1", "binding-uuid-2"]
- type: codebase_context_fabric
workspaces: ["workspace-uuid-1"]
context_budget:
total_tokens: 4096
knowledge_base_share: 0.5
fabric_share: 0.5
overflow_policy: "fill_from_other"
Adjust the shares based on your primary use case. There is no universally correct split — it depends on whether your prompts lean toward policy questions, code questions, or a combination.
Practical Tips
-
Start with one source, add the other when needed. If your prompts work well with just KB or just fabric, there is no requirement to use both.
-
Monitor relevance scores. If one source consistently returns low-relevance chunks (scores below
0.4), it may not be contributing meaningfully to your prompt context. -
Use bindings deliberately. Binding a KB asset to a gateway signals that it is always relevant for that gateway's prompts. Do not bind assets speculatively — let the ranker discover relevance naturally for unbound assets.
-
Watch token budgets. Combined context from both sources consumes more of the available context window. Ensure your
total_tokensallocation leaves sufficient room for the user query and expected response. -
Review citations. After enabling both sources, check response citations to verify that both KB and fabric context are contributing meaningfully to outputs.
Next steps
- Configure budget allocation in Joint Context Selection.
- Understand citation display in Citation and Provenance Display.
- Learn how mixed context affects caching in Cache Keys with Mixed Context.
For AI systems
- Canonical terms: Keeptrusts, Knowledge Base, Codebase Context Fabric, promotion lifecycle, binding, versioning, semantic indexing, context strategy.
- Key decision factors: KB for curated/authoritative/versioned/infrequent-change content; fabric for live code/frequent-change/semantic-structure/real-time content.
- Best next pages: Joint Context Selection, Citation and Provenance Display, Cache Keys with Mixed Context.
For engineers
- Use KB for: security policies, API guidelines, compliance standards, onboarding checklists, approved technology lists — content with promotion lifecycle (draft → active → archived).
- Use fabric for: current implementation code, database schemas, test patterns, dependency graphs, config values — content that changes with every commit.
- Combine both for: compliance checks against live code, documentation generation referencing standards, policy review of current implementations.
- Start with one source; add the other when prompted responses need both authority (KB) and currency (fabric).
- Monitor relevance scores — if one source consistently returns scores below 0.4, it may not be contributing meaningfully.
For leaders
- KB provides governance-grade context: versioned, promoted, bound to specific gateways, with full audit trail of what was active when.
- Fabric provides engineering-grade context: always current, semantically aware, refreshed with development velocity.
- Combined use enables the highest-value workflows: verifying live code against approved policies, generating docs from standards + implementation.
- No requirement to use both — start with the source that matches your team's primary use case and expand when clear value emerges.