self-extend

self-extend is a skill for Claude Code, Codex from squadcodercom/squadcoder. It costs 56 tokens per session (973 once invoked), scanned D, a copy of self-extend, MIT.

A guide for extending an AI coding assistant with custom tools, hooks, and skills. Hooks are automatic actions that run when specified events occur, such as blocking a dangerous shell command.

In plain words
What is it for?
Use it to create project-specific tools, modify prompts or tool behavior, add safety checks, and store reusable domain knowledge.
Why use it?
It lets the assistant adapt to a project's recurring needs and enforce useful rules without repeatedly explaining them in chat.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to create project-specific tools, modify prompts or tool behavior, add safety checks, and store reusable domain knowledge.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/squadcodercom/squadcoder/self-extend
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add squadcodercom/squadcoder --skill self-extend
Clone the repo
git clone --depth 1 https://github.com/squadcodercom/squadcoder

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for self-extend

README.md
[![agentmods](https://agentmods.dev/badge/skills/squadcodercom/squadcoder/self-extend/github.svg)](https://agentmods.dev/skills/squadcodercom/squadcoder/self-extend)
Your own site
<a href="https://agentmods.dev/skills/squadcodercom/squadcoder/self-extend"><img src="https://agentmods.dev/badge/skills/squadcodercom/squadcoder/self-extend/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for self-extend

Your own site · 80×15
<a href="https://agentmods.dev/skills/squadcodercom/squadcoder/self-extend"><img src="https://agentmods.dev/badge/skills/squadcodercom/squadcoder/self-extend.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 56 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 973 The whole file, excluding the scripts and references it only reads on demand.
Security scan D 3 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 91% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00056 $0.00973
Opus 5 $0.00028 $0.00487
Sonnet 5 $0.00011 $0.00195
Haiku 4.5 $0.00006 $0.00097

Measured 6d ago against content hash f1ab8fee4ee5, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade D, and why

self-extend scanned grade D with 3 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks for rootmediumPrivilege escalation

A mod that escalates privileges can change anything on the machine, not only the project.

if (args.command.includes("sudo")) return "Error: sudo not allowed"

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

if (input.tool === "bash" && output.args.command?.includes("rm -rf /")) {

Runs shell commandslowCapability

Expected in a hook, worth knowing in a rule or an instructions file.

import { execSync } from "child_process"
Origin

This is a copy

91% identical to self-extend — 22 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

packages/opencode/src/skill/compose/.bundle/self-extend/SKILL.md · 132 lines

How it starts

The opening of the file, as written. The whole thing — 132 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Self-Extension

Overview

You can extend your own capabilities by writing files to .squadcoder/. Changes to tools, hooks, and skills take effect immediately (next turn) — no restart needed.

Creating Tools

Write to .squadcoder/tools/<name>.ts:

import { tool } from "@squadcoder/plugin"

export default tool({
  description: "What this tool does",
  args: {
    param1: tool.schema.string().describe("Parameter description"),
  },
  async execute(args, ctx) {
    // ctx.directory — project root
    // ctx.worktree — git worktree root
    // ctx.abort — AbortSignal
    return `Result: ${args.param1}`
  },
})

Multiple tools per file: use named exports instead of default.

Creating Hooks

Write to .squadcoder/hooks/<name>.ts — export a Hooks object:

export default {
  "tool.execute.before": async (input, output) => {
    if (input.tool === "bash" && output.args.command?.includes("rm -rf /")) {
      output.cancel = true
      output.cancelReason = "Blocked dangerous command"
    }
  },
  "experimental.chat.system.transform": async (input, output) => {
    output.system.push("Additional instruction here.")
  },
}

Hook Events

Event Capability
tool.execute.before Modify args or cancel=true to block
tool.execute.after Modify tool output
tool.definition Modify tool description/parameters
chat.params Modify temperature, topP, maxOutputTokens
experimental.chat.system.transform Append to system prompt
experimental.chat.messages.transform Modify message list sent to LLM
permission.ask Auto-allow/deny permission requests
shell.env Inject environment variables

Tool Override

A custom tool with the same id as a built-in replaces it:

// .squadcoder/tools/bash.ts — overrides built-in bash
import { tool } from "@squadcoder/plugin"
import { execSync } from "child_process"

export default tool({
  description: "Shell with safety checks",
  args: { command: tool.schema.string() },
  async execute(args, ctx) {
    if (args.command.includes("sudo")) return "Error: sudo not allowed"
    return execSync(args.command, { encoding: "utf-8", cwd: ctx.directory })
  },
})

Read the full file on GitHub · 132 lines

Files

What ships with it

4 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 132 lines · 56 tokens per session scan D f1ab8fee4ee5

Subscribe to this mod's changes

self-extend is a skill published in the GitHub repository squadcodercom/squadcoder (11 stars, last pushed 2mo ago), licensed MIT. It adds 56 tokens to every session and 973 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it D with 3 findings (asks for root, recursive force delete, runs shell commands). It is 91% identical to self-extend, differing in 22 lines, and is treated as a copy.