<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jack Napier</title>
    <description>The latest articles on DEV Community by Jack Napier (@mrnapier).</description>
    <link>https://dev.to/mrnapier</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4267141%2F56d4eae8-7d49-4564-adbe-c5e7b71242c2.png</url>
      <title>DEV Community: Jack Napier</title>
      <link>https://dev.to/mrnapier</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mrnapier"/>
    <language>en</language>
    <item>
      <title>Claude Code Subagents: 4 Practical Examples You Can Copy Today</title>
      <dc:creator>Jack Napier</dc:creator>
      <pubDate>Fri, 27 Nov 2026 18:33:51 +0000</pubDate>
      <link>https://dev.to/mrnapier/claude-code-subagents-4-practical-examples-you-can-copy-today-33a7</link>
      <guid>https://dev.to/mrnapier/claude-code-subagents-4-practical-examples-you-can-copy-today-33a7</guid>
      <description>&lt;p&gt;If you use Claude Code for more than quick edits, you eventually hit the same wall: the main conversation fills up with file dumps, test logs and half-finished investigations, and the quality of answers drops.&lt;/p&gt;

&lt;p&gt;Subagents fix a big part of that. A subagent is a separate Claude instance with &lt;strong&gt;its own context window, its own system prompt and its own tool permissions&lt;/strong&gt;. The main session hands it a task, the subagent does the noisy work, and only a short result comes back.&lt;/p&gt;

&lt;p&gt;This post shows how subagents are defined and four examples you can copy into a project today.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where subagents live
&lt;/h2&gt;

&lt;p&gt;A subagent is a Markdown file with YAML frontmatter:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.claude/agents/&amp;lt;name&amp;gt;.md&lt;/code&gt; — project subagents (commit them so your team gets them)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;~/.claude/agents/&amp;lt;name&amp;gt;.md&lt;/code&gt; — personal subagents, available in every project&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If both exist with the same name, the project one wins. You can also create and edit them interactively with the &lt;code&gt;/agents&lt;/code&gt; command inside Claude Code.&lt;/p&gt;

&lt;p&gt;The basic shape:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
name: my-agent
description: "When Claude should use this agent. Be specific."
tools: Read, Grep, Glob
model: sonnet
---

The system prompt for the agent goes here.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Three fields do most of the work:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;description&lt;/code&gt;&lt;/strong&gt; is how Claude decides when to delegate. Vague descriptions mean the agent never gets picked. Phrases like "Use proactively after code changes" help.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;tools&lt;/code&gt;&lt;/strong&gt; restricts what the agent can do. Leave it out and the agent inherits all tools from the main session, including Bash and edits.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;model&lt;/code&gt;&lt;/strong&gt; lets you run cheap tasks on a smaller model (&lt;code&gt;haiku&lt;/code&gt;) and keep &lt;code&gt;sonnet&lt;/code&gt;/&lt;code&gt;opus&lt;/code&gt; for harder ones. &lt;code&gt;inherit&lt;/code&gt; uses whatever the main session uses.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can always call an agent explicitly: &lt;em&gt;"Use the code-reviewer subagent to review my last commit."&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 1: a read-only code reviewer
&lt;/h2&gt;

&lt;p&gt;The most useful subagent for most people. Note that it has no &lt;code&gt;Edit&lt;/code&gt; or &lt;code&gt;Write&lt;/code&gt; tool, so it can only report, not "fix" things behind your back.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
name: code-reviewer
description: Reviews recent code changes for bugs, security problems and readability. Use proactively after writing or modifying code.
tools: Read, Grep, Glob, Bash
model: sonnet
---

You are a senior code reviewer.

1. Run &lt;span class="sb"&gt;`git diff HEAD`&lt;/span&gt; to see what changed. If nothing is staged or modified, review the last commit with &lt;span class="sb"&gt;`git show`&lt;/span&gt;.
2. Read the surrounding code for every changed function, not just the diff lines.
3. Report findings grouped as: Critical, Warnings, Suggestions.
4. For each finding give file:line, what is wrong, and a concrete fix.

Do not rewrite files. Do not comment on formatting a linter would catch.
If you find nothing important, say so in one line.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bash is included only so it can run &lt;code&gt;git diff&lt;/code&gt;. If you want it stricter, a &lt;code&gt;PreToolUse&lt;/code&gt; hook can block anything that isn't a read-only git command.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 2: a test runner that keeps logs out of your context
&lt;/h2&gt;

&lt;p&gt;Test output is the classic context killer: hundreds of lines of passing tests to find one failure. Let a subagent read them.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
name: test-runner
description: Runs the project's test suite and reports only failures with their root cause. Use after code changes or when the user asks to run tests.
tools: Read, Grep, Glob, Bash
model: haiku
---

You run tests and summarize results.

1. Detect the test command (package.json scripts, pytest.ini/pyproject.toml, Makefile, go.mod).
2. Run the full suite once.
3. If everything passes, reply with one line: the command and the pass count.
4. For each failure, report: test name, the assertion or error, and the most likely cause after reading the code under test.

