Branch Context logo

Branch Context

Organization
pydantic
branch-context

Branch-local durable PR state -- issue brief, decisions log, and session handoffs. Read the brief, decisions, and latest handoff at session start; append decisions as you work; write a handoff only on user request or explicit session turnover.

Overview

Publisherpydantic
Repositorypydantic-ai-harness
Skill namebranch-context
Stars
954
Forks
150
Bundled files
6
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 6 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by pydantic on GitHub. Read the source before you install it.

Installation

Install the Branch Context AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/pydantic/pydantic-ai-harness/tree/main/.agents/skills/branch-context
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/pydantic/pydantic-ai-harness.git /tmp/pydantic-ai-harness
mkdir -p .claude/skills
cp -r /tmp/pydantic-ai-harness/.agents/skills/branch-context .claude/skills/branch-context
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Branch Context in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Branch Context on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Branch Context is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Branch Context

This directory is the home for durable PR/branch state that outlives a single session. Three surfaces:

File / dirRoleLifetime
issue-brief.mdSynthesis of the issue(s) this branch addressesRewritten only when adopting or re-syncing a branch
pr-decisions.mdAppend-only log of non-obvious PR-shaping decisionsAppend forever; supersede, never edit
handoffs/ + handoffs-index.mdAppend-only session handoffs for the next agentNever overwrite a handoff file; index points at the latest

The instances (issue-brief.md, pr-decisions.md, handoffs-index.md, handoffs/) are per-branch and git-ignored. The scaffolding (this file, the scripts, the *.template.md files) is committed. Instantiate the instances from the templates, or via /adopt-pr when a PR already exists.

Session defaults

On start, before coding:

  1. Confirm the branch matches the brief's branch: field (git rev-parse --abbrev-ref HEAD).
  2. Read issue-brief.md, pr-decisions.md, and handoffs-index.md.
  3. Read the latest handoff -- the last entry in handoffs-index.md points at its file under handoffs/. That is what the previous session left for you. If the index has no entries, there is no handoff yet; start from the brief.
  4. If the brief is still the unfilled template, populate it first: run /adopt-pr when a PR already exists, or write it from the linked issue when starting fresh.

While working -- persist without being asked:

  • A non-obvious decision (picking path A over B, a plan deviation, an ambiguous thread resolution) goes into pr-decisions.md via append-pr-decision.sh in the same turn you make it, not "later".
  • Disk in this directory is the continuity channel, not chat history. Do not rely on the conversation surviving a context clear or a new session.
  • Do not write a handoff because the context "feels full" -- that misjudges and primes an early stop. Write a handoff only when the user asks, or when session turnover is already decided (the user is clearing, switching tools, or ending the sitting).

When to write each surface

issue-brief.md

Rewritten only when adopting a branch (/adopt-pr) or re-syncing after new issue activity. Do not freestyle-edit it mid-session.

pr-decisions.md

Append whenever you make a decision the issue did not already spell out:

bash
.claude/skills/branch-context/append-pr-decision.sh \
  --title "<short title>" \
  --decision "<one-line decision>" \
  --why "<one-line why>" \
  --source "<source url -- mandatory>" \
  [--iter N] [--supersedes "<earlier title>"]

Named flags are preferred (they resist arg-order mistakes). Positional order is title decision why source [iter] [supersedes] -- do not pass iter as the second argument.

Entry shape (the script writes this):

## YYYY-MM-DD · <short title> · iter <N or "-">
- Decision: <one line>
- Why: <one line>
- Source: <link -- mandatory>
- Supersedes: <earlier title, if applicable>

When the decision restates a modal claim (always / never / only if / must / unless), quote that clause verbatim instead of paraphrasing -- "always X unless Y" compressed to "always X" is a different instruction.

Handoffs

One handoff per session, newest last. Never overwrite another session's handoff.

bash
.claude/skills/branch-context/append-handoff.sh [--writer <name>] "<one-line summary>" [path-to-body.md]

--writer tags the index line with the skill that produced the handoff. If you omit the body path, the script writes a stub you must fill in via Write/Edit before stopping; prefer writing the full body first and passing its path. To revise a handoff you already wrote this session, edit the file in place rather than appending a second index entry.

Handoff body sections (required):

markdown
# Handoff · YYYY-MM-DD · <summary>

## Done
- ...

## Next
- ... (ordered; first item is what the next agent starts on)

## Commitments & constraints carried forward
- ... (verbatim; or "none")

## Key paths
- `path` -- why

## Open questions
- ... (or "none")

## Branch-context pointers
- Brief: issue-brief.md (still valid? yes/no)
- Decisions appended this session: <titles or "none">
- Related plan file (if any): <path>

Commitments & constraints is a required check, not an optional extra. Before writing the handoff, sweep the session for two things and quote them verbatim -- do not paraphrase, the modality is the payload:

  • Constraints the user stated that are not already in the brief's Constraints section. "Always X unless Y" and "always X" are different instructions, and a one-line paraphrase is where the qualifier gets dropped.
  • Promises you made and have not kept -- to the user ("I'll add the regression test next"), or on the record in a PR/review comment ("I'll file a follow-up issue", "I'll re-run this once CI clears"). A promise made to a reviewer and then dropped across a session boundary is the expensive kind: the next agent cannot know it exists, and the reviewer is still waiting.

A longer, accurate handoff beats a short lossy one. Do not compress this section to save space.

Session turnover

Write the handoff (and any unlogged decisions) when the user turns the session over. If the harness has a plan mode, capture the remaining work as a concrete plan (next steps, files, verification), persist the handoff, then exit plan mode so the fresh session inherits it. If the harness has no plan mode, persist the handoff and tell the user to start a new session in this worktree whose first action is to read handoffs-index.md and the latest handoff.

Scope boundary

  • Not for research notes or repro scripts -- those belong outside this directory.
  • Not for durable codebase facts that outlive the PR -- those belong in longer-lived project docs or memory. Rule of thumb: if removing the linked thread would make this PR's diff confusing, it is a decision; if the fact still helps after merge, it belongs elsewhere.

Helpers

bash
.claude/skills/branch-context/status.sh              # JSON: brief/decisions/handoffs state
.claude/skills/branch-context/append-pr-decision.sh ...
.claude/skills/branch-context/append-handoff.sh ...

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Branch Context AI skill do?

Branch-local durable PR state -- issue brief, decisions log, and session handoffs. Read the brief, decisions, and latest handoff at session start; append decisions as you work; write a handoff only on user request or explicit session turnover.

Why use Branch Context on TypingMind?

Because you install it once and use it with any model. Branch Context is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Branch Context in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/pydantic/pydantic-ai-harness/tree/main/.agents/skills/branch-context. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Branch Context?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Branch Context?

As many as you like. As long as a model supports skills, you can use Branch Context with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Branch Context AI skill free?

Yes. It is published on GitHub by pydantic under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