34 Claude Code Usage Tips

Master advanced Claude Code techniques, from command line to image processing, from external integration to workflow optimization - a complete guide.

Command Line (CLI) Tips

1. Think of it as a CLI

Fundamentally understand Claude Code as a command-line tool with all its basic characteristics.

# Claude Code can execute all standard CLI operations
claude --help
claude --version
claude --list-sessions

2. Pass Command Arguments

Use the -P parameter to run in command-line mode.

# Directly pass prompts to execute tasks
claude -P "Analyze package.json and list all dependencies"

3. Use Non-interactive Mode

Use the -P parameter to run in non-interactive mode.

# Non-interactive mode, output results directly
claude -P "Generate a React component" --no-interactive

4. Connect with Other Tools

Connect other command-line tools (bash/CLI tools) to the workflow.

# Use with other tools
git diff | claude -P "Explain these code changes"
npm test 2>&1 | claude -P "Analyze test failure reasons"

5. Use Pipe Input

Pass data to Claude Code through pipes (|).

# Pass data via pipe
cat error.log | claude -P "Analyze error log and provide solutions"
curl https://api.example.com | claude -P "Parse this API response"

6. Run Multiple Instances

Run multiple Claude Code instances simultaneously to handle different tasks.

# Terminal 1
claude --session frontend-work

# Terminal 2
claude --session backend-api

# Terminal 3
claude --session testing

7. Let It Launch Itself

Instruct Claude Code to launch a new instance to handle tasks.

Please run tests in a new Claude instance and report the results to me.

Image Processing Tips

8. macOS Screenshot Paste

Use the shortcut Shift+Command+Control+4 to copy screenshots to clipboard.

Step 1

Press Shift+Command+Control+4

Step 2

Select the area to screenshot

Step 3

Screenshot automatically copies to clipboard

9. Use Control+V to Paste

Use Control+V (not Command+V) to paste images to terminal.

Note: In macOS terminal, use Control+V instead of Command+V to paste images

10. Generate Code from Design

Paste design mockups and let Claude Code build the interface.

[Paste design image]
Please generate corresponding React components based on this design, including:
- Responsive layout
- Mobile adaptation
- Using Tailwind CSS

11. Build Visual Feedback Loop

Screenshot the current state of your app and feed it back to Claude Code for iterative modifications.

Initial Implementation

Generate initial interface code

Screenshot Feedback

Capture running effect screenshot

Iterative Optimization

Adjust based on screenshot

Continuous Improvement

Repeat until satisfied

12. Automated Generation

Use Puppeteer MCP service to automate the screenshot generation process.

// Automated screenshot script example
const puppeteer = require('puppeteer')

async function captureScreenshots() {
  const browser = await puppeteer.launch()
  const page = await browser.newPage()

  // Capture screenshots of different states
  await page.goto('https://localhost:3000')
  await page.screenshot({ path: 'homepage.png' })

  await page.click('.login-button')
  await page.screenshot({ path: 'login-page.png' })

  await browser.close()
}

13. Batch Image Processing

Process multiple image files simultaneously.

Please analyze all screenshots in the screenshots/ directory and identify UI inconsistencies.

Integration and External Data Tips

14. Act as MCP Server/Client

Claude Code can act as both an MCP server and connect to other services as a client.

// MCP configuration example
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-postgres"]
    }
  }
}

15. Connect to Database

Use Postgres MCP server to connect Claude Code to your database.

After connecting to the database, please:
1. Analyze existing table structure
2. Generate TypeScript type definitions
3. Create CRUD API interfaces

16. Get Latest API Documentation

Use MCP servers provided by companies like Cloudflare to get real-time updated documentation.

Please get the latest Workers API documentation from Cloudflare MCP and create a sample project.

Paste a URL directly and Claude Code will crawl the webpage content as context.

https://docs.example.com/api/v2

Please create a corresponding TypeScript SDK based on the above documentation.

18. Get External Knowledge

Use URL crawling to get external knowledge and apply it to code.

https://en.wikipedia.org/wiki/Chess_rules

Based on the above rules, implement the core logic of a chess game.

CLAUDE.md Configuration Tips

19. Understand Its Core Role

CLAUDE.md is a system prompt file that loads on every request.

# CLAUDE.md Example Structure

## Project Overview

Brief description of project purpose and tech stack

## Development Standards

- Code style guide
- Naming conventions
- File organization structure

## Common Commands

List frequently used project commands

## Important Notes

Project-specific notes and limitations

20. Use /init to Auto-generate

Run /init command in project directory to auto-generate CLAUDE.md based on project structure.

# Run in project root directory
> /init

# Claude Code will analyze project and generate configuration file

21. Add Project-Specific Rules

Define project-specific coding rules in CLAUDE.md.

## Project Rules

