setup

setup is a command for Claude Code from JuanMarchetto/agent-skills. It costs 33 tokens per session (990 once invoked), scanned A, original, MIT.

A setup command that installs error-detection hooks in a project or user configuration.

In plain words
What is it for?
Use it to install the learning system locally for one project or globally for your user account.
Why use it?
It adds automatic lesson tracking without replacing hooks that are already configured.

Command for Claude Code

Written for Claude Code: PostToolUse hook event. Also seen: reads .claude/ paths.

Part of the learn-by-mistake plugin — 1 skill, 4 commands, 3 hooks shipped together

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.

agentmods
npx agentmods add commands/juanmarchetto/agent-skills/setup
Clone the repo
git clone --depth 1 https://github.com/JuanMarchetto/agent-skills

Made for: Claude Code.

Or install learn-by-mistake, the plugin that ships this one along with the rest of its 1 skill, 4 commands, 3 hooks.

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 setup

README.md
[![agentmods](https://agentmods.dev/badge/commands/juanmarchetto/agent-skills/setup.svg)](https://agentmods.dev/commands/juanmarchetto/agent-skills/setup)
Your own site
<a href="https://agentmods.dev/commands/juanmarchetto/agent-skills/setup"><img src="https://agentmods.dev/badge/commands/juanmarchetto/agent-skills/setup.svg" alt="Measured on agentmods" height="20"></a>
Per session 33 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 990 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found 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.00033 $0.00990
Opus 5 $0.00016 $0.00495
Sonnet 5 $0.00007 $0.00198
Haiku 4.5 $0.00003 $0.00099

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

Security

Grade A, and why

setup scanned grade A with 0 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 2d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/learn-by-mistake/commands/setup.md · 147 lines

How it starts

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

/learn setup

Install the learn-by-mistake hooks for automatic error detection. This command MERGES hooks into your existing configuration — it never overwrites other hooks.

What it does

  1. Detect if hooks should go to project level (.claude/hooks.json) or user level (~/.claude/hooks.json)
  2. Read existing hooks file (if any)
  3. Merge learn-by-mistake hooks into the existing structure
  4. Write the merged result
  5. Verify installation

Protocol

Step 1: Determine scope

  • If the user said /learn setup --global → use ~/.claude/hooks.json
  • Otherwise → use .claude/hooks.json in the current project root
  • Tell the user which location you're using

Step 2: Read existing hooks

Read the target hooks file. If it exists, parse the JSON. If it doesn't exist, start with:

{"hooks": {}}

Step 3: Merge — NEVER overwrite

For each hook type (PostToolUse, SessionStart, PreCompact):

If the hook type doesn't exist in the target file: add it entirely.

If the hook type already exists: APPEND learn-by-mistake hooks to the existing array. Never remove or modify existing hooks.

To prevent duplicates, check if any existing hook command contains "learn-by-mistake" or "detect-error" before adding.

Step 4: Determine script paths

The hook scripts live in the skill directory. Find them:

# Check common locations
SKILL_DIR=""
for dir in \
  ~/.claude/skills/learn-by-mistake \
  .claude/skills/learn-by-mistake \
  node_modules/learn-by-mistake-skill; do
  if [ -f "$dir/hooks/scripts/detect-error.sh" ]; then
    SKILL_DIR="$dir"
    break
  fi
done

Use ABSOLUTE paths in the hooks.json to avoid working directory issues.

Step 5: Write the merged hooks

The learn-by-mistake hooks to merge:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "bash <SKILL_DIR>/hooks/scripts/detect-error.sh",
            "timeout": 5
          }
        ]
      }
    ],
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "bash <SKILL_DIR>/hooks/scripts/load-lessons.sh",
            "timeout": 3
          }
        ]
      }
    ],
    "PreCompact": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "bash <SKILL_DIR>/hooks/scripts/preserve-lessons.sh",
            "timeout": 3
          }
        ]
      }
    ]
  }
}

Read the full file on GitHub · 147 lines

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. 2d ago First seen · 147 lines · 33 tokens per session scan A e9c1e6cc55c4

Subscribe to this mod's changes

setup is a command published in the GitHub repository JuanMarchetto/agent-skills (5 stars, last pushed 5mo ago), licensed MIT. It adds 33 tokens to every session and 990 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.