# How We Integrated Claude Code Mods at Apache Magpie

Over the past two months, I had the chance to explore, build, and ship **Claude Code Mods** across the skill families of [**Apache Magpie**](https://github.com/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.

![](https://cdn.hashnode.com/uploads/covers/6aed55f785cd1b8ef5a0f98d/e8a7e8a7-01af-4c02-bdc6-d7bdca16d3b7.png align="center")

---

## 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](https://github.com/apache/magpie/issues/1497).

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

![](https://cdn.hashnode.com/uploads/covers/6aed55f785cd1b8ef5a0f98d/d2b131a9-b8b1-4b6b-a7af-472782e247e3.png align="center")

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`](docs/when-to-use-mods.md) ([#1541](https://github.com/apache/magpie/pull/1541)).
- **CI & Pre-commit Validation:** We wired `claude plugin validate --strict` and `claude plugin test` into `prek` and GitHub Actions ([#1564](https://github.com/apache/magpie/pull/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](https://github.com/apache/magpie/pull/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](https://github.com/apache/magpie/pull/1601)) and `/magpie-skills` ([#1667](https://github.com/apache/magpie/pull/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](https://github.com/apache/magpie/pull/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](https://github.com/apache/magpie/pull/1856), [#1914](https://github.com/apache/magpie/pull/1914), and [#2134](https://github.com/apache/magpie/pull/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 `Pane`s, 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](https://github.com/apache/magpie/pull/1920), [#1954](https://github.com/apache/magpie/pull/1954), [#2160](https://github.com/apache/magpie/pull/2160)), a live triage sweep progress band ([#2221](https://github.com/apache/magpie/pull/2221)), and a PR stats dashboard pane ([#2432](https://github.com/apache/magpie/pull/2432)).
- **Release Management (**`family:release-management`**):** A live `verify-rc` checklist pane ([#2007](https://github.com/apache/magpie/pull/2007), [#2013](https://github.com/apache/magpie/pull/2013)) and a live vote-tally band ([#2216](https://github.com/apache/magpie/pull/2216)).
- **Issue Management (**`family:issue`**):** A duplicate-picker `Pane` ([#2076](https://github.com/apache/magpie/pull/2076), [#2080](https://github.com/apache/magpie/pull/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](https://github.com/apache/magpie/pull/2272)).
- **Utilities (**`family:utilities`**):** Commit attribution (`attribution.text` + `Bash` guard) ([#2234](https://github.com/apache/magpie/pull/2234)) and a live token-cost and context meter band ([#2237](https://github.com/apache/magpie/pull/2237)).
- **Pairing (**`family:pairing`**):** A multi-agent review side-by-side comparison pane ([#2274](https://github.com/apache/magpie/pull/2274), [#2323](https://github.com/apache/magpie/pull/2323)).
- **Security & Contributor Growth (**`family:security`**,** `family:contributor-growth`**):** Local-only triage and activity sweep panes ([#2295](https://github.com/apache/magpie/pull/2295), [#2398](https://github.com/apache/magpie/pull/2398), [#2397](https://github.com/apache/magpie/pull/2397), [#2399](https://github.com/apache/magpie/pull/2399), [#2583](https://github.com/apache/magpie/pull/2583)).

---

## Wrapping Up Setup & Closing #1497

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

- **Hardware-key signing-wait toast** ([#2584](https://github.com/apache/magpie/pull/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](https://github.com/apache/magpie/pull/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](https://github.com/apache/magpie/issues/1497) as completed.

![](https://cdn.hashnode.com/uploads/covers/6aed55f785cd1b8ef5a0f98d/a4081245-88b2-49a1-82cb-4a4a2ce77afe.png align="center")

---

## 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](https://github.com/apache/magpie/issues/2622):

1. **Update** `write-skill`**:** Automatically propose additive mods when authoring new skills, grounded in [`docs/when-to-use-mods.md`](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 :)