Never modify source or test files. Keep the final answer under 25 lines.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;haiku&lt;/code&gt; is usually enough here: the job is running a command and reading output, not deep reasoning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 3: a debugger with a strict process
&lt;/h2&gt;

&lt;p&gt;When a bug is subtle, the main session tends to guess and patch. A dedicated debugger with a fixed process guesses less.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
name: debugger
description: Investigates errors, failing tests and unexpected behavior to find the root cause. Use when a bug is not obvious from the error message.
tools: Read, Grep, Glob, Bash, Edit
model: sonnet
---

You are a debugging specialist.

1. Reproduce the problem first. Write down the exact command and the observed output.
2. Form at most three hypotheses and rank them.
3. Test each hypothesis with the smallest possible experiment (a log line, a one-off script, a focused test).
4. Only after the cause is confirmed, apply the minimal fix and rerun the reproduction.

Report: root cause, evidence, the fix, and how you verified it.
If you could not confirm the cause, say so instead of guessing.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This one gets &lt;code&gt;Edit&lt;/code&gt; because applying the fix is part of the job. Decide per agent; don't hand edit rights to every agent by default.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 4: a cheap codebase explorer
&lt;/h2&gt;

&lt;p&gt;"Where is X handled?" questions often need reading 20 files to produce a 5-line answer. That's exactly the shape subagents are good at.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;---
name: explorer
description: Finds where things are implemented in this codebase and explains how they connect. Use for "where is", "how does", and "what calls" questions.
tools: Read, Grep, Glob
model: haiku
---

You answer questions about this codebase by searching it.

&lt;span class="k"&gt;- &lt;/span&gt;Start with Grep/Glob, then read only the relevant parts of files.
&lt;span class="k"&gt;- &lt;/span&gt;Answer with file paths and line numbers.
&lt;span class="k"&gt;- &lt;/span&gt;Finish with a 3-5 line explanation of how the pieces connect.

Never guess a path. If you did not find it, say what you searched for.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Recent Claude Code versions also ship built-in agents for exploration and planning, so check what you already have before duplicating it. A project-specific explorer is still worth it when you want to point it at your own conventions ("API handlers live in &lt;code&gt;src/routes&lt;/code&gt;, never in &lt;code&gt;src/lib&lt;/code&gt;").&lt;/p&gt;

&lt;h2&gt;
  
  
  Things that bite people
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Subagents can't spawn other subagents.&lt;/strong&gt; Orchestration happens in the main session. Design agents as leaves, not managers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;They start with a fresh context.&lt;/strong&gt; The agent doesn't see your conversation, so the delegation message has to include what matters (file names, the error, what you already tried). Write system prompts that tell the agent to find context itself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Long reports defeat the purpose.&lt;/strong&gt; If an agent returns 300 lines, you've moved the noise, not removed it. Put an output limit in every prompt.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Descriptions are routing rules.&lt;/strong&gt; If an agent never triggers, rewrite its &lt;code&gt;description&lt;/code&gt; before touching anything else.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tool lists are your safety boundary.&lt;/strong&gt; Review agents should not have &lt;code&gt;Edit&lt;/code&gt;/&lt;code&gt;Write&lt;/code&gt;. Combine that with hooks for anything destructive.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;code&gt;mkdir -p .claude/agents&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Save one of the files above as &lt;code&gt;.claude/agents/code-reviewer.md&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Make a small change and ask: &lt;em&gt;"Use the code-reviewer subagent on this change."&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;/agents&lt;/code&gt; to see it listed and tweak it.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Start with one reviewer and one test runner. Add more only when you notice the same kind of task polluting your main session.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Free resources:&lt;/strong&gt; I keep a free collection of Claude Code skills and hooks here: &lt;a href="https://github.com/MrNapier89/claude-code-skills-hooks" rel="noopener noreferrer"&gt;github.com/MrNapier89/claude-code-skills-hooks&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Disclosure:&lt;/strong&gt; if you want a ready-made set, I sell a pack of 12 subagents (planner, code reviewer, debugger, QA and more) with install notes: &lt;a href="https://napier4.gumroad.com/l/claude-code-subagent-team" rel="noopener noreferrer"&gt;Claude Code Agents Pack&lt;/a&gt; ($24). It's my product; everything in this post works without it.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>productivity</category>
      <category>programming</category>
    </item>
    <item>
      <title>Claude Code Hooks: 3 Examples That Stop the Agent From Breaking Things</title>
      <dc:creator>Jack Napier</dc:creator>
      <pubDate>Thu, 26 Nov 2026 15:03:32 +0000</pubDate>
      <link>https://dev.to/mrnapier/claude-code-hooks-3-examples-that-stop-the-agent-from-breaking-things-faa</link>
      <guid>https://dev.to/mrnapier/claude-code-hooks-3-examples-that-stop-the-agent-from-breaking-things-faa</guid>
      <description>&lt;p&gt;Claude Code is great until it runs &lt;code&gt;git reset --hard&lt;/code&gt; on an afternoon of work, or "helpfully" edits your &lt;code&gt;.env&lt;/code&gt;. Hooks fix that. They're shell commands Claude Code runs at fixed points (before a tool call, after an edit, when it stops), and they can block, allow or ask.&lt;/p&gt;

