claude-code-best-practice
```markdown
What this skill does
```markdown
---
name: claude-code-best-practice
description: Master Claude Code features, patterns, and agentic workflows using community best practices
triggers:
- "how do I use Claude Code effectively"
- "what are Claude Code best practices"
- "set up subagents in Claude Code"
- "create a slash command for Claude"
- "configure CLAUDE.md memory"
- "orchestrate agents with Claude Code"
- "use skills in Claude Code"
- "vibe coding with Claude"
---
# Claude Code Best Practice
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
Community-curated best practices and patterns for [Claude Code](https://code.claude.com) — Anthropic's agentic coding tool. Covers subagents, commands, skills, memory, hooks, MCP servers, orchestration workflows, and advanced features like Auto Mode, Agent Teams, and Scheduled Tasks.
---
## What Claude Code Is
Claude Code is an AI coding agent that runs in your terminal (and web/IDE). It can read, write, and execute code; browse the web; call tools; and spawn subagents. Configuration lives in `.claude/` inside your project.
```
.claude/
├── settings.json # permissions, model, output style
├── agents/ # subagent definitions
├── commands/ # slash command templates
├── skills/ # skill bundles (SKILL.md)
├── hooks/ # event-driven scripts
└── rules/ # scoped memory rules
CLAUDE.md # root memory file (always loaded)
.mcp.json # MCP server connections
```
---
## Installation & Setup
```bash
# Install Claude Code CLI
npm install -g @anthropic/claude-code
# Authenticate
claude auth login
# Launch interactive session
claude
# Launch with auto-permissions (no prompts)
claude --permission-mode auto
# Launch headless (pipe a prompt)
claude -p "Refactor src/utils.ts to use async/await"
```
---
## Core Concepts
### Memory — `CLAUDE.md`
The root memory file is always injected into context. Use it to define project conventions, tech stack, and rules.
```markdown
# CLAUDE.md
## Project
TypeScript monorepo. Node 20. pnpm workspaces.
## Rules
- Never commit directly to `main`
- All new files need a unit test
- Use `zod` for runtime validation
## @imports
@.claude/rules/typescript.md
@.claude/rules/testing.md
```
Import scoped rule files with `@path`:
```bash
# .claude/rules/typescript.md
- Prefer `type` over `interface` for unions
- Enable `strict: true` in tsconfig
```
Auto memory writes: Claude can append learnings to `CLAUDE.md` automatically when you ask it to "remember this".
---
### Subagents — `.claude/agents/<name>.md`
Subagents run in a **fresh isolated context** with their own tools, permissions, model, and identity.
```markdown
<!-- .claude/agents/code-reviewer.md -->
---
name: code-reviewer
description: Reviews PRs for bugs, style issues, and security vulnerabilities
model: claude-opus-4-5
tools:
- read_file
- search_code
permissions:
- read
---
You are a senior code reviewer. When invoked:
1. Read the diff provided
2. Check for security issues (injections, secrets, unvalidated input)
3. Flag style violations against CLAUDE.md rules
4. Suggest improvements with code examples
5. Return a structured review with LGTM / REQUEST_CHANGES verdict
```
Invoke a subagent from a command or prompt:
```
/review-pr diff: <paste diff here>
```
Or spawn programmatically in headless mode:
```bash
claude -p "Use the code-reviewer agent to review the changes in the last commit" \
--agent code-reviewer
```
---
### Commands — `.claude/commands/<name>.md`
Commands inject a **prompt template** into the current context. They're simple, fast, and user-invoked with `/`.
```markdown
<!-- .claude/commands/fix-types.md -->
---
description: Fix all TypeScript type errors in the current file
---
Look at the currently open file. Run `tsc --noEmit` scoped to this file.
For each type error:
1. Explain what's wrong in one sentence
2. Apply the minimal fix
3. Re-run tsc to confirm it's resolved
Do not change logic — only fix types.
```
Usage in Claude Code:
```
/fix-types
```
---
### Skills — `.claude/skills/<name>/SKILL.md`
Skills are **discoverable knowledge bundles** with frontmatter triggers. Claude auto-loads them when a trigger phrase is detected.
```
.claude/skills/
└── openapi-codegen/
└── SKILL.md
```
```markdown
<!-- .claude/skills/openapi-codegen/SKILL.md -->
---
name: openapi-codegen
description: Generate TypeScript clients from OpenAPI specs
triggers:
- "generate API client"
- "create types from OpenAPI"
- "scaffold from swagger"
---
# OpenAPI Codegen Skill
Use `openapi-typescript` to generate types:
```bash
npx openapi-typescript ./openapi.yaml -o src/types/api.d.ts
```
Then use `openapi-fetch` for type-safe calls:
```typescript
import createClient from "openapi-fetch";
import type { paths } from "./types/api.d.ts";
const client = createClient<paths>({ baseUrl: process.env.API_BASE_URL });
const { data, error } = await client.GET("/users/{id}", {
params: { path: { id: "123" } },
});
```
```
---
### Settings — `.claude/settings.json`
```json
{
"model": "claude-opus-4-5",
"permissionMode": "auto",
"outputStyle": "minimal",
"fastMode": true,
"statusLine": {
"show": true,
"items": ["context", "model", "cost", "session"]
},
"permissions": {
"allow": ["read", "write", "execute"],
"deny": ["network:external"]
},
"keybindings": {
"voice": "ctrl+shift+v"
}
}
```
Global settings live in `~/.claude/settings.json`. Project settings override globals.
---
### MCP Servers — `.mcp.json`
Connect external tools, databases, and APIs via the Model Context Protocol.
```json
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "${DATABASE_URL}"
}
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
},
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"]
}
}
}
```
---
### Hooks — `.claude/hooks/`
Hooks are scripts that fire on Claude Code events **outside the agentic loop**.
```json
// .claude/settings.json
{
"hooks": {
"postToolUse": ".claude/hooks/post-tool.sh",
"onSessionEnd": ".claude/hooks/summarize.sh",
"preFileWrite": ".claude/hooks/lint-check.sh"
}
}
```
```bash
#!/bin/bash
# .claude/hooks/lint-check.sh
# Runs before Claude writes a file — blocks if lint fails
FILE=$CLAUDE_HOOK_FILE
npx eslint "$FILE" --max-warnings 0
exit $?
```
---
## Orchestration Workflow Pattern
The recommended pattern: **Command → Agent → Skill**
```
User types /weather-orchestrator city=London
│
▼
┌─────────────────┐
│ Command │ Parses args, sets up context
│ weather- │ Invokes subagent with task
│ orchestrator.md │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Subagent │ Isolated context, specialized model
│ weather- │ Uses skills for domain knowledge
│ fetcher.md │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Skill │ Auto-loaded by trigger phrase
│ weather-api/ │ Provides API patterns + examples
│ SKILL.md │
└─────────────────┘
```
```markdown
<!-- .claude/commands/weather-orchestrator.md -->
---
description: Fetch and display weather for a city
args:
city: string
---
Fetch weather for {{city}}.
Use the weather-fetcher subagent.
Format the result as a concise summary with temperature, conditions, and 3-day forecast.
```
---
## Advanced Features
### Agent Teams (parallel agents)
```bash
# Enable via env var
export CLAUDE_AGENT_TEAMS=true
claude
```
```
/team-task
agent-1: Refactor the auth module
agent-2: Write tests for the auth module
agent-3: Update the auth documentation
```
Agents share Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.