deliberate.codes

Weblog of Marco N. - a software guy in data. I build with AI.

Claude Code cheat sheet

For me, one of the most important events in 2025 was the quiet release of Claude Code.

Anthropic didn’t even give it a proper launch. They mentioned it as a secondary item in their post announcing Claude 3.7 Sonnet:

“Claude Code is an active collaborator that can search and read code, edit files, write and run tests, commit and push code to GitHub, and use command line tools—keeping you in the loop at every step.”

In short: a coding agent that writes code, executes it, inspects the results, and iterates until it reaches a desired state. Claude Code offers many ways to customize its behavior. This guide covers six key concepts: CLAUDE.md, slash commands, rules, configuration, sub-agents, and skills.

CLAUDE.md#

CLAUDE.md is a special file that Claude automatically loads into context at the start of every conversation. Use it to document project conventions, build commands, code style, and repository etiquette.

Locations#

Claude Code reads CLAUDE.md files from multiple locations, in order of precedence:

LocationScopeGit
./CLAUDE.mdProject rootCommit and share with team
./CLAUDE.local.mdProject rootGitignore for personal config
../CLAUDE.mdParent directoriesUseful for monorepos
~/.claude/CLAUDE.mdUser homePersonal defaults across all projects

Press # during a session to add instructions directly to your CLAUDE.md.

Example#

# Build Commands

- npm run build: Build the project
- npm run test: Run tests

# Code Style

- Use ES modules (import/export), not CommonJS
- Destructure imports when possible

# Workflow

- Run typecheck after making code changes
- Prefer single tests over full suite for performance

Slash commands#

Slash Commands capture repeated prompts as reusable templates stored in markdown files. They appear in the autocomplete menu when you type /.

Locations#

  • Project commands: .claude/commands/ — available to the current project
  • Personal commands: ~/.claude/commands/ — available across all projects

Example#

Create .claude/commands/fix-issue.md:

---
description: Analyze and fix a GitHub issue
allowed-tools: Read, Write, Bash
---

Analyze and fix GitHub issue: $ARGUMENTS

Steps:

1. Use `gh issue view $ARGUMENTS` to get details
2. Search the codebase for relevant files
3. Implement the fix
4. Write tests to verify
5. Run linting and type checking

Usage: /fix-issue 1234

The $ARGUMENTS keyword passes everything after the command name into the prompt.

Rules#

Rules let you organize project instructions into multiple focused files instead of one large CLAUDE.md. All markdown files in .claude/rules/ are automatically loaded into context at startup.

Locations#

  • Project rules: .claude/rules/ — shared with team via git
  • User rules: ~/.claude/rules/ — personal rules across all projects

User-level rules load first; project rules take higher priority.

Structure#

.claude/rules/
├── code-style.md      # Formatting conventions
├── testing.md         # Test requirements
├── security.md        # Security checklist
└── frontend/
    ├── react.md       # React patterns
    └── styling.md     # CSS conventions

Conditional Rules#

Scope rules to specific files using YAML frontmatter with the paths field:

---
paths: src/api/**/*.ts
---

# API Development Rules

- All endpoints must validate input
- Use standard error response format
- Include OpenAPI documentation comments

This rule only activates when Claude works on files matching src/api/**/*.ts. Rules without a paths field apply to all files.

Example#

Create .claude/rules/testing.md:

---
paths: **/*.test.ts
---

# Testing Standards

- Use descriptive test names: "should [action] when [condition]"
- One assertion per test when possible
- Mock external dependencies
- Include edge cases
- Run tests before committing

Configuration#

Configuration controls permissions, environment variables, and behavioral settings via settings.json. This determines what Claude can do without asking for confirmation.

Locations#

FileScope
~/.claude/settings.jsonUser-level defaults
.claude/settings.jsonProject-level, shared via git
.claude/settings.local.jsonProject-level, gitignored

Project settings override user settings.

Example#

{
  "permissions": {
    "allow": [
      "Bash(npm run lint)",
      "Bash(npm run test:*)",
      "Read(./src/**)",
      "Write(./src/**)"
    ],
    "deny": [
      "Bash(rm -rf *)",
      "Bash(git push:*)",
      "Read(./.env)",
      "Read(./secrets/**)"
    ]
  }
}

Permissions use glob patterns. Bash(npm run test:*) matches npm run test:unit, npm run test:integration, etc. Deny rules take precedence over allow rules.

Sub-agents#

Sub-agents are specialized AI assistants with their own context windows and tool permissions. They handle specific tasks without polluting your main conversation.

Locations#

  • Project agents: .claude/agents/
  • Personal agents: ~/.claude/agents/

Configuration#

Sub-agent files use YAML frontmatter to define behavior:

---
name: code-reviewer
description: Reviews code for bugs and best practices. Use proactively after implementing features.
tools: Read, Grep, Glob
model: sonnet
---

You are a code reviewer specializing in TypeScript and React.

When invoked:

1. Analyze the code structure and patterns
2. Check for potential bugs and edge cases
3. Verify error handling
4. Review naming conventions
5. Provide actionable feedback

Usage#

  • Automatic: Claude delegates based on task context when descriptions include phrases like “use proactively”
  • Explicit: Use the code-reviewer to check my recent changes
  • Command: /agents to create and manage sub-agents interactively

Built-in sub-agents include Explore (read-only codebase exploration) and a general-purpose agent for multi-step tasks.

Skills#

Skills are directories containing a SKILL.md file plus supporting resources. Unlike sub-agents, Skills use progressive disclosure: Claude loads only the metadata at startup, then reads the full skill when relevant.

Structure#

my-skill/
├── SKILL.md          # Required: name, description, instructions
├── reference.md      # Optional: additional context
├── templates/        # Optional: supporting files
└── scripts/          # Optional: executable code

Example SKILL.md#

---
name: api-integration
description: Guides for integrating with our internal APIs
---

# API Integration Skill

When building API integrations:

1. Read `reference.md` for endpoint specifications
2. Use templates in `templates/` for request/response patterns
3. Run `scripts/validate.py` to check payloads

## Authentication

All requests require Bearer tokens. See `reference.md` for token generation.

## Rate limits

- 100 requests/minute for standard endpoints
- 10 requests/minute for batch operations

Key Differences from Sub-agents#

AspectSub-agentsSkills
InvocationDelegated tasks with separate contextAuto-loaded based on relevance
StructureSingle markdown fileDirectory with supporting files
ContextOwn context windowMain conversation context
Use caseIsolated specialized tasksDomain knowledge and workflows

Summary#

ConceptPurposeLocation
CLAUDE.mdProject context always loadedRepo root, parent dirs, home
Slash CommandsReusable prompt templates.claude/commands/
RulesModular instructions with path targeting.claude/rules/
ConfigurationPermission guardrailssettings.json
Sub-agentsSpecialized task handlers.claude/agents/
SkillsProgressive domain knowledgeSkill directories with SKILL.md

Start with CLAUDE.md for basic project context. Add Rules when CLAUDE.md grows unwieldy. Use Slash Commands for repeated workflows. Configure permissions in settings.json. Use Sub-agents for isolated tasks. Build Skills for complex domain knowledge.