Skip to content

Skill Patterns for Common Workflows

Ready-made patterns for code review, test writing, docs, migration, and debugging. Adapt to your stack instead of starting from scratch.

Five skill patterns you can steal and adapt to your stack, plus the advanced mechanics (dynamic context injection, fork context, subagent execution) that make skills genuinely powerful instead of just convenient.

Quick Refresher: Two Flavors

Reference skills provide knowledge Claude Code applies inline. API conventions, style guides, domain terminology. No explicit steps, just context that shapes behavior.

Task skills are step-by-step checklists. You invoke them with /skill-name, Claude Code follows the procedure. All five patterns below are task skills.

Pattern 1: Code Review

---
name: review
description: Review code for bugs, style, and performance issues
---
## Review checklist
1. Check for logic errors and edge cases
2. Verify error handling covers failure modes
3. Look for performance issues (N+1 queries, unnecessary re-renders, missing indexes)
4. Confirm naming follows project conventions in CLAUDE.md
5. Flag any security concerns (unsanitized input, exposed secrets, missing auth checks)
 
Report findings grouped by severity: critical, warning, suggestion.
Include file paths and line numbers for every finding.

Simplest useful skill. No dynamic context, no subagents. Just a consistent checklist. Same results every time.

Pattern 2: Test Writing

---
name: write-tests
description: Generate tests for a module following project conventions
---
## Instructions
1. Read the target file and all files it imports
2. Identify every public function and exported component
3. For each one, write tests covering: happy path, edge cases, error conditions
4. Follow the testing patterns already established in the project (check existing test files first)
5. Use the same assertion library and test runner the project already uses
6. Run the tests to confirm they pass before finishing

Step 4 is the key. Telling Claude Code to check existing tests first means new tests match your team's patterns automatically. You never need to spell out "use vitest" or "use jest" in the skill itself. The codebase is the reference.

Pattern 3: Documentation

---
name: document
description: Generate documentation for a module or API endpoint
---
## Instructions
1. Read the source code thoroughly, including types and interfaces
2. Write a summary explaining what the module does and when you would use it
3. Document every public function with parameters, return types, and a usage example
4. If there are side effects or prerequisites, call them out explicitly
5. Add a "Common Pitfalls" section if the code has non-obvious behavior
6. Write for a developer who has never seen this code before

Pattern 4: Migration

---
name: migrate
description: Migrate code from one pattern or dependency to another
---
## Instructions
1. Find all files using the old pattern with Grep
2. For each file, apply the new pattern while preserving existing behavior
3. Run the build after every batch of changes to catch regressions early
4. Run existing tests to confirm nothing broke
5. If tests fail, fix the migration (not the tests) unless the test was asserting old behavior
6. Summarize what changed and what needs manual review

This pattern shines when you fill in the specifics. Swap out "old pattern" and "new pattern" for your actual migration. REST to tRPC. Class components to hooks. Moment to date-fns. Make it concrete and this becomes a one-command migration tool. I've seen teams cut multi-day migrations down to hours this way.

Pattern 5: Debugging with Dynamic Context

Now for the stuff that separates basic skills from powerful ones. The !backtick syntax injects live data into a skill. Command runs first, output replaces the placeholder, Claude Code sees the full context.

---
name: debug-pr
description: Diagnose failing CI on the current pull request
context: fork
agent: Explore
allowed-tools: Bash(gh *), Bash(npm test *)
---
## Current state
- PR diff: !`gh pr diff`
- CI status: !`gh pr checks`
- Recent comments: !`gh pr view --comments`
- Changed files: !`gh pr diff --name-only`
 
## Your task
Analyze the failing checks on this pull request.
1. Identify which checks failed and why
2. Cross-reference failures with the changed files
3. Suggest specific fixes with file paths and code changes
4. If a failure is flaky or unrelated to this PR, say so explicitly

Notice what's happening here. The !backtick commands pull in real data from GitHub before Claude Code starts working. context: fork runs this in an isolated subagent with its own context window, so your main conversation stays clean. And allowed-tools restricts the subagent to only gh commands and npm test. Safety guardrail. A debugging skill that accidentally modifies your code is worse than no skill at all.

The PR Summary Pattern

Combines dynamic context with fork execution for PR summaries:

---
name: pr-summary
description: Summarize changes in a pull request
context: fork
agent: Explore
allowed-tools: Bash(gh *)
---
## Pull request context
- PR diff: !`gh pr diff`
- PR comments: !`gh pr view --comments`
- Changed files: !`gh pr diff --name-only`
 
## Your task
Summarize this pull request in a way that helps a reviewer understand what changed and why. Group changes by area. Highlight anything that looks risky or unusual.

agent: Explore means a subagent optimized for reading and understanding code, not modifying it. Use Plan for architecture-focused tasks, or leave the field out for general-purpose execution.

Built-in Skills Worth Studying

/simplify spawns three review agents in parallel (code reuse, quality, efficiency). /batch orchestrates large-scale parallel changes. You don't need to build these yourself, but studying their structure teaches you a lot about skill composition.

Try It

Create a review skill for your project at .claude/skills/review.md. Start with the code review pattern above, then customize. Add your team's conventions. Reference your linter rules. The patterns you always check for in your stack. Run /review on a recently changed file.

Then try dynamic context. Create a PR review skill that pulls in the diff with !backtickgh pr diffbacktick. Run it on an open pull request. Watch the subagent work through changes independently while your main session stays clean.

Simple skills are checklists in a file. Powerful skills combine dynamic context injection (live data), fork context (isolation), and allowed-tools (safety). Start simple and layer in the advanced stuff when a basic checklist isn't cutting it.

Mastering Claude Code

Lesson 48 of 70