Skip to content

Context Integration

Generic branch and stack context lives in the standalone context CLI and MCP server. The dotfiles repo no longer embeds that logic in dot; it installs the tool, stows shell completions, and keeps the OpenCode plugins that turn the JSON payloads into prompt XML.

dot init installs the context-git AUR package from .dot-public-packages. That package provides the context binary on PATH. After init, verify in any git checkout:

Terminal window
context git --json | head
context stack --json | head

Shell completions for context are stowed from this repo. Regenerate them after upgrading the binary with context completions bash|fish|zsh, then dot stow. See Shell Setup.

Use the commands directly when scripting or debugging agent context:

Terminal window
context git # human-readable branch context
context git --json # structured payload for tools and plugins
context stack # human-readable tech-stack summary
context stack --json # structured stack payload
context help git # command help (also exposed as an MCP resource)

NO_COLOR disables ANSI colour in TTY-aware output. See Environment Variables.

Repository context tools are provided by the standalone context MCP server:

Terminal window
context mcp

Typical tools (names from tools/list):

ToolPurpose
git_contextBranch context for the current repository
stack_contextTech-stack summary for a directory
command_helpHelp text for a context subcommand

Read-only resources include context://git, context://stack, and context://command/{name}. Wire the server in an agent harness with ["context", "mcp"] as the command. Full schemas and examples are on https://context.timmo.dev/mcp/.

Use notes mcp for the notes vault. Agent harnesses that need repository context and notes load both standalone stdio servers side by side.

The dotfiles repo keeps the OpenCode plugins that consume context JSON and render prompt blocks:

  • branch-context runs context git --json and injects <branch-context> XML for scoped slash commands (PR-inclusive branch context, or work-scope-only variants without the pull request). PR descriptions are capped at 4,000 characters; up to 20 comments and 20 reviews are included, with each body capped at 2,000 characters.
  • stack-context runs context stack --json and injects <stack-context> XML automatically on the first message of a session inside a git repository, and on demand for /inject-stack or /inject-context.

Plugin-specific command allowlists and injection rules stay in agents/.config/opencode/plugins/. For CLI flags, JSON payload fields, and MCP tool parameters, see https://context.timmo.dev.

The plugins render the structured JSON into tagged XML sections. Treat injected blocks as the primary source for branch and stack analysis; avoid re-running git/gh or re-scanning the tree unless the user asks for a fresh snapshot or the block reports collection failure.

SectionPurpose
context-metadataHow the snapshot was produced (context git --json) and when it was generated.
branch-metadataRepository identity, current branch, HEAD, default remote/branch, base ref, upstream, ahead/behind, and whether HEAD is on the default branch. Unresolved default-branch metadata is labelled (unresolved) rather than guessed.
statusCompact git status -sb summary.
work-scopeCurrent work scope in priority order: unstaged, staged, then branch-only changes. On the default branch, branch scope is skipped and recent commits are shown instead.
pull-requestPR metadata, description, comments, reviews, and checks (branch-focused commands only).
truncationsApplied output limits. Treat affected sections as partial.
warningsNon-fatal collection issues, fallbacks, or missing data.

work-scope reflects the producer’s workScope.state:

StateMeaning
collectedBranch-only commits, files, and diff stat are present.
not-applicableHEAD is on the default branch; branch scope is skipped and recent commits are shown.
unresolvedDefault branch could not be resolved; recent commits are shown with a reason.

Work-scope-only commands (for example scoped refactor helpers) call context git --json --no-pr and omit the pull-request section.

SectionPurpose
context-metadataHow the snapshot was produced (context stack --json), repository root, and files scanned.
languagesDetected languages with file counts and general locations.
ecosystemsPackage ecosystems from manifest files.
toolingPackage managers, linters, formatters, task runners, build tools, and test runners from lockfiles and configs.
frameworksFrameworks and libraries from declared dependencies.
truncationsScan or output limits that make a section partial.
warningsNon-fatal collection issues.

Automatic session injection runs at most once per session and only inside a git worktree with a non-empty detection result.

MCP refresh outside plugin-backed commands

Section titled “MCP refresh outside plugin-backed commands”

Plugin injection covers registered slash commands. For ad-hoc work (for example /commit scope checks or manual branch inspection), use the Context MCP server’s git_context tool with only the fields the task needs (diff, branchDiff, PR details, and so on). See Commit Gateway for the commit path.