← Agent workflows guides

How to manage context for agents

How-To Agent workflows Intermediate 1041006HOWTO-1041006

HOWTO-1041006Agent workflowsIntermediate

This guide shows you how to manage context for agents in a spec-driven development project without pasting a large architecture document into every request.

SpecDD manages context through local files and path-based resolution. The agent should work from the selected content root, inherit parent specs down to the target, include the nearest local spec, and use explicit references for outside context.

Short answer

Open the correct project root, keep specs close to the files or areas they describe, and prompt the specific work. Use parent specs for inherited context, same-basename specs for local file contracts, and References or Can read for outside context that should not become write authority.

When to use this guide

Use this guide when:

Steps

1. Open the selected content root

The selected content root is the project boundary used for / paths, spec indexing, and resolution. It is usually the repository or workspace root unless the project configures a different SpecDD root.

For a project named travel-planner, a minimal root looks like:

travel-planner/
  AGENTS.md
  .specdd/
    bootstrap.md
    bootstrap.project.md
  travel-planner.sdd

Start the agent from that root. Opening a nested folder can change how root specs and / paths are resolved.

2. Choose the nearest useful target

Context starts from the work target. The target might be:

For example:

Plan the Itinerary validation change.

That target is narrow enough for the agent to resolve the itinerary context instead of summarizing the whole repository.

3. Let parent specs provide inherited context

SpecDD inheritance is vertical. Parent specs apply down the target path.

travel-planner/
  travel-planner.sdd
  src/
    trips/
      trips.sdd
      itinerary.js
      itinerary.sdd

For itinerary work, the relevant context can include:

travel-planner.sdd
src/trips/trips.sdd
src/trips/itinerary.sdd

This gives the agent project-level rules, trip-area rules, and local itinerary rules without loading unrelated sibling areas.

4. Use same-basename specs for local files

Same-directory basename matching makes local context easy to find:

src/trips/itinerary.js
src/trips/itinerary.sdd

The .sdd file is the local spec for the matching source file. This works best when spec and source names align with the project’s naming conventions.

5. Use References for horizontal context

Sibling specs are not inherited automatically. If itinerary behavior needs destination search context, reference it:

References:
  ../destinations/destination-search.sdd

This makes the outside context explicit. It also keeps authority clear: references provide context, not permission to edit the referenced area.

6. Use Can read for read-only implementation context

If an agent may inspect files for context but should not change them, use Can read:

Can read:
  ../storage/trip-storage.sdd
  ../storage/trip-storage.js

This is useful when implementation depends on another module’s API or behavior but the current task should stay local.

7. Keep prompts focused

After context is in specs, the prompt can name the task:

Implement the open Itinerary validation task.

If the agent needs to verify its understanding first:

Explain the Itinerary spec.

Do not compensate for missing specs by adding more and more prompt context. Add durable context to the right spec and review it.

Context checklist

For a well-managed agent context, confirm:

Common mistakes

How to verify the result

Agent context is managed well when:

← Agent workflows guides