Shared Context
Origin-keyed engineering context. Each file-backed record uses its configured
repository or shared store. The repository's Git origin identifies shared context.
Markdown access policy
Use mq-query skill for every agent operation that searches, reads, filters,
selects, lists, summarises, or validates local Markdown content. Load its matching
task reference and the required upstream reference first. Use explicit input and
output formats.
Do not use grep, find, rg, fd, ls, shell globs, or ad hoc Markdown
parsers to locate or inspect local Markdown. A known path may be passed to
mq, but mq remains the content-reading interface. This policy applies to
alignment files, ingested files, indexes, and local ticket files. It does not
change the implementation of the shared-context CLI itself.
Step 0: resolve the root. Always.
Resolve the installed shared-context skill directory (the directory containing
this SKILL.md) and set SHARED_CONTEXT_SKILL_ROOT to its absolute path.
The CLI is inside the skill, not the repository. Run it by absolute path from
the project root:
"$SHARED_CONTEXT_SKILL_ROOT/scripts/shared-context/cli.ts"
Its shebang starts Bun through mise and installs the CLI's own dependencies on first run. You MUST NOT prefix the call with Bun's runner (or any other runner) because that skips the entry point's shebang.
report is the default. Use
"$SHARED_CONTEXT_SKILL_ROOT/scripts/shared-context/cli.ts" resolve <kind> ... --json
to resolve a record. Use
"$SHARED_CONTEXT_SKILL_ROOT/scripts/shared-context/cli.ts" root only when a
script needs the alignment root.
mode: shared | repository | mixed
root: <alignment root>
alignment: shared | repository
tickets: <tracker adapter or local store>
initiatives: shared | repository
workflows: shared | repository
evidence: workflows -> <store>, or <store>
sources: alignment -> <store>, or <store>
origin: <git origin>
slug: <origin-derived directory name>
Content contracts
Read Contract definitions and upgrades before interpreting versioned configuration or converting content. New resolution JSON declares shared-context-resolution/v1; all existing location fields retain their meanings. Route v2 and layout v1 remain read-only compatible. Use the absolute installed CLI for explicit content operations:
"$SHARED_CONTEXT_SKILL_ROOT/scripts/shared-context/cli.ts" upgrade --artifacts /absolute/selected-paths.json
"$SHARED_CONTEXT_SKILL_ROOT/scripts/shared-context/cli.ts" configure-route --kind sources --store repository
The selection file is a JSON array of mutable route/layout paths. Bulk conversion reports each outcome and exits nonzero for partial success. Configuration updates preserve authored text and pin inherited child stores before changing their parent. Neither command copies stored files. Use storage migration separately. Preserve immutable history and external formats. Never convert source copies through the configuration adapter.
Recovery boundary
A typed resolve workflow result identifies a location, not an existing workflow, valid receipt chain, running phase, or completed implementation. Resolve and inspect existing records without creating directories during read-only recovery. Evidence has its own route and publication rules; evidence runs are not phase receipts and do not establish workflow progress. The worktree skill owns recovery decisions and append-only workflow provenance. Never run init or migrate as an implied recovery step; both require an explicit request naming that storage operation.
Router
| You want to | Read |
|---|---|
| See or change where context is stored | references/storage.md |
| Know where a file goes and what it is named | references/layout.md |
| Pull an external source into context | references/ingest.md |
| Fetch one specific source type | references/sources.md |
| Make a write visible to other agents | references/publishing.md |
Shared-context writes and links
Run the shared-context CLI before you choose a path or link, using the absolute skill-relative path established in Step 0:
"$SHARED_CONTEXT_SKILL_ROOT/scripts/shared-context/cli.ts"
Use resolve <kind> for the record you will read or write. Its structured
result names the adapter, store, root, path, stable reference, and publication
rule. Do not infer a store from mode or join paths under root.
For an external ticket, use the ticket skill. shared-context resolves only
file-backed records. A file-backed record can use the repository or the
origin-keyed shared store.
Write rule
When a record resolves to store: shared, write to its resolved path. Read
references/publishing.md and publish when the store has a usable git remote.
A non-git store is valid local-only storage. Keep the write and report that it
is local.
Link rule
Use a public URL only when the shared-context store is a public git repository and the destination has the same public access boundary. Build the URL only after you commit and push the file. Include the context slug in the path.
For a shared-context store with no git repository, no usable remote, or a private GitHub repository whose destination is not related to the shared-context store, write the reference as:
SharedContext/<path relative to the shared-context root>
If you cannot determine whether the shared-context store and the destination have the same access boundary, ask the user before you choose a URL or path. Never use a public URL for a private or uncertain boundary.
For a file in the repository being changed, use a path relative to that repository root.
CLI usage errors
If a CLI command fails because its arguments or usage are incorrect, read its
--help output, correct the command, and try again. Do not report the error as
a blocker before checking the documented usage. For other non-zero exit
statuses, follow Rule 7.
Rules that override convenience
- You MUST Always use the absolute path to the CLI entry point. Do not
cdto the skill directory. - You MUST NOT run
initormigratefrom an implied request. Both mutate storage. Run either only when the user names that operation. - You MUST resolve each record kind before choosing a path. Do not infer a store from the report mode or mix a resolved path with a different root.
- You MUST use
shared-context resolveto get a typed target. Do not join root-relative path segments in a skill. For source ingestion, useresolve source --ticket <ID> --source <SOURCE>orresolve source --library --source <SOURCE>. - Run
shared-context index <dir> --kind source --source <SOURCE>after you add or remove a file in a source directory. Include--ticket <ID>or--libraryto select the source record. - For each record resolved to
store: shared, you MUST readreferences/publishing.mdafter the write. Publish when that store has a usable git remote. A non-git store is valid local-only storage. - You MUST NOT overwrite a file that holds hand-written work. See the
authored-content guard in
references/layout.md. - You MUST stop and report a non-zero exit status from
shared-context, except for an incorrect-arguments or usage error. For that error, readshared-context --help, correct the command, and try again. Do not retry other failures silently. This rule coversshared-contextonly. An ordinary shell probe such aslsexits non-zero for an absent path, which is an answer, not a failure. - If there exists
<shared-agent-context />block in the system prompt, then you don't need to run the shared-context cli to get a report.
Collection roots and layout
Use resolve tracker --json, resolve tickets --json, resolve initiatives --json,
or resolve sources --json to get exact collection directories. Do not append
tracker or sources to a resolved store. Optional
docs/agents/context-layout.toml in the active alignment root overrides tracker
and source base directories; store routes remain independent. Local tracker
frontmatter issue-root and initiative-root override their collection paths.
See references/layout.md for schema, defaults, and validation rules.