Skip to main content

How We Integrated Claude Code Mods at Apache Magpie

Updated 5 min readMarkdown

Over the past two months, I had the chance to explore, build, and ship Claude Code Mods across the skill families of Apache Magpie. What started as an open-ended experiment turned into more than 20 merged PRs that save tokens, replace multi-turn confirmation loops with interactive terminal UI, and enforce deterministic safety checks.

Here is how the journey unfolded from day one, what broke along the way, and where we are taking it next.


Where It All Started: Jarek's Vision in Issue #1497

On October 2, 2026, Claude Code shipped native mods (v2.1.287), allowing plugins to run in-process JavaScript/TypeScript middleware (($, e, next)) around agent events. Right away, Jarek Potiuk (@potiuk) opened Issue #1497: Explore Claude Code mods across the skill families.

His idea wasn't to rewrite Magpie into Claude-specific code. Instead, he laid out four clear principles:

  • Keep skills vendor-neutral: Mods only run in Claude Code, so every skill must still work end-to-end on Codex, Antigravity, Goose, Pi, and headless claude -p when mods are absent.
  • Keep the unsandboxed surface tiny: Mods execute inside the host agent process outside the Bash sandbox, so every mod needs a minimal, auditable calls: surface.
  • No accidental LLM hops: Any model-routing hook still has to respect privacy-LLM rules.
  • Go zero-token wherever possible: Deterministic checks and status reports shouldn't burn model turns.

That framing gave us a clear North Star before writing a single line of hook code.


Laying the Rails First: Docs, CI, and Early Pilots

