If you’ve already read my CLAUDE.md introduction article and know how to use # for quick memory and /init to build your project’s brain, this article is your next step toward mastering Claude Code.
This piece continues our deep dive into CLAUDE.md’s power, but it’s not a detailed step-by-step tutorial. Instead, think of it as a battle-tested cheat sheet. I’ll quickly introduce 10 advanced techniques to show you “what else CLAUDE.md can do.” These techniques will make your Claude Code smarter and more aligned with your workflow.
Who is this for?
- Developers who’ve used Claude Code a few times and want to improve
- Pragmatists seeking a quick overview of
CLAUDE.md’s capabilities - Anyone needing a cheat sheet to remind themselves to practice these
CLAUDE.mdtechniques (yes, that’s me)
Let’s dive in ʕ •ᴥ•ʔ
Part One: File Management and Memory Optimization#
1. Flexible Initialization: Advanced /init Usage#
As mentioned in my previous article, /init is your first step when starting a new Claude Code project, i.e., it generates your CLAUDE.md file. The /init command actually performs a deep scan of every file in your project, analyzing folder structure, libraries/packages used, and existing documentation to generate a comprehensive CLAUDE.md file.
Here’s the interesting part: this file is “alive.” You can re-run /init anytime to update your project’s brain.
Why is this useful? When your project architecture changes (new modules, refactored folders), re-running /init helps Claude grasp the latest state, preventing it from working with outdated information.
The usage is straightforward. You just run this command in your terminal whenever needed:
# After project refactoring, re-scan and update memory
/init
Claude will prompt you about overwriting the existing CLAUDE.md, and you can choose to merge or replace it.
2. Hierarchical File Structure: Savior for Large Projects#
Create independent
CLAUDE.mdfiles in subdirectories, allowing Claude to load relevant rules only when working on specific modules
Why is this useful? As projects grow, the main CLAUDE.md file at the root directory often becomes massive (potentially thousands of lines long!). This file loads into Claude Code’s context (memory) at the start of every conversation. When it reaches thousands of lines, it not only consumes expensive tokens but also causes performance degradation and potentially worse code quality as the model processes vast amounts of irrelevant information.
Therefore, we can create independent CLAUDE.md files for different subdirectories (i.e., building a “hierarchical file structure”). These subdirectory CLAUDE.md files store detailed rules and context specific to that component or functional module.
- Claude Code won’t load all subdirectory
CLAUDE.mdfiles at startup. It only reads them when actually working on tasks related to that subdirectory - This approach ensures Claude reads only the most relevant rules, avoiding loading unnecessary information in every conversation
Simple example:
Project Root/
├── CLAUDE.md (Global rules: Git workflow)
├── backend/
│ └── CLAUDE.md (Backend rules: Python, FastAPI)
└── frontend/
└── CLAUDE.md (Frontend rules: React, Tailwind)
When working in the frontend/ folder, Claude automatically loads that directory’s CLAUDE.md without reading backend (backend/) files (no interference from backend rules).
Reference: Anthropic’s official tip on managing large CLAUDE.md files
3. Precise References: Use @ to Tell Claude Where to Look#
The
@symbol is a powerful Claude Code feature that lets you directly reference specific files in your prompts orCLAUDE.md
Why is this useful? No need to paste entire documents into CLAUDE.md or let Claude search endlessly without finding the key points. This prevents the AI from processing massive amounts of irrelevant information, reducing performance degradation and token consumption. Think of it like recording knowledge in different books: when you need specific knowledge, you reference that particular book rather than cramming everything into one billion-word tome!
Simple example:
You can use @ directly in the terminal or write it in CLAUDE.md. For instance, in the terminal:
Please modify the user.py API endpoint according to the specifications in @docs/api-spec.md
Claude will directly read the api-spec.md file content, ensuring modifications match the latest spec.
You can also use @ in CLAUDE.md to reference specific document information:
## Database Schema
Please refer to the field definitions in @docs/database-schema.md

