Claude Code cheatsheet

Claude Code: Configuration files

8 common Claude Code tasks.

Write a CLAUDE.md

Project memory that Claude reads at the start of every session: commands, conventions and gotchas.

# Project guide

## Commands
- Build: `npm run build`
- Test: `npm test`

## Conventions
- TypeScript strict mode; prefer named exports.
- Run `npm run lint` before committing.

Allow and deny tools

In .claude/settings.json, allow safe commands without prompts and block sensitive files.

{
  "permissions": {
    "allow": ["Bash(npm run test:*)", "Bash(git diff:*)"],
    "deny": ["Read(./.env)", "Read(./secrets/**)"]
  }
}

Run a command after edits

A hook runs your command automatically at an event, here after Claude edits or writes a file.

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [{ "type": "command", "command": "npm run format" }]
      }
    ]
  }
}

Create a slash command

A Markdown file in .claude/commands becomes a command. This one is /review-pr, and $ARGUMENTS holds what you type after it.

# .claude/commands/review-pr.md
Review pull request $ARGUMENTS for bugs, missing tests and unclear names. Be concise.

Define a subagent

A Markdown file with front matter in .claude/agents defines a specialist Claude can delegate to.

---
name: test-runner
description: Runs the test suite and reports failures. Use after code changes.
tools: Bash, Read
---
Run the tests, then summarize each failure with the file and line.

Add a remote MCP server

Connect Claude Code to a remote MCP server by URL.

claude mcp add --transport http notion https://mcp.notion.com/mcp

Add a local MCP server

Run a local MCP server as a subprocess. Everything after -- is the command that starts it.

claude mcp add --transport stdio my-server --env API_KEY=your-api-key -- npx -y my-mcp-server

List MCP servers

Show the configured MCP servers.

claude mcp list

Was this page helpful?