- All API responses must include status and data fields
- Use camelCase for variables, PascalCase for components
- Forbidden to use any type, must define explicit TypeScript types

22. Include Common Code Snippets

Include frequently used code templates in configuration file.

## Code Templates

### React Component Template

\```tsx
import React from 'react';

interface Props {
// props definition
}

export const ComponentName: React.FC<Props> = ({ }) => {
return <div></div>;
};
\```

23. Record Architecture Decisions

Use CLAUDE.md to record important architecture decisions.

## Architecture Decision Records

### ADR-001: Using Redux Toolkit

- **Date**: 2024-01-15
- **Decision**: Adopt Redux Toolkit for state management
- **Reason**: Simplify Redux usage, reduce boilerplate code

24. Maintain Dependency Descriptions

Document the purpose and version requirements of key dependencies.

## Key Dependencies

| Package | Version | Purpose              | Notes                     |
| ------- | ------- | -------------------- | ------------------------- |
| react   | ^18.0.0 | UI framework         | Using concurrent features |
| next    | ^14.0.0 | Full-stack framework | App Router                |

25. Define Testing Strategy

Clarify project testing requirements and strategy.

## Testing Strategy

- Unit test coverage > 80%
- All API endpoints must have integration tests
- Using Jest + React Testing Library
- E2E testing with Playwright

Custom Command Tips

26. Create Custom Commands

Create custom commands in .claude/commands/ directory.

// .claude/commands/test-all.js
module.exports = {
  name: 'test-all',
  description: 'Run all tests and generate coverage report',
  execute: async () => {
    await runCommand('npm test -- --coverage')
    await runCommand('npm run e2e')
  }
}

27. Command Aliases

Create short aliases for frequently used long commands.

// .claude/commands/aliases.js
module.exports = {
  c: 'commit',
  p: 'push',
  ta: 'test-all',
  dev: 'npm run dev'
}

28. Batch Commands

Create batch commands that execute multiple operations.

// .claude/commands/deploy.js
module.exports = {
  name: 'deploy',
  description: 'Complete deployment process',
  execute: async () => {
    await runCommand('npm test')
    await runCommand('npm run build')
    await runCommand('npm run deploy:prod')
  }
}

29. Parameterized Commands

Support custom commands that accept parameters.

// .claude/commands/create-component.js
module.exports = {
  name: 'create-component',
  description: 'Create new component',
  parameters: ['name', 'type'],
  execute: async (name, type = 'functional') => {
    // Generate component based on parameters
  }
}

30. Conditional Commands

Commands that execute different operations based on conditions.

// .claude/commands/smart-test.js
module.exports = {
  name: 'smart-test',
  execute: async () => {
    const files = await getChangedFiles()
    if (files.some((f) => f.endsWith('.tsx'))) {
      await runCommand('npm run test:components')
    }
    if (files.some((f) => f.includes('api/'))) {
      await runCommand('npm run test:api')
    }
  }
}

31. Interactive Commands

Create interactive commands that require user input.

// .claude/commands/scaffold.js
module.exports = {
  name: 'scaffold',
  interactive: true,
  execute: async () => {
    const type = await prompt('Choose type: component/page/api')
    const name = await prompt('Enter name:')
    // Generate code based on input
  }
}

UI and Workflow Tips

32. Use Split Screen Mode

Use terminal split screen functionality to view code and Claude Code output simultaneously.

# Horizontal split
Ctrl+b "

# Vertical split
Ctrl+b %

# Switch panes
Ctrl+b arrow keys

33. Set Up Workspaces

Set up dedicated workspaces for different types of tasks.

# Create frontend development workspace
claude --workspace frontend --dir ./src/components

# Create backend development workspace
claude --workspace backend --dir ./src/api

# Create testing workspace
claude --workspace testing --dir ./tests

34. Use Session History

Use session history to quickly restore previous work state.

# View session history
claude --history

# Resume specific session
claude --resume <session-id>

# Export session record
claude --export-session > session-backup.json

Best Practices Summary

Master the Basics

Deeply understand Claude Code's essence as a CLI tool and fully utilize command-line features.

Visual First

Make good use of screenshot and image processing features to build visual feedback loops for accelerated development.

External Integration

Connect databases, API documentation and other external resources to expand Claude Code's capabilities.

Personalized Configuration

Create a project-specific environment through CLAUDE.md and custom commands.

Workflow Optimization

Use split screen, workspaces, session management and other techniques to improve development efficiency.

💡 Tip: These 34 tips cover all aspects of Claude Code. It's recommended to first master the basic tips, then gradually apply advanced features based on project needs, ultimately forming your own efficient workflow.

Bring endless innovation and opportunities with AI
About
Features
Docs
Pricing
Contact us
Terms & Policies
Terms of Use
Privacy Policy
Specified Commercial Transactions Act