This document defines the contract between brief --agent and brief context. It is the authoritative reference for P2 (brief context implementation) and for anyone extending or calling these interfaces.
Both --agent and brief context are constitutions — authoritative context packs — but at different scopes:
| Command | Scope | Nature |
|---|---|---|
brief --agent |
User-scope | Who the agent is and how it should behave across all sessions and environments |
brief context |
Env-scope | What the agent needs to know about this specific repo, folder, or environment |
This scope distinction is the organizing principle for every boundary decision in this document.
brief --agent contractScope: User-level. Valid across all sessions, all repos, all environments.
What it owns:
session_guide — stable tool onboarding (how to use brief)Stability: Stable API. Callers (~/.claude/CLAUDE.md, scripts, agent runtimes) may depend on this shape without version guards.
JSON shape (current, stable):
{
"preferences": [{ "title": "...", "content": "..." }],
"session_guide": "..."
}
What it never contains:
brief context contractScope: Env-level. Scoped to a specific repo, folder, or environment.
What it owns:
--cwd (from the crawl store)Stability: Evolving surface. brief context is where the context lifecycle matures. --agent is the stable anchor.
JSON shape (contract for P2 to implement against):
{
"scope": "<resolved path or env identifier>",
"memories": [],
"sources": [],
"preferences": []
}
scope — the resolved path or env identifier this pack is scoped tomemories — relevant entries (non-preference categories) from the entries store for this envsources — indexed source chunks from the crawl store for this envpreferences — preference entries naturally surfaced by the env-scoped search; not the full --agent set; may be emptyPreferences in context: Preferences appear in brief context as a result of natural function — they are entries like any other, and if they are relevant to the env scope, they surface. This is not an opt-in flag. It is different from the user-global preference set returned by --agent.
Empty sections (memories, sources, preferences) are always present as empty arrays, never omitted.
These are prohibitions, not suggestions:
--agent never includes source evidence or env-specific memories.brief context never replicates the full --agent preference set; only preferences naturally relevant to this environment appear.memories and sources remain separate keys.session_guide stays in --agent until its long-term placement is resolved in a future scope. It does not belong in brief context responses.| Question | Resolution |
|---|---|
What remains in --agent? |
User-scope constitution: behavioral preferences and session_guide. Stable. Valid for any session, any repo. |
What does brief context own? |
Env-scope constitution: memories, source evidence, and env-relevant preferences for the current repo/folder/env. |
Can context include preferences? |
Yes — as a natural function, not an opt-in flag. Preference entries surface when they are relevant to the env scope, just as memories do. |
Where does session_guide belong long-term? |
Deferred. Currently lives in --agent. Long-term placement is out of scope for P1. |
Is --agent stable API or eventually a compatibility alias? |
Stable now. Post-maturation (after preference maturation primitives exist), --agent may become a shortcut to its equivalent context call. The binding form is not decided here. |
brief --agent is implemented in internal/cli/onboard.go (runOnboarding, agentOnboardPayload). Do not modify its shape.brief context is a new command: internal/cli/context.go, registered under the memory group in internal/cli/root.go.scope field resolves to the path passed via --cwd (default: current working directory).memories and preferences both come from the entries store (internal/db/entries.go, SearchEntries) — filtered by category to separate them.sources comes from the crawl store (internal/db/crawl.go, SearchChunks) scoped to the nearest indexed source containing --cwd.--cwd → source path mapping via ListSources() using longest-prefix matching.brief context proposal), #48 (unified search scope), #39.