# Claude Code Tips: A Short Course From a Real Repo

> Thirteen Claude Code lessons from a real repo: CLAUDE.md, permissions, skills, hooks, subagents, tokens, MCP, headless runs and settings, doc-checked.

URL: https://www.matthewswong.com/en/learn/claude-code-tips/

Reviewed on 13 October 2026 · Checked against Claude Code v2.1.301 · By Matthews Wong (https://www.matthewswong.com/en/about/)

> Claude Code is Anthropic's agentic coding tool for the terminal. These thirteen lessons show how one real repository steers it: a CLAUDE.md that sets the rules, permissions that remove friction, skills that teach house style, hooks that check every edit, subagents that work in parallel without collisions, habits that keep context small, MCP servers, headless runs, parallel worktrees and safe rewinds.

Free, no sign-up, no certificate. Built from the setup that runs this website.

## What you will be able to do

- Write a CLAUDE.md and settings that steer Claude Code without slowing you down.
- Teach project rules once with skills, and enforce them automatically with hooks.
- Run subagents in parallel safely, and keep context and token use under control.

## Who it is for

Developers who already use Claude Code for small tasks and want it to follow their project's rules on bigger ones.

## Before you start

- Claude Code installed and signed in, and a git repository to practise in.
- Basic terminal and JSON familiarity.

## Lessons

1. [CLAUDE.md File Example: Global, Project and Local Layers](https://www.matthewswong.com/en/learn/claude-code-tips/claude-md-file-example/): A real CLAUDE.md file example: the managed, user, project and local layers, how they load, @imports, and what belongs in a skill or a hook instead.
2. [Claude Code settings.json Example: Allow, Ask and Deny Rules](https://www.matthewswong.com/en/learn/claude-code-tips/claude-code-permissions-settings/): A real Claude Code settings.json example: which settings file wins, how allow, ask and deny rules match, why deny wins, and how to keep .env out of reach.
3. [Claude Code Skills Examples: Write One That Actually Triggers](https://www.matthewswong.com/en/learn/claude-code-tips/claude-code-skills-examples/): Claude Code skills examples from a real repo: SKILL.md frontmatter, why the description decides triggering, what loads when, and skills vs CLAUDE.md.
4. [Claude Code Hooks Examples: Guardrails That Always Run](https://www.matthewswong.com/en/learn/claude-code-tips/claude-code-hooks-examples/): Claude Code hooks examples from a real repo: events, matchers, the JSON on stdin, exit codes and JSON output, and when a hook should block or only advise.
5. [Claude Code Subagents Examples: When to Delegate a Task](https://www.matthewswong.com/en/learn/claude-code-tips/claude-code-subagents-examples/): Claude Code subagents examples from a real repo: what a subagent sees, the name, description and tools fields, when to delegate, and safe parallel fan-out.
6. [Claude Code Tips to Save Tokens: Context, Compaction, Scope](https://www.matthewswong.com/en/learn/claude-code-tips/save-tokens-claude-code/): Claude Code tips to save tokens: read /context, compact or clear at the right time, scope reads, load skills on demand and keep exploration in subagents.
7. [Add an MCP Server to Claude Code: Scopes and Permissions](https://www.matthewswong.com/en/learn/claude-code-tips/add-mcp-server-claude-code/): Add an MCP server to Claude Code with claude mcp add: http vs stdio, local, project and user scope, .mcp.json, MCP permission rules, and the risks.
8. [Claude Code Headless Mode: claude -p With a Pass/Fail Gate](https://www.matthewswong.com/en/learn/claude-code-tips/claude-code-headless-pass-fail-gate/): Run Claude Code headless with claude -p: output formats, permission modes, allowedTools and dontAsk, plus a verification gate script that closes the loop.
9. [Claude Code Worktrees: Run Parallel Sessions Without Collisions](https://www.matthewswong.com/en/learn/claude-code-tips/claude-code-git-worktrees-parallel-sessions/): Run parallel Claude Code sessions with git worktrees: what claude --worktree creates, what it isolates, what stays shared, cleanup, and subagent isolation.
10. [Claude Code Rewind and Plan Mode: Undo Risky Changes](https://www.matthewswong.com/en/learn/claude-code-tips/claude-code-rewind-plan-mode-safe-changes/): How to undo Claude Code changes: what /rewind restores and what it cannot, how plan mode holds edits for review, and why git stays your real safety net.
11. [Claude Code Settings Scopes: Which File Wins, What Is Shared](https://www.matthewswong.com/en/learn/claude-code-tips/claude-code-settings-scopes-precedence/): Claude Code settings scopes explained from a real repo: user, project, local and managed files, which one wins, what git shares, and how lists merge.
12. [Where to Put Instructions in Claude Code: A Decision Guide](https://www.matthewswong.com/en/learn/claude-code-tips/where-to-put-instructions-claude-code/): Where to put instructions in Claude Code: CLAUDE.md, rules, skills, custom commands, hooks or auto memory. A decision table built on a real repo.
13. [Claude Code Git Workflow: Safe Commits, PRs and Push Rules](https://www.matthewswong.com/en/learn/claude-code-tips/claude-code-git-workflow-safe-commits/): A Claude Code git workflow that keeps main clean: commit and PR attribution, feature branches, and a deny rule or hook that stops git push and force-push.

---

- HTML version: https://www.matthewswong.com/en/learn/claude-code-tips/
- Bahasa Indonesia: https://www.matthewswong.com/id/learn/claude-code-tips/
- Site index for agents: https://www.matthewswong.com/llms.txt
- Sitemap: https://www.matthewswong.com/sitemap.xml
- API description (OpenAPI): https://www.matthewswong.com/openapi.json
