feat: ship Agent Foundry as a Claude Code plugin #270

Merged
claudiomaradonna merged 3 commits from feat/claude-code-plugin into main 2026-12-02 17:50:37 +01:00
Collaborator

Why

Agent Foundry reaches Claude Code only through adoption: each repository holds a copy of AGENTS.md, .agents/, and .claude/, and every newer source needs a foundry-upgrade in each one. #269 gave OpenCode a folder it loads from outside the repository. This does the same for Claude Code, as a plugin installed once per user that updates with claude plugin update. Codex stays for a work of its own.

Refs #268

What changed

scripts/build-form.sh claude <commit> <folder> builds a folder that is itself a marketplace, dumbledore, holding one plugin, dumbledore. The plugin holds the shared part, byte for byte the same as OpenCode's form, the subagent adapters, and hooks wiring the main-checkout guard and the shell check. Its version is the source commit, so each build is an update.

A plugin carries no CLAUDE.md, so SessionStart hooks hand the policy over as added context. Claude Code caps each hook's context at 10,000 characters, and the built policy is about 18,500. The build therefore cuts it at its ## headings into parts, three today, each with its own hook and an opening line saying "Part n of m", so the model can put them back in order. The last part adds where the plugin sits, known only at run time, and that Claude Code lists the skills and subagents the policy names by their bare names as dumbledore:<name>. Claude Code reads the project's own AGENTS.md itself, and the policy already has the session read AGENTS.local.md.

A plugin cannot carry settings, so the build also writes settings/dumbledore.json, which the operator merges into ~/.claude/settings.json. It holds the source's denied tools, Read rules, edits that ask first, and the features it turns off, without the source's sandbox.

scripts/publish-form.sh commits the build to the branch claude-plugin when it changes, without force. It refuses to put an older build over a newer one. A publish job in the Maintenance workflow runs it after the checks pass on each push to main, using the forge's automatic token. Operators add the marketplace as <repository URL>#claude-plugin. The section "Plugin for Claude Code" of docs/INSTALL.md gives the install, update, and checks.

How to verify

Needs Claude Code 2.1.277 or later, jq, and this branch checked out. Branch tip 1e6bc53, base main at 249629c.

  1. Build and validate the build:

    scripts/build-form.sh claude HEAD /tmp/example/build
    claude plugin validate /tmp/example/build
    

    It exits 0, with warnings for no author, README, or icon. On main, the claude target exits 2 with the usage line.

  2. In a scratch repository holding only a README and a git-ignored AGENTS.local.md with a Test command, run:

    claude -p --plugin-dir /tmp/example/build/plugins/dumbledore "Without calling a tool, quote the first bullet of the section Working with the user."
    

    The answer starts "Material decisions, such as product, architecture, and stack choices".

    Run on 2026-12-02 with Claude Code 2.1.334 and Sonnet 5.5, these scenarios gave the expected results:

    • the three parts arrived whole, in the order 1, 3, 2, and again after /compact;
    • 27 skills were listed, foundry-upgrade not among them, and implement-feature then loaded dumbledore:run-change from its bare name;
    • all seven subagents launched and resolved agent-foundry/templates/handoff.md to the plugin's path;
    • the guard refused a Write to the main checkout;
    • writing echo $1 in a worktree showed ShellCheck's SC2086;
    • the session answered the Test command from AGENTS.local.md.
  3. Publish to a local bare repository, serve it over HTTP, then add, install, publish a later commit, and update. Claude Code refuses file:// as a marketplace source, hence HTTP. In a scratch CLAUDE_CONFIG_DIR, this moved the plugin from the earlier commit to the later one. Doing the same with a local build folder rebuilt in place also updated it.

Checks on the tip: tests/verify-agent-config.sh 412 passed, with the new areas build-form.sh (42) and publish-form.sh (8); tests/check-work-folder.sh 46; ShellCheck clean; prettier; the static validator; and git diff --check main. Each new test fails on main, at the claude target name or at the publishing script the branch adds.

Considerations

  • The publish job has not run on the forge yet. Its first push to main after the merge shows whether the automatic token can push claude-plugin. Forgejo's documentation says the token can push for a push event.
  • The source's sandbox stays out of the plugin's settings. Its exclusion for run-sandboxed.sh could not match an installed path, because Claude Code does not expand ~ in excludedCommands. Whether the sandbox stays at all is open.
  • Policy parts reach the model out of order. Their opening lines put them back, and a missing part, for example when jq is absent, starts the session without it; the opening line asks the model to tell the user.
  • Set aside as low: the settings step assumes ~/.claude rather than a custom CLAUDE_CONFIG_DIR, and the context text's sentence that AGENTS.md names the policy, inherited from the OpenCode form.

https://claude.ai/code/session_012wUN2eKSj9s2vRHJdFPNk3