&lt;p&gt;Here are three hooks I put in every project. All of them are free on GitHub (link at the end).&lt;/p&gt;

&lt;h2&gt;
  
  
  How a hook works in 30 seconds
&lt;/h2&gt;

&lt;p&gt;Hooks live in &lt;code&gt;.claude/settings.json&lt;/code&gt;. Each one gets JSON on stdin describing what Claude is about to do. For a &lt;code&gt;PreToolUse&lt;/code&gt; hook, you answer with a decision:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"hookSpecificOutput"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"hookEventName"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"PreToolUse"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"permissionDecision"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deny"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"permissionDecisionReason"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"why"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;deny&lt;/code&gt; blocks the call and shows Claude the reason. &lt;code&gt;ask&lt;/code&gt; hands the decision to you. Exit 0 with no output lets it through.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Block dangerous shell commands
&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;PreToolUse&lt;/code&gt; hook on the &lt;code&gt;Bash&lt;/code&gt; tool. It checks the command against two lists of regexes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;deny&lt;/strong&gt;: &lt;code&gt;rm -rf /&lt;/code&gt; or &lt;code&gt;~&lt;/code&gt;, force push, &lt;code&gt;git reset --hard&lt;/code&gt;, &lt;code&gt;git clean -f&lt;/code&gt;, &lt;code&gt;mkfs&lt;/code&gt;, &lt;code&gt;dd of=/dev/…&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ask&lt;/strong&gt;: &lt;code&gt;git push&lt;/code&gt;, &lt;code&gt;sudo&lt;/code&gt;, &lt;code&gt;curl … | sh&lt;/code&gt;, &lt;code&gt;DROP TABLE&lt;/code&gt;, package publishing
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"matcher"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Bash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nl"&gt;"hooks"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"python \"${CLAUDE_PROJECT_DIR}/.claude/hooks/block_dangerous_bash.py\""&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test it without Claude:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'{"tool_input":{"command":"rm -rf /"}}'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; python .claude/hooks/block_dangerous_bash.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Protect files Claude should never edit
&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;PreToolUse&lt;/code&gt; hook on &lt;code&gt;Edit|Write|MultiEdit&lt;/code&gt;. It denies any write to &lt;code&gt;.env*&lt;/code&gt;, &lt;code&gt;*.pem&lt;/code&gt;, &lt;code&gt;*.key&lt;/code&gt;, credentials files, lockfiles and &lt;code&gt;.git/&lt;/code&gt;. You can add your own globs in &lt;code&gt;.claude/protected.txt&lt;/code&gt;, one per line.&lt;/p&gt;

&lt;p&gt;Lockfiles are on the list on purpose: when Claude edits &lt;code&gt;package-lock.json&lt;/code&gt; by hand, you get installs that work on your machine and nowhere else.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Auto-format after every edit
&lt;/h2&gt;

&lt;p&gt;A &lt;code&gt;PostToolUse&lt;/code&gt; hook on &lt;code&gt;Edit|Write|MultiEdit&lt;/code&gt;. It looks at the file extension and runs the formatter if it's installed: prettier for JS/TS/CSS/JSON/MD, ruff or black for Python, gofmt, rustfmt. No formatter installed means it quietly does nothing.&lt;/p&gt;

&lt;p&gt;The point isn't style. Claude reads the formatted file on its next turn, so diffs stay small and it stops "fixing" whitespace.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hooks vs skills
&lt;/h2&gt;

&lt;p&gt;People mix these up. A &lt;strong&gt;skill&lt;/strong&gt; is instructions Claude chooses to load when a task matches its description. A &lt;strong&gt;hook&lt;/strong&gt; is code that always runs, whether Claude wants it or not. Use skills for &lt;em&gt;how to do a task well&lt;/em&gt;, hooks for &lt;em&gt;rules that must never be broken&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Get them
&lt;/h2&gt;

&lt;p&gt;All three hooks, plus three skills (clean commits, PR descriptions, codebase explainer), are MIT on GitHub: &lt;a href="https://github.com/MrNapier89/claude-code-skills-hooks" rel="noopener noreferrer"&gt;https://github.com/MrNapier89/claude-code-skills-hooks&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Copy the &lt;code&gt;.claude/&lt;/code&gt; folder into your repo and they work.&lt;/p&gt;

&lt;p&gt;If you want more, I sell a &lt;a href="https://napier4.gumroad.com/l/claude-code-hooks-cookbook" rel="noopener noreferrer"&gt;10-hook pack&lt;/a&gt; with a secret guard on prompts, "run the tests before you say done", lint feedback, an audit log and desktop notifications, plus a guide. Disclosure: that's my product.&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>ai</category>
      <category>productivity</category>
      <category>python</category>
    </item>
  </channel>
</rss>
