Fabriq
Agents

Injecting Context: What Your Agent Knows

Give your agent the project knowledge it needs — architecture, conventions, and relevant docs.

An agent is only as good as its context. Without it, the agent has to discover everything by reading your codebase from scratch — and it might miss important details.

Context injection is how you tell the agent what it needs to know before it starts working.

What context injection is

When you inject context, Fabriq sends project knowledge to the agent via ACP. This knowledge includes:

  • runtime-context.md — a document you maintain with project structure, architecture decisions, coding conventions, and links to relevant docs
  • Cognitive envelope — structured knowledge extracted by CDR (behaviors, business rules, state machines) from your codebase

The agent receives this before starting a feature and references it throughout.

What goes in runtime-context.md

Create a context/runtime-context.md file in your feature (or at the workspace level). It should contain:

<!-- KNOWLEDGE_BOUNDARY: dimension=workspace, scope=my-project,
     writable=features/*, forbidden=.dapei/ -->

# Runtime Context

## Project Structure
- Monorepo with `packages/` and `apps/` directories
- Shared UI library in `packages/ui/`
- API server in `apps/server/`

## Architecture Decisions
- Uses React 19 with Server Components (RSC)
- Styling via Tailwind v4 CSS, tokens in `packages/ui/src/tokens/`
- API communication via tRPC
- Auth via NextAuth.js with GitHub provider

## Coding Conventions
- Components: default exports, PascalCase filenames
- Utilities: named exports, camelCase filenames
- Tests: co-located with source, `*.test.tsx`
- CSS: utility classes preferred over custom CSS

## Relevant Docs
- Component API: `docs/03-business-design.md`
- Data model: `docs/04-technical-design.md`

The KNOWLEDGE_BOUNDARY header is crucial — it tells the agent which dimension it's operating in, what scope it has, and what paths are forbidden.

How to inject context

  1. Open the Feature Workbench
  2. In the Agent panel (right sidebar), click Inject Context
  3. Select the context sources to include:
    • ✅ Workspace runtime-context.md
    • ✅ Feature runtime-context.md
    • ✅ CDR cognitive index (if available)
    • ✅ Specific docs you want the agent to reference
  4. Click Send

Fabriq packages the selected context and sends it to the agent as a structured message.

When to re-inject

SituationAction
Before creating a featureInject workspace context so the agent starts informed
After updating architecture docsRe-inject so the agent has the latest decisions
When agent seems confusedRe-inject with clearer, more specific context
Starting a complex featureInject with extra focus on the relevant area
After a CDR scanInject cognitive index so the agent can query it

The Knowledge Boundary header

The KNOWLEDGE_BOUNDARY header is an HTML comment embedded in markdown files that defines the runtime contract between the agent and the workspace:

<!-- KNOWLEDGE_BOUNDARY: dimension=workspace, scope=my-project,
     writable=features/*, forbidden=.dapei/ -->
FieldWhat it defines
dimensionWhich surface this document belongs to (workspace or feature)
scopeThe project scope
writableGlob patterns for paths the agent can write to
forbiddenGlob patterns for paths the agent must never touch

If the agent attempts to write to a forbidden path, the engine blocks the action at the IPC layer — before it reaches disk.

Pro tips

  • Write concise context docs: Agents handle focused context better than a dump of everything you know. Keep runtime-context.md to 1-2 pages.
  • Keep runtime-context.md updated: When architecture decisions change, update the context doc. Stale context is worse than no context.
  • Use the cognitive index: If you've run CDR, the cognitive index is available for injection. It's structured, sourced, and validated — the best possible context for an agent.
  • Inject early: The most common reason for agent mistakes is missing context. Inject before the feature starts, not after the agent goes off track.
  • Feature-level context overrides: If a feature needs specific context that differs from the workspace default, add it to the feature's context/runtime-context.md.

Next steps

Edit on GitHub

Last updated on

On this page