## Why Agent Foundry reaches Claude Code only through adoption: each repository holds a copy of `AGENTS.md`, `.agents/`, and `.claude/`, and every newer source needs a `foundry-upgrade` in each one. #269 gave OpenCode a folder it loads from outside the repository. This does the same for Claude Code, as a plugin installed once per user that updates with `claude plugin update`. Codex stays for a work of its own. Refs #268 ## What changed `scripts/build-form.sh claude <commit> <folder>` builds a folder that is itself a marketplace, `dumbledore`, holding one plugin, `dumbledore`. The plugin holds the shared part, byte for byte the same as OpenCode's form, the subagent adapters, and hooks wiring the main-checkout guard and the shell check. Its `version` is the source commit, so each build is an update. A plugin carries no `CLAUDE.md`, so SessionStart hooks hand the policy over as added context. Claude Code caps each hook's context at 10,000 characters, and the built policy is about 18,500. The build therefore cuts it at its `##` headings into parts, three today, each with its own hook and an opening line saying "Part n of m", so the model can put them back in order. The last part adds where the plugin sits, known only at run time, and that Claude Code lists the skills and subagents the policy names by their bare names as `dumbledore:<name>`. Claude Code reads the project's own `AGENTS.md` itself, and the policy already has the session read `AGENTS.local.md`. A plugin cannot carry settings, so the build also writes `settings/dumbledore.json`, which the operator merges into `~/.claude/settings.json`. It holds the source's denied tools, `Read` rules, edits that ask first, and the features it turns off, without the source's sandbox. `scripts/publish-form.sh` commits the build to the branch `claude-plugin` when it changes, without force. It refuses to put an older build over a newer one. A `publish` job in the Maintenance workflow runs it after the checks pass on each push to `main`, using the forge's automatic token. Operators add the marketplace as `<repository URL>#claude-plugin`. The section "Plugin for Claude Code" of `docs/INSTALL.md` gives the install, update, and checks. ## How to verify Needs Claude Code 2.1.277 or later, `jq`, and this branch checked out. Branch tip `1e6bc53`, base `main` at `249629c`. 1. Build and validate the build: ```sh scripts/build-form.sh claude HEAD /tmp/example/build claude plugin validate /tmp/example/build ``` It exits 0, with warnings for no author, README, or icon. On `main`, the `claude` target exits 2 with the usage line. 2. In a scratch repository holding only a README and a git-ignored `AGENTS.local.md` with a Test command, run: ```sh claude -p --plugin-dir /tmp/example/build/plugins/dumbledore "Without calling a tool, quote the first bullet of the section Working with the user." ``` The answer starts "Material decisions, such as product, architecture, and stack choices". Run on 2026-12-02 with Claude Code 2.1.334 and Sonnet 5.5, these scenarios gave the expected results: - the three parts arrived whole, in the order 1, 3, 2, and again after `/compact`; - 27 skills were listed, `foundry-upgrade` not among them, and `implement-feature` then loaded `dumbledore:run-change` from its bare name; - all seven subagents launched and resolved `agent-foundry/templates/handoff.md` to the plugin's path; - the guard refused a Write to the main checkout; - writing `echo $1` in a worktree showed ShellCheck's SC2086; - the session answered the Test command from `AGENTS.local.md`. 3. Publish to a local bare repository, serve it over HTTP, then add, install, publish a later commit, and update. Claude Code refuses `file://` as a marketplace source, hence HTTP. In a scratch `CLAUDE_CONFIG_DIR`, this moved the plugin from the earlier commit to the later one. Doing the same with a local build folder rebuilt in place also updated it. Checks on the tip: `tests/verify-agent-config.sh` 412 passed, with the new areas `build-form.sh` (42) and `publish-form.sh` (8); `tests/check-work-folder.sh` 46; ShellCheck clean; prettier; the static validator; and `git diff --check main`. Each new test fails on `main`, at the `claude` target name or at the publishing script the branch adds. ## Considerations - The `publish` job has not run on the forge yet. Its first push to `main` after the merge shows whether the automatic token can push `claude-plugin`. Forgejo's documentation says the token can push for a push event. - The source's sandbox stays out of the plugin's settings. Its exclusion for `run-sandboxed.sh` could not match an installed path, because Claude Code does not expand `~` in `excludedCommands`. Whether the sandbox stays at all is open. - Policy parts reach the model out of order. Their opening lines put them back, and a missing part, for example when `jq` is absent, starts the session without it; the opening line asks the model to tell the user. - Set aside as low: the settings step assumes `~/.claude` rather than a custom `CLAUDE_CONFIG_DIR`, and the context text's sentence that `AGENTS.md` names the policy, inherited from the OpenCode form. https://claude.ai/code/session_012wUN2eKSj9s2vRHJdFPNk3
The target claude lays the shared part out as the plugin dumbledore in
a marketplace of the same name, so a repository with no foundry file
gets the policy, skills, subagents, and hooks in Claude Code. Claude
Code caps each hook's added context at 10,000 characters, so the policy
goes over in parts cut at its headings, one SessionStart hook each, the
last with where the plugin sits, known only at run time. Claude Code's
settings, which a plugin cannot carry, are built beside it without the
source's sandbox.
An operator adds the marketplace once by the repository's git URL with
#claude-plugin and updates it with claude plugin update, so each merge
to main must leave that branch holding the build of the merged commit.
The job sits in the Maintenance workflow, after its checks, since
Forgejo has no workflow_run event to wait on them with. An unchanged
build adds no commit, so an update finds nothing new.
docs(install): describe the Claude Code plugin
Some checks failed
Maintenance / checks (pull_request) Failing after 3m50s
Maintenance / publish (pull_request) Has been skipped
Maintenance / checks (push) Successful in 9m30s
Maintenance / publish (push) Successful in 4m18s
1e6bc5320b
First-time contributor

Command failed

The agent did not complete this command, so nothing came of it. A person should look at this thread.

The run failed at step "aoe_purge". The operator reads the job logs in the Windmill editor, or finds the run with: wmill job list --path f/agents/bot_commands

## Command failed The agent did not complete this command, so nothing came of it. A person should look at this thread. The run failed at step "aoe_purge". The operator reads the job logs in the Windmill editor, or finds the run with: `wmill job list --path f/agents/bot_commands`
claudiomaradonna deleted branch feat/claude-code-plugin 2026-12-02 17:50:55 +01:00
Sign in to join this conversation.
No description provided.