Design#

How it works#

graftkit <args>                         launcher.main
  -> locate the root: --root, GRAFTKIT_ROOT, or the nearest graftkit.toml going up
  -> delegate to the version the root pins, unless this process already is it
       [cli] core = "X.Y.Z"   -> uvx --from graftkit==X.Y.Z graftkit <args>
       [cli] extension = "n"  -> uv run --project <root> --frozen graftkit <args>
       (GRAFTKIT_DELEGATED marks the child, so it never delegates again)
  -> run_here: Context.load(root)        the root, its settings, its extension, or why not
       -> build_app: the core commands, then the extension's
       -> cli-interview-kit App.main     flags, interview, --describe, consents, exit code

A broken graftkit.toml or extension never stops the core: Context records the problem, the core commands still run, and doctor reports it.

Where to run your agent#

graftkit is built around one repository at a time: its root pins the core, and its skills and commands are that repository’s. So an agent (Claude Code, Codex, pi, your own harness) starts in the repository it changes, and reaches the others through graftkit:

  • Start in the repository you change. The agent then loads exactly its skills, and its generated graftkit skill lists exactly its commands.

  • Find other repositories with graftkit org map --json (what each provides, and its commands) and their code with graftkit org search, within what the person can read.

  • Open another repository only when the task needs its code, read-only, for example with Claude Code’s --add-dir ../other.

  • Not in the folder that holds every clone. It is no root, so the agent gets no pinned core, no repository commands and no repository skills, and it sees every repository at once.

org clone and org sync refuse a folder inside a checkout or a root, so the clones are never nested in a repository; they live in a folder of their own, such as ~/code/<org>.

Modules#

The public API is graftkit and graftkit.testing; everything else lives in the private graftkit._core package and may change in any release.