Before building features across every family, we made sure the framework itself could enforce those rules automatically:

  • Guidelines: We documented the boundaries in docs/when-to-use-mods.md (#1541).
  • CI & Pre-commit Validation: We wired claude plugin validate --strict and claude plugin test into prek and GitHub Actions (#1564) so every PR automatically prints and checks its hooked events, calls: surface, and unit tests.

Then came the first zero-token pilots in family:setup and family:utilities:

  • Setup drift check (#1552): Compares .apache-magpie.local.lock against .apache-magpie.lock on session.start and renders an AbovePrompt notice with zero model tokens.
  • /magpie-status (#1601) and /magpie-skills (#1667): Slash commands backed by command.run that print status and skill lists directly.

The Hardest Part: 8+ Review Rounds on the Security Guard (#1676)

If there was one PR that taught me the most about building production-grade mods, it was the deterministic public-surface scrub guard (#1676).

In magpie-security, security-fix commits and PRs against <upstream> must never leak embargoed terms (CVE-, vulnerability keywords, advisory details) onto public surfaces. We built a tool.call (Bash) guard that intercepts git commit, gh pr create, and gh pr comment before they run and inspects the payload deterministically.

Getting that right took 16 commits and 8+ intense review rounds with @potiuk (followed by refinements in #1856, #1914, and #2134). Every round surfaced real edge cases: fail-closed behavior, test-harness alignment, and making sure shell quoting or flags couldn't slip past the guard. Those iterations set the bar for every mod we shipped afterward.

Just as valuable was learning when not to use a mod:

  • We kept agent-guard as a settings hook (PreToolUse) so shell protection stays portable across Codex, Antigravity, and environments where mods are disabled.
  • We dropped in-process PII rewriting (session.append / prompt.submit), because mutating local session history does not replace gateway-level isolation.

Scaling Across Every Skill Family

With the core patterns proven, we brought interactive Panes, live AbovePrompt bands, and deterministic hooks across the rest of Magpie:

  • PR Management (family:pr-management): An interactive review findings Pane ([Accept], [Skip], [Edit]) replacing repetitive AskUserQuestion loops (#1920, #1954, #2160), a live triage sweep progress band (#2221), and a PR stats dashboard pane (#2432).
  • Release Management (family:release-management): A live verify-rc checklist pane (#2007, #2013) and a live vote-tally band (#2216).
  • Issue Management (family:issue): A duplicate-picker Pane (#2076, #2080) that pushed us to harden filesystem IPC (symlink prechecks via $.fs.stat, serialized writes, and stale-decision invalidation on re-stage), plus an issue sweep progress band (#2272).
  • Utilities (family:utilities): Commit attribution (attribution.text + Bash guard) (#2234) and a live token-cost and context meter band (#2237).
  • Pairing (family:pairing): A multi-agent review side-by-side comparison pane (#2274, #2323).
  • Security & Contributor Growth (family:security, family:contributor-growth): Local-only triage and activity sweep panes (#2295, #2398, #2397, #2399, #2583).

Wrapping Up Setup & Closing #1497

In the final stretch for family:setup, we landed two last pieces:

  • Hardware-key signing-wait toast (#2584): An advisory $.ui.toast when git commit or git tag runs with signing flags (-S, --gpg-sign, -s, --sign) so terminal users know when a hardware key might be waiting for a touch or PIN.
  • /magpie-mod-doctor static auditor (#2593): A zero-token command.run inspector (inspect_mods.py) wired into isolated-setup-verify that audits workspace and user mods for unapproved process or network calls while recognizing vetted magpie-python launcher calls. Even after CI went green, a contributor review caught 6 subtle static-analysis edge cases (regex-literal lexing, side-effect imports, multiline calls, installed plugin cache layouts, and verifiable call-site checks) that we fixed before merging.

With every explored item merged or resolved, we closed Issue #1497 as completed.


What's Next: Making Mods Standard (Issue #2622)

Now that mods have proven themselves across every family, @potiuk suggested the natural next step: make mods a standard part of how we write and optimize skills, now tracked in Issue #2622:

  1. Update write-skill: Automatically propose additive mods when authoring new skills, grounded in docs/when-to-use-mods.md.
  2. Update optimize-skill: Add a mod-opportunity smell and pass seeded from the mod patterns already shipped in the repo.
  3. Sweep all skills: Run optimize-skill across all skill families to find more zero-token command wins, friendlier interactive UI, and small cleanups (such as migrating /magpie-skills from python3/python to magpie-python).

Big thanks to everyone who reviewed, tested, and pushed these PRs forward!


Github: https://github.com/Kaap10

LinkedIn: https://www.linkedin.com/in/vardhman-gupta/

Thanks for reading :)

About the author

  • Apache Magpie Committer | Agentic AI & Security Engineer | Building @PicadoLabs
OOlivia2d ago

The security guard story is the part that stuck with me — 16 commits and 8+ review rounds for a deterministic scrub guard shows how much care the unsandboxed surface deserves. The zero-token principle is a great north star too; checks that don't burn model turns are exactly what make mods worth building.

Thanks so much, Olivia! Those 8+ rounds on the scrub guard definitely taught us to treat the unsandboxed surface with a lot of respect - it's also what led us to add /magpie-mod-doctor later to audit mod surfaces deterministically too.

Totally agree on the zero-token principle: keeping repetitive checks out of the model's context is where mods shine most!

OOlivia2d ago

That tracks — 8+ rounds on the scrub guard is the kind of lesson you only learn by hitting the unsandboxed surface yourself. Curious how /magpie-mod-doctor works in practice — does it run when a mod is installed, or is it something you invoke when you're reviewing one?

Great question! It runs 'on demand' rather than automatically on install. Whenever you want to check your setup or review mods, you just run /magpie-mod-doctor in Claude Code (it runs as plain code with zero AI tokens), or run the same inspector script from any other tool during setup verification.

Behind the scenes, it safely scans the mod files in your project and user config, and flags any unapproved subprocess or network calls - while recognizing official Magpie launcher calls as safe. (For Magpie's own PRs, CI also runs claude plugin validate --strict and unit tests before anything is merged.)

OOlivia1d ago

On-demand makes a lot of sense — it's a check I run when something feels off, rather than another thing watching in the background. When it flags something, is the output just a report, or does it also suggest a fix? And what does it most commonly flag in practice?

It's strictly a read-only report (available as Markdown or --format json) - it prints the verdict (clean or flagged), the exact file and line number, the category (process or network), and the sanitized line snippet, without modifying anything or auto-fixing on its own.

In practice, it flags unapproved subprocess calls (child_process, $.process.*, Bun.spawn, Deno.Command) and network calls (http/https/net, $.http, fetch(), WebSocket). Funny enough, the first time we ran it on Magpie itself, it immediately caught /magpie-skills still invoking python3/python via $.process.run instead of our pinned bin/magpie-python launcher - which was fixed right after!

OOlivia18h ago

A read-only report with the file and line number is exactly the kind of output I trust — no suggested fixes means there's nothing to second-guess. Does the JSON output plug into anything downstream, like a CI check or a mod-review step, or is it mainly for eyeballing during review?

Noce one !