@ symbol in Claude Code’s terminal and start typing a filenameClaude Code displays an autocomplete list of file options
helping you quickly and accurately specify the file path
Part Two: AI Behavior Guidance and Workflow#
4. Define Coding Style#
Set explicit coding standards (Style Guide) in
CLAUDE.md, such as indentation, naming conventions, comment requirements, etc.
Unify team coding style and ensure code quality
Why is this useful? Large Language Models (LLMs) are inherently stateless. Without explicit instructions, Claude’s default coding style likely won’t match your or your team’s habits (e.g., using camelCase instead of snake_case naming). Clear rules ensure code consistency and reduce Code Review back-and-forth.
Simple CLAUDE.md example:
## Coding Style
- Python uses 4-space indentation
- Variable naming uses snake_case (no single-letter variables)
- All functions must have docstrings that clearly define their purpose, all parameters, dependencies, and expected return types
These rules should be as specific and structured as possible. Once incorporated into CLAUDE.md, Claude Code automatically follows them. Code consistency is an excellent weapon for accelerating your review of AI-generated code.
5. Git Workflow: Let Claude Auto-Commit Changes#
Set rules requiring Claude to automatically execute
git commitafter completing features and write clear, descriptive commit messages
Why is this useful? When executing complex tasks, Claude Code might be overly ambitious, making massive changes across multiple files or even introducing changes that break things, making it difficult for developers to track and revert to a “known good state” (i.e., the most recent bug-free version).
Since Claude Code lacks built-in checkpoint functionality like other tools, we must rely on Git as our project’s safety net or time machine. By establishing a Git workflow, you can embed the professional engineering discipline of version control into Claude’s behavior, ensuring easy recovery even when errors occur.
AI excels at handling Git operations. It can review code changes and examine recent history to write high-quality commit messages. When I first started my career, I found writing git commit messages tedious. Now even this can be delegated to AI (too convenient!).
Simple CLAUDE.md example:
## Git Workflow Standards
- Frequent commits: Must commit after completing each feature set
- Commit messages should cover the full scope of changes while remaining concise
- When implementing new features, create and switch to a new Git branch (e.g., using git worktree or directly creating a branch)
- *Never* push to the main branch (main or master) to avoid disrupting the prod environment
After writing these standards in CLAUDE.md, simply add a brief phrase in your Claude Code terminal prompt:
... please commit changes when done
Claude will automatically execute git add, write the message, and commit.

