34 Claude Code Usage Tips
I. Command Line Interface (CLI) Tips (7 tips)
- Treat it as CLI: Fundamentally understand that Claude Code is a command line tool with all its basic characteristics.
- Pass command arguments: Use the
-P
parameter to run in command line mode. - Use no-mode: Use the
-P
parameter to run in front-end interface mode. - Connect with other tools: Can connect other command line tools (bash/CLI tools) to the workflow.
- Use piped input: Pipe data into Claude Code using pipes (
|
). - Run multiple instances: Can run multiple Claude Code instances simultaneously.
- Let it start itself: Can instruct Claude Code to start a new instance to handle task principles.
II. Image Processing Tips (6 tips)
- Drag and paste: Drag image files directly into the terminal for use.
- macOS screenshot paste: Use shortcut
Shift+Command+Control+4
to copy screenshots to clipboard. - Use Control+V to paste: Use
Control+V
(instead ofCommand+V
) to paste images into the terminal. - Generate code from design mockups: Paste design mockup images and let Claude Code build the interface.
- Establish visual feedback loop: Take screenshots of the current application state and feed them back to Claude Code for iterative modifications.
- Automated generation: Use Puppeteer MCP service to automate the screenshot generation workflow for applications.
III. Integration and External Data Tips (5 tips)
- Act as MCP server/client: Claude Code itself can serve both as an MCP server and as a client connecting to other services.
- Connect to databases: Use Postgres MCP server to connect Claude Code to your database.
- Get latest API documentation: Utilize MCP servers provided by companies like Cloudflare to get real-time updated documentation.
- Scrape link content: Directly paste a URL, and Claude Code will scrape the webpage content as context.
- Get external knowledge: Use URL scraping functionality to obtain knowledge from the external world (like game rules) and apply it to code.
IV. claude.md Configuration File Tips (7 tips)
- Understand its core purpose:
claude.md
is a system prompt file that gets loaded with every request. - Use /init for auto-generation: Run the
/init
command in the project directory to automatically generate aclaude.md
based on project structure. - Use # for dynamic updates: In conversations, use the
#
symbol to directly add instructions toclaude.md
. - Set global configuration: Create
claude.md
in the user home directory~/.claude/
to apply to all projects. - Use subdirectory configuration: Add
claude.md
in subdirectories to apply to specific modules. - Regular reloading: Regularly optimize and refine your
claude.md
file to keep it specific and efficient. - Use prompt optimization tools: Leverage Anthropic's prompt optimization tools to improve
claude.md
content.
V. Custom Slash Commands Tips (6 tips)
- Define in specified folder: Create files in the
.claude/slash_commands
folder to customize your own slash commands. - Create commands for solving GitHub issues: Create a command like
/solve_github_issue
. - Create commands for refactoring: Create a
/refactor
command. - Create commands for code checking: Create a
/lint
command. - Create commands for PR review: Create a
/review_pr
command. - Pass arguments to commands: Your custom slash commands are prompt templates that can receive command line arguments.
VI. UI and Workflow Tips (3 tips)
- Use Tab completion: Use the
Tab
key to auto-complete file and directory names for more precise context. - Decisively press Esc to interrupt: When you see Claude Code's output deviating from expectations, immediately press the
Esc
key to interrupt it. - Use undo to revert: After interrupting, you can ask it to
undo
the previous operation.