Skip to content
Back to skills

Splice Mods

ASecurity

Author, configure, wire up, and troubleshoot Splice Mods (TypeScript Mods v2 via `splice mod install`) and Splice Modes (External JAR Modes via `[[mods.jar]]`, MCP tools, `ui://` MCP Apps, request-lifecycle-only API hooks, and `/api/` or `/server/mod/` routes) without touching the Splice source repository. Make sure to use this skill whenever creating a Splice mod or mode, choosing between TS Mods v2 vs External JAR Modes vs standard MCP servers, building a zero-UI/zero-tool request-lifecycle...

  • 20 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentstypescriptpythonrustjavakotlinbashsqlnodedebugginggit

Works with

  • claude desktop
  • cli
  • api
  • mcp

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add torad-labs/splice --skill splice-mods --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Splice Mods?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Splice Mods
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/torad-labs-splice-mods/badge)](https://www.skillsdirectory.com/skills/torad-labs-splice-mods)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: splice-mods
description: >-
  Author, configure, wire up, and troubleshoot Splice Mods (TypeScript Mods v2 via
  `splice mod install`) and Splice Modes (External JAR Modes via `[[mods.jar]]`,
  MCP tools, `ui://` MCP Apps, request-lifecycle-only API hooks, and `/api/` or
  `/server/mod/` routes) without touching the Splice source repository. Make sure
  to use this skill whenever creating a Splice mod or mode, choosing between TS
  Mods v2 vs External JAR Modes vs standard MCP servers, building a
  zero-UI/zero-tool request-lifecycle hook mode (`session_start`,
  `before_tool_call`, `after_tool_call`, `on_stop`, `request`, `response` like
  `modes/gather`), starting from `modes/template` or `modes/templateapp`, toggling
  mods in Console Settings Splice Mods, or debugging refused capabilities or
  `server_taken` collisions.
---
<!-- splice-managed: splice-plugin -->

# Authoring Splice Mods and Modes

Build extensions for Splice **without modifying or rebuilding Splice itself**. Both TypeScript Mods v2 (`splice mod install`) and External JAR Modes (`[[mods.jar]]` in `splice.toml`) load externally into an installed Splice daemon.

For general gateway ops (`splice.toml`, restarts, `/api/*`), use the `splice` skill; for Claude Desktop reload and policy rules, use `splice-desktop-policy`.

---

## Step 0: Decision Matrix (Start Here)

Choose the right extension mechanism **before** writing code:

| What you need to build | Use | Runs today? | Needs Splice source? |
| --- | --- | --- | --- |
| Observe sessions and turns, store per-mod SQLite KV state, log telemetry, or trigger external side effects | **Path A: TypeScript Mod v2** (`splice mod install`) | Yes (observe-only) | No |
| Give models tools (`kind = "door"` or `"mcp"`), draw MCP App `ui://` views in Claude Desktop, or serve `/api/` or `/server/mod/<name>/` routes | **Path B1: External JAR Mode** (`[[mods.jar]]`) | Yes | No (compile against installed `splice.jar`) |
| Intercept or mutate turns/tools/requests/responses with **zero UI and zero tools** (pure API/lifecycle hook mode, e.g., `modes/gather`) | **Path B2: Request-Lifecycle-Only JAR Mode** (`tools = []` + `[hooks.*]`) | Yes | No (compile against installed `splice.jar`) |
| Expose MCP tools and/or `ui://` MCP Apps from an existing Bun/Node/Python/Rust server without a JVM build | **Path C: Standard MCP Server** (`splice mcp import` / `sync`) | Yes | No |

> **CRITICAL — What TypeScript Mods v2 REFUSES at load today (Phase 1 observe-only)**
>
> Splice refuses at load: `mod.json` declarations `pages`, `commands`, `tools`, `views` (`declared but not served yet`); event handlers `sessions.list`, `ui.render`, `command.run`, `http.request`, `launch.prepare`; handle calls `$.sessions.invalidate()` (throws if called), `$.ui`, `$.ui.respond()`; and turn mutations (handler return values and modified events passed to `next(e)` have **no effect** on any turn).
>
> Do **not** build tools, UI views, commands, or request rewriters as a TS Mod v2 expecting them to serve, and never mock a fake Mods v2 host in tests to hide real daemon refusals. Use **Path B1/B2** or **Path C** instead.

---

## Path A: TypeScript Mod v2 (Observe-Only)

Detailed API, limits, and exact load notices: [references/ts-mod-v2.md](references/ts-mod-v2.md).
TypeScript contract declarations: [references/contract.ts](references/contract.ts).

### 1. Layout & manifest

```text
my-mod/
  .splice-mod/
    mod.json          # manifest (required)
  hooks/
    hooks.json        # { "modules": ["./register.ts"] }
    register.ts       # export const register: Register = (on) => { ... }
  types/
    contract.ts       # optional local copy of references/contract.ts
```

- `hooks/` sits at the mod root beside `.splice-mod/`, never inside `.splice-mod/`.
- `name` in `mod.json` must match `[a-z][a-z0-9]*` (lowercase letters and digits only, max 40 chars; e.g., `turnwatch`, not `turn-watch`).
- `capabilities` in `mod.json` is an **install-time disclosure** shown to the user, not a sandbox or permission wall.

### 2. Minimal `mod.json`, `hooks.json`, and `register.ts`

```json
{
  "name": "turnwatch",
  "version": "0.1.0",
  "description": "Records turn counts and token usage per session.",
  "capabilities": ["watch-sessions", "watch-turns"]
}
```

```json
{ "modules": ["./register.ts"] }
```

```ts
import type { Register } from "../types/contract.ts";

export const register: Register = (on) => {
  on("session.start", async ($, e, next) => {
    $.log(`session ${e.session} started in ${e.cwd} (seenBefore=${e.seenBefore})`);
    await next(e);
  });

  on("turn.complete", async ($, e, next) => {
    const key = e.session ?? "unattributed";
    const count = ((await $.store.get(key)) as number | undefined) ?? 0;
    await $.store.set(key, count + 1);
    $.log(`turn ${e.turn}: model=${e.model} outcome=${e.outcome} in=${e.usage.input} out=${e.usage.output}`);
    await next(e);
  }).catch(async ($, e, next) => {
    $.log(`handler error: ${e.error.message}`);
    await next(e);
  });
};
```

- **Import confinement:** Runtime imports may only target files inside the mod's own folder (including its own `node_modules`) and Bun built-ins (`bun:`, `node:`). `import type` is erased at runtime.
- **Served events:** `mod.start`, `mod.stop`, `session.start`, `session.end`, `turn.start`, `request.send`, `stream.event`, `tool.call` (filter `{ server?, tool? }`), `response.receive`, `turn.complete` (metadata only — never bodies or tool arguments).
- **Served `$` handle:** `$.store` (`get`, `set`, `delete`, `list`), `$.clock` (`now`, `after`), `$.log`, `$.sessions.list()`.
- **Labels & opt-out:** `SPLICE_LABEL_<KEY>=<value>` (lowercased in `e.labels`), `SPLICE_MODS_OFF=1` or comma-separated mod names.

### 3. Install and verify live (Bun required)

```bash
splice mod install ./my-mod --link   # dev: reads folder directly (not hash-checked)
splice mod install ./my-mod          # prod: copies into state + records SHA-256 hashes
splice mod list                      # verify state == running, dropped events == 0, no last handler error
```

Check `<logs>/mods/<name>.log` (default `~/.splice/logs/mods/<name>.log`) after a real turn to confirm handlers fired.

---

## Path B: External JAR Modes (`[[mods.jar]]`)

Full JAR spec, `Mode` / `ModeHooks` / `ModeSession` contracts, `ui://` JSON-RPC handshake, hook wire format, and security rules: [references/external-jar-mode.md](references/external-jar-mode.md).

### Starter templates & built-in references

- **`modes/template`** — minimal `kind = "door"` starter mode (one tool answered inside Splice).
- **`modes/templateapp`** — minimal `kind = "mcp"` starter mode with a `ui://` MCP App resource.
- **`modes/gather`** — built-in example of a **Request-Lifecycle-Only (API-only, zero-UI, zero-tool)** mode using door hooks without exposing any model tools or UI views.

### 1. Required JAR layout & compiling against `splice.jar`

```text
my-mode.jar
  splice-modes/
    index                          # one mode folder name per line (e.g. "mymode")
    mymode/
      mode.toml                    # manifest
      prompt.md                    # optional model guidance / MCP instructions
      tools/<tool>.{json,md,meta.json}   # omitted when tools = []
      resources/<page>.html        # optional static ui:// MCP App resource
  META-INF/services/splice.modes.api.Mode
  com/example/mymode/MyMode.class  # public no-arg constructor
```

Compile standalone on JDK 21 with `compileOnly` against `~/.local/share/splice/splice.jar` (or `$SPLICE_JAR`):

```kotlin
plugins { kotlin("jvm") version "2.1.20" }
java { toolchain { languageVersion.set(JavaLanguageVersion.of(21)) } }
val spliceJar = providers.environmentVariable("SPLICE_JAR")
    .orElse(providers.provider { "${System.getProperty("user.home")}/.local/share/splice/splice.jar" })
dependencies { compileOnly(files(spliceJar)) }
```

- Parent-first `ModJarClassLoader`: never bundle `splice/core/` or `splice/modes/api/`, and never set manifest `Class-Path`. Max 32 MiB on disk, 64 MiB expanded.
- `ModeSession.caller` is **nullable** (`ModeCaller?`) since 0.7.0 — always handle `null`.

### 2. Three External JAR Mode patterns

- **Door / MCP tool & `ui://` MCP App mode (Path B1):**
  - `kind = "door"` (default): Splice answers tool calls inside the turn across Anthropic, Chat Completions, and Responses providers.
  - `kind = "mcp"`: Daemon serves `/mcp/<server>` in-process. Models see `mcp__<server>__<tool>` and Claude Desktop renders `[[resources]]` (`ui://...`, linked via `tools/<tool>.meta.json`). Use `on_for = ["desktop"]` for Desktop-only UI modes.
- **Request-Lifecycle-Only (API-only, zero-UI, zero-tool) mode (Path B2):**
  Set `tools = []`, omit `tools/` and `resources/`, implement `Mode` + `ModeHooks` (or wire external `http`/`mcp` workers), and declare any of the 6 hook moments (`[hooks.session_start]`, `[hooks.before_tool_call]`, `[hooks.after_tool_call]`, `[hooks.on_stop]`, `[hooks.request]`, `[hooks.response]`). Use this whenever you want pure request/tool/response interception or context injection with zero tool-schema or UI overhead (as `modes/gather` does):
  ```toml
  name = "myhook"
  summary = "Injects context or enforces policy across request lifecycle hooks."
  server = "myhook"
  handler = "com.example.myhook.MyHookMode"
  tools = []
  kind = "door"
  on = false

  [hooks]
  order = 10

  [hooks.session_start]
  timeout_s = 5
  on_failure = "open"

  [hooks.request]
  timeout_s = 10
  on_failure = "open"
  ```
- **Custom HTTP routes:** Return `ModeRoute` entries from `Mode.routes` to mount management-key-guarded endpoints under `/api/`, or implement `Mode.serve(ModRequest)` and set `[modes.<name>] server_routes = true` (plus optional `server_admin_only = true`) to serve Team Server endpoints at `/server/mod/<name>/...`.

### 3. Pin in `splice.toml` and verify live

Place the JAR under `~/.config/splice/mods/` (or `[mods] dir`), compute its SHA-256 (`sha256sum my-mode.jar`), pin it in `~/.config/splice/splice.toml`, and verify:

```toml
[[mods.jar]]
name = "mymode-release"
path = "my-mode.jar"
sha256 = "<64-hex-sha256>"

[modes.mymode]
on = true
```

```bash
splice check-config          # validates pin, JAR layout, manifest, tools, hooks, and collisions
splice restart               # loads the pinned JAR into the running daemon
splice status                # confirm mode is active and NOT "server_taken"
```

Confirm via `GET /api/modes` that `server_taken` is `false` (for `kind = "mcp"`) and `on` / `callers` match your intent.

---

## Path C: Standard MCP Server (Non-JVM)

If you already have a Bun, Node, Python, or Rust server and only need tools or `ui://` MCP Apps without Splice door hooks:
1. Build a standard stdio or Streamable HTTP MCP server.
2. Register it in `~/.claude.json` or `claude_desktop_config.json`, or sync across harnesses with `splice mcp import` and `splice mcp sync`.

---

## Console Management (`Settings -> Splice Mods`)

Built-in modes, pinned External JAR Modes, and installed TS Mods v2 are managed together in **Console -> Settings -> Splice Mods** (`splice console`, then open Settings):
- Use one-click **Enable All** to turn on available mods/modes at once, or toggle individual modes per head and per session default (`Default` / `On` / `Off` for `on_for = ["desktop"]` modes).
- Live API equivalents: `GET /api/modes`, `PUT /api/modes/<name>`, and `GET /api/mods`.
- **Claude Desktop reload rule:** After adding, removing, or toggling any `kind = "mcp"` mode, **fully quit Claude Desktop and reopen it** so it reloads `claude_desktop_config.json`.

---

## Hard Rules

1. **Zero Splice source edits for personal or third-party extensions.** Use TS Mods v2 or `[[mods.jar]]`.
2. **Never mock away Phase 1 TS Mod host refusals** to pretend unserved capabilities work.
3. **Neither TS mods nor JAR modes are sandboxed.** Both run with the user/daemon account's permissions; `capabilities` in `mod.json` is disclosure only.
4. **Never trust `ModeSession.caller` or `_meta.ui.visibility` for authorization.** Both are client-facing hints; enforce real access control where the action executes.
5. **Always verify against the live daemon** (`splice mod list` + `GET /api/mods`, or `splice check-config` + `splice restart` + `splice status` + `GET /api/modes`) before declaring an extension wired up.

Files in this skill

  • SKILL.md12.1 KB
  • references/external-jar-mode.md14 KB
  • references/ts-mod-v2.md10.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.