(Source: Reddit)
6. Custom Slash Commands: Execute Complex Tasks with One Command#
Store frequently used complex instructions as Markdown files (in
.claude/commands/)
Trigger them with slash commands (/command-name)
Why is this useful? Have you noticed yourself performing certain common tasks that require several lines of prompts to get Claude Code to execute correctly? Manually entering these prompts every time wastes time and invites errors, disrupting your development flow.
Using slash commands (/command-name), you don’t need to re-enter dozens of prompt lines each time. It’s especially useful for repetitive tasks. This technique aims to save these complex or frequently used workflows as reusable templates, integrated in the .claude/commands/ folder, then trigger them with a simple /command.
Simple CLAUDE.md example:
Custom Slash Commands are essentially prompt templates stored in Markdown files. We can create a “code review task” at .claude/commands/review.md:
## Code Review
Please review all staged changes, checking for:
- Compliance with project coding style standards
- Potential security vulnerabilities, dependency issues, and incorrect permission configurations
- Performance issues
- Focus on specific files or modules specified in $ARGUMENTS
Output results in Markdown table format
When you want to perform a security review on a specific file (e.g., user_auth.py), just type in Claude Code’s terminal:
/review user_auth.py
At this point, $ARGUMENTS gets replaced with user_auth.py. Through custom slash commands, complex security review workflows can now be completed with one command!
Note: Commands placed in .claude/commands/ are “project-specific” memory. If you want them available across all projects, store slash commands in the global location ~/.claude/commands/ (official documentation)
7. Specialized AI Agents (Sub-Agents): Let Claude Play Different Roles#
Define the professional role Claude should play (e.g., frontend developer, security expert) and set that role’s system prompt
Why is this useful? Different tasks require different professional perspectives. Setting up specialized agents (Sub-Agents) makes Claude more focused and professional.
Claude Code itself is a versatile coding expert, but when facing highly specialized tasks not limited to code generation, such as:
- Conducting complex financial analysis
- Writing marketing copy matching specific brand styles
- Following strict UI/UX specifications (e.g., using ShadCN components)
Its versatility becomes a limitation.
Therefore, when you need Claude to behave like a specific expert (professional designer or debugging master), you must provide a highly focused, targeted system prompt.
Creating custom agents (Sub-agents) is the most common and powerful approach. You can manually create them or use the /agents command to let Claude Code generate specialized sub-agents. These agents are independent, have their own context windows, and have dedicated Markdown files storing their system prompts (e.g., in the .claude/agents/ folder).
Simple example:
Suppose you want Claude Code to serve as your professional presentation designer, responsible for transforming your YouTube video scripts into HTML presentations with specific design styles (e.g., Apple minimalist style). You can write the following core instructions in CLAUDE.md or a dedicated agent configuration (.claude/agents/ folder), such as .claude/agents/designer.md:
## Presentation Designer AI Agent
**Role:** You are a professional presentation designer specializing in creating Apple-style HTML presentations for YouTube videos.
**Design Philosophy:**
- When discussing past or outdated concepts, must use **red**
- When introducing new opportunities or solutions, must use **green**
- Always use Apple Minimal style CSS templates (reference `@styles/apple_minimal.css`)
When executing the /designer command, Claude Code will follow these rigorous design philosophies and your personal style preferences to generate presentations:
/designer "Please design a presentation based on my AI software business model introduction document, using Apple minimalist style"
8. MCP Servers: Connect Claude to Practical Tools#
Model Context Protocol (MCP) enables Claude to interact with external tools, such as browsers, databases, and API documentation
Why is this useful? Claude’s core capabilities lie in processing text, code, and logic. It cannot natively interact with external systems. For instance, even though AI can generate HTML code, it cannot actually view web pages directly. With MCP, Claude Code can “see” web pages, read real-time database structures, execute automated tests, and more.
Practical MCP examples (data science related):
- Postgres MCP: Lets Claude directly query database structure and write correct SQL queries
- Puppeteer MCP: Lets Claude control browsers to test data visualization webpage rendering
- Context7 MCP: Lets Claude access the latest library documentation (e.g., latest versions of pandas, scikit-learn)
You don’t need to learn MCP installation and usage right now (after all, this article would become incredibly long). Just know:
Part Three: Leverage Templates#
With all these techniques, remembering everything at once is genuinely challenging. We can leverage templates, which directly copy and paste community-vetted AI configurations to help ourselves get started quickly.
9. Claude Code Templates: Standing on Giants'#
aitmpl.com is an open-source Claude Code template library containing over 400 ready-made agents, commands, and configurations
Why is this useful? No need to write CLAUDE.md or custom commands from scratch. Directly install expert-level templates to quickly launch projects.
Templates aim to utilize reusable, battle-tested agent prompts. We can treat templates and prompts like “LEGO blocks” (combining and swapping them). When standing on giants’ shoulders, prompts and CLAUDE.md configurations suitable for new projects don’t need to start from zero!
Simple example:
# Install frontend developer agent template
npx claude-code-templates@latest --agent=development-team/frontend-developer --yes
This single short line automatically sets up a professional frontend development environment, including code standards, workflows, and common commands. Fast enough, right?

(GitHub link)
10. Data Science Template: Or, Want to Copy My Common Prompts?#
The CLAUDE.md I need for each data science or analysis project naturally varies. Besides referencing aitmpl.com templates, I ensure my CLAUDE.md includes the following practical instructions for your reference:
# Language
- Always respond in Traditional Chinese for conversations
- Code content (including strings) and comments always written in English
# Python Preferences
- Use 4-space indentation
- Use pytest rather than unittest
- Functions must have complete type hints
- Prefer f-strings over format()
# Data Analysis
- Use plotnine package for visualization
- Check assumptions before statistical tests (e.g., check multicollinearity using Variance Inflation Factor)
- When visualizing data with plotnine and matplotlib, set appropriate figure sizes and DPI for clarity
Summary: Your Next Steps#
The numerous techniques in this article cover CLAUDE.md’s core application scenarios:
- Context Management:
/init, hierarchical file structure,@references - AI Behavior Guidance: Coding style, Git workflow, custom commands, specialized agents, MCP servers
- Efficiency Acceleration: Leverage templates
You don’t need to master everything at once. I’m still practicing too. My recommendations:
- Master
#and@first: These are most practical and easiest to learn - Set coding style and Git standards: Establish stable workflows telling AI-generated code to meet team requirements!
- Explore other techniques as needed: For instance, learn custom slash commands when repeatedly executing tasks
This article is my personal cheat sheet and hopefully expands your AI horizons. Simply knowing these techniques exist is the first step toward improvement.
Ready to take your Claude Code to the next level? Open your terminal now and try these techniques.
Further Reading:
References:
- Official documentation: Manage Claude’s memory
- Claude Code: Best practices for agentic coding
- Template resources: aitmpl.com
- Official course: Claude Code in Action

