Skip to content

34 Claude Code Usage Tips

I. Command Line Interface (CLI) Tips (7 tips)

  1. Treat it as CLI: Fundamentally understand that Claude Code is a command line tool with all its basic characteristics.
  2. Pass command arguments: Use the -P parameter to run in command line mode.
  3. Use no-mode: Use the -P parameter to run in front-end interface mode.
  4. Connect with other tools: Can connect other command line tools (bash/CLI tools) to the workflow.
  5. Use piped input: Pipe data into Claude Code using pipes (|).
  6. Run multiple instances: Can run multiple Claude Code instances simultaneously.
  7. Let it start itself: Can instruct Claude Code to start a new instance to handle task principles.

II. Image Processing Tips (6 tips)

  1. Drag and paste: Drag image files directly into the terminal for use.
  2. macOS screenshot paste: Use shortcut Shift+Command+Control+4 to copy screenshots to clipboard.
  3. Use Control+V to paste: Use Control+V (instead of Command+V) to paste images into the terminal.
  4. Generate code from design mockups: Paste design mockup images and let Claude Code build the interface.
  5. Establish visual feedback loop: Take screenshots of the current application state and feed them back to Claude Code for iterative modifications.
  6. Automated generation: Use Puppeteer MCP service to automate the screenshot generation workflow for applications.

III. Integration and External Data Tips (5 tips)

  1. Act as MCP server/client: Claude Code itself can serve both as an MCP server and as a client connecting to other services.
  2. Connect to databases: Use Postgres MCP server to connect Claude Code to your database.
  3. Get latest API documentation: Utilize MCP servers provided by companies like Cloudflare to get real-time updated documentation.
  4. Scrape link content: Directly paste a URL, and Claude Code will scrape the webpage content as context.
  5. 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)

  1. Understand its core purpose: claude.md is a system prompt file that gets loaded with every request.
  2. Use /init for auto-generation: Run the /init command in the project directory to automatically generate a claude.md based on project structure.
  3. Use # for dynamic updates: In conversations, use the # symbol to directly add instructions to claude.md.
  4. Set global configuration: Create claude.md in the user home directory ~/.claude/ to apply to all projects.
  5. Use subdirectory configuration: Add claude.md in subdirectories to apply to specific modules.
  6. Regular reloading: Regularly optimize and refine your claude.md file to keep it specific and efficient.
  7. Use prompt optimization tools: Leverage Anthropic's prompt optimization tools to improve claude.md content.

V. Custom Slash Commands Tips (6 tips)

  1. Define in specified folder: Create files in the .claude/slash_commands folder to customize your own slash commands.
  2. Create commands for solving GitHub issues: Create a command like /solve_github_issue.
  3. Create commands for refactoring: Create a /refactor command.
  4. Create commands for code checking: Create a /lint command.
  5. Create commands for PR review: Create a /review_pr command.
  6. Pass arguments to commands: Your custom slash commands are prompt templates that can receive command line arguments.

VI. UI and Workflow Tips (3 tips)

  1. Use Tab completion: Use the Tab key to auto-complete file and directory names for more precise context.
  2. Decisively press Esc to interrupt: When you see Claude Code's output deviating from expectations, immediately press the Esc key to interrupt it.
  3. Use undo to revert: After interrupting, you can ask it to undo the previous operation.