launcher       find the root, run the pinned version, never twice
context        what the core knows before any command runs: root, extension, settings, GitHub, git
app            one App from the core commands and the extension's
commands/      declarations and rendering only, one module per command; _shared for what
               several declare alike (--json, a setting's question)
workflows/     what the commands do: take values, return reports, never print
conformance    the command standard, for the core and every extension
agent          the agent policy annotation
github         GitHub through gh: releases, archives, an organisation's repositories, code search
git            checkouts through git and gh: clones, fast-forwards, pull requests
readme         the README's For agents section, which the map shows
process        the one way git, gh and uv run, failing with the command, its message and a hint
extension      loading extensions from entry points; Extension.from_package
tomlfile       reading TOML files, and editing them in place with comments kept
config, settings, root, identity, patterns, models, errors
               graftkit.toml, the settings layers, the root, the names, the formats, the
               models' base, validation errors as one line
templates/     what init and extension new scaffold, as string.Template files
skills/        the skills engine
  catalog        a content release: shared skills, bundles, allow-list, vendors.lock
  resolve        sources -> exact files and a lock (network, no writes)
  install        plan and apply changes under the ownership rules
  lock           graftkit.lock
  links          one link per skill for each harness that needs it
  spec           the Agent Skills specification
  content        a skill's files: read, write, remove, and their content hash
  harness        each harness: where it reads skills, and whether it needs links
  generate       the generated graftkit skill, and reading its command table back
testing/       public test helpers and the pytest plugin

Decisions#

  • The command name, file names and variables derive from one constant (identity.CLI_NAME). The core names no organisation and no repository: those are settings (settings), so the same package serves every organisation.

  • One name per concept. “Config” is graftkit.toml (config.Config); the person’s values are settings (settings.SETTINGS_ENV, user_settings_path), even though the variable, GRAFTKIT_CONFIG, and the config command keep their names. --root PATH only picks the root; config --in-root writes the root’s [settings]. Repo is the root, an extension’s view of the repository it runs in; Repository is a repository on GitHub, which the org commands list. Repo stays, because it is public API and renaming it would break every extension.

  • Extensions are entry points in the graftkit.extensions group, loaded inside the repository’s own environment. An extension pins the core like any other dependency, in its uv.lock, so a repository’s commands and its core move together.

  • One mechanical standard for every command, the core’s included (conformance). A repository’s CLI reads like every other one, and agents can rely on the shape.

  • The agent policy is declared on each command as a graftkit.agent annotation, which cli-interview-kit carries without interpreting. Undeclared means hand-off.

  • Local skills are discovered, not declared. A folder in .agents/skills that no lock entry owns is the repository’s own. Listing them as well would be a second source of truth.

  • Bundles may contain vendor skills. The content release pins each one by commit and content hash in vendors.lock, so a moved tag or a changed skill fails before anything is written.

  • The lock is JSON, written by the tool and never edited by hand; tags are labels, the commit and the content hashes are the truth.

  • Settings questions derive from the Settings model: the field’s description is the help and the model is the validator, so a new setting is one field. One loader reads every layer and returns each value’s layer with the settings, so config show reads the layering instead of redoing it. Settings are read when a command first needs them: an invalid value fails that command once, and the commands that need none still run.

  • Role is GitHub access. The org commands work from the person’s own gh login, so they see only what that login can read, and report the person’s access to each repository. Permissions stay where they are managed (for Northbridge, Terraform); graftkit keeps no permission model of its own. Before opening a pull request, git asks GitHub for the person’s access and fails early below WRITE; GitHub still enforces every write.

  • The map is built per person, on demand, from what repositories already hold: GitHub’s metadata, the README’s ## For agents section, and the commands table of the generated skill, read back by the module that writes it. Nothing is published centrally, because a shared map would show every repository to everyone.

  • The generated skill always points to org map, whether or not organisation is set where sync runs: the skill must be the same on every machine and in CI, so it cannot depend on a person’s user config.

  • Agents read an index, then one command’s details. The generated skill lists every command in one line, with no options or examples, so it stays small however many commands a repository adds; an agent runs <command> --describe for the one it needs. Examples are declared on the command and checked against its flags when the app is built, so they are never wrong. (Anthropic’s MCP-CLI experiment takes the same shape for MCP tools.)

  • GitHub only through the GitHub CLI. graftkit never handles a token; authentication is whatever gh auth login (or GH_TOKEN in CI) set up.

  • Each repository carries its own small CI workflow (graftkit init). All logic lives in the CLI, so there is no shared workflow to version.

  • An in-house scaffold (string.Template) instead of a template engine: conformance checks, not template updates, keep older extensions on the standard.

Trade-offs#

  • Symbolic links for harnesses that do not read .agents/skills. One link per skill shows a skill placed straight into a harness folder as a stray. Windows needs core.symlinks.

  • sync --check is offline. It trusts the lock and the hashes on disk; it does not ask GitHub whether a newer release exists. That is skills update, run on purpose.

  • A vendor’s skills_path is searched at any depth, so vendors that group skills by plugin need one allow-list entry. A folder whose name is not a valid skill name is not a skill.

  • Simple on purpose. Vendors are downloaded one after another, and a stale lock re-resolves every source rather than only the changed one. A root pins a few vendors, and archives are cached by commit, so both are fast; parallel downloads or incremental resolution would earn their complexity only for a root with many vendors where sync is measurably slow.

  • org map has no cache. One GraphQL query per 100 repositories returns the metadata and both files at each head, which is a few seconds at an organisation’s size. A cache keyed by each repository’s head is the next step if the map is measurably slow. Only the map asks for the files, so a file too large for GitHub to return whole stops the map alone.

  • org sync only fast-forwards what is plainly a clone of the repository: its configured origin names it and it is on the default branch. Anything else may be someone’s work in progress, so it is skipped with the reason, never switched or reset.

  • org search is GitHub’s code search, with its limits: the default branch only, repositories GitHub has indexed (a new or rarely changed one may be missing), and a quota of about ten searches a minute. An index of its own would lift them, but is built only if GitHub’s search measurably falls short.

  • Python extensions only. The extension mechanism is Python entry points; another language’s commands can be wrapped by a Python command.

Extending#

  • A harness: a row in skills/harness.py and its name in HarnessName.

  • A core command: a module in commands/ defining command(context), its logic in workflows/, added in app.py; it follows the same standard as an extension’s.

  • A repository’s commands: an extension; see Writing an extension.