CLI Tips
34 practical Claude Code CLI tips to boost your development efficiency
CLI Tips¶
This guide compiles 34 practical Claude Code tips, from basic operations to advanced features, helping you maximize Claude Code's potential.
Basic Operations¶
1. Tab Autocomplete for File Paths¶
Press Tab after typing @ to autocomplete file paths—no need to remember full paths.
2. Use @ to Reference Files Precisely¶
> Analyze security in @src/utils/auth.ts
> Compare @v1/api.js with @v2/api.js
Direct file references are more accurate than describing file locations.
3. Pipe Input for Analysis¶
git diff | claude "explain these changes"
cat error.log | claude "analyze error causes"
npm test 2>&1 | claude "analyze test failures"
4. Keyboard Shortcuts¶
| Shortcut | Function |
|---|---|
Tab |
Autocomplete file paths |
Esc |
Interrupt current output |
Ctrl+C |
Cancel current operation |
↑ / ↓ |
Browse command history |
Shift+Tab (twice) |
Enter plan mode |
Alt+Tab / Option+Tab |
Toggle thinking mode |
5. Use ! for Quick Commands¶
Prefix with ! to execute shell commands directly:
> !git status
> !npm run build
Slash Commands¶
6. /help - View All Commands¶
> /help
Shows all available slash commands and shortcuts.
7. /clear - Clear Conversation¶
> /clear
Clear context before starting new tasks to avoid interference from previous conversations.
8. /compact - Compress History¶
> /compact
Use when context gets too long—compresses history to save tokens while keeping core information.
9. /context - Check Context Usage¶
> /context
Shows current context usage percentage. Consider compacting or starting a new session at 60%.
10. /model - Switch Models¶
> /model opus
> /model sonnet
- Opus 4.5: Complex tasks, architecture design, difficult problems
- Sonnet 4.5: Daily coding, quick iterations (cost-effective)
11. /memory - Edit Project Memory¶
> /memory
Opens CLAUDE.md file for editing project standards and preferences.
12. /init - Initialize Project Config¶
> /init
Let Claude analyze your project and generate a CLAUDE.md configuration file.
13. /commit - Smart Commit¶
> /commit
Automatically analyzes changes, generates proper commit messages, and commits.
14. /review - Code Review¶
> /review
Reviews current changes for potential issues.
15. /resume - Resume Session¶
> /resume
Resume a previous conversation session to continue unfinished work.
Context Management¶
16. Keep Sessions Focused¶
Focus one session on one task. Use /clear after completing a task to start fresh.
17. Monitor Context Usage¶
Claude Code has ~200K token context limit. Use /context to monitor, and at 60%:
- Use /compact to compress
- Start a new session for new tasks
18. Copy-Paste Output for Feedback¶
When you need Claude to analyze its own output, select, copy, and paste it back. This works for any terminal output.
Plan Mode¶
19. Enter Plan Mode¶
Press Shift+Tab twice to enter plan mode. Claude will research and create plans without modifying code.
20. Plan Before Execute¶
For complex tasks, have Claude create a plan first:
> Analyze this feature requirement and create an implementation plan, don't write code yet
Confirm the plan before execution to reduce rework.
21. Execute Complex Tasks Step by Step¶
Break large tasks into smaller steps:
> Step 1: Analyze the existing auth system
> Step 2: Design the new JWT approach
> Step 3: Implement core functionality
> Step 4: Add tests
Subagents¶
22. Use Explore Agent for Fast Search¶
The Explore agent specializes in fast codebase searches:
> Use the Explore agent to find all payment handling code
23. Use Plan Agent for Design¶
The Plan agent specializes in implementation planning:
> Use the Plan agent to design the user permission system
24. Background Agents for Parallel Tasks¶
Launch multiple background agents to process tasks in parallel for better efficiency.
CLAUDE.md Configuration¶
25. Define Project Standards¶
In CLAUDE.md, define: - Code style standards - Naming conventions - Architecture overview - Common commands
26. Record Project-Specific Info¶
## Project Info
- Using TypeScript strict mode
- Test framework: Jest
- Build command: npm run build
- Main branch: main
27. Set Preferences¶
## Preferences
- Use functional components, not class components
- Prefer async/await
- Error handling uses custom AppError class
Git Workflow¶
28. Smart Commit Messages¶
> /commit
Claude analyzes all changes and generates proper commit messages.
29. Create PR Descriptions¶
> Create a PR description for the current branch
Automatically generates PR descriptions with change summary and test plan.
30. Analyze PR Changes¶
gh pr diff 123 | claude "review this PR"
Testing & Debugging¶
31. Have Claude Write Tests¶
> Write unit tests for @src/services/UserService.ts
Let Claude write tests to verify its own code correctness.
32. Analyze Test Failures¶
npm test 2>&1 | claude "analyze failures and fix"
33. Debug Errors¶
> Analyze this error: [paste error message]
> Debug the issue in @src/pages/Login.tsx
Advanced Tips¶
34. Use Screenshots/Images¶
Claude Code supports image understanding:
> Look at this screenshot @screenshot.png and analyze UI issues
Efficiency Comparison¶
| Scenario | Traditional | Claude Code |
|---|---|---|
| Find code | grep + manual browsing | @file or Explore agent |
| Write tests | Manual + debugging | /review + auto-generate |
| Git commit | Think message + write | /commit one-click |
| Code review | Line-by-line review | /review smart analysis |
| Understand code | Read docs + read code | Just ask Claude |
Best Practices Summary¶
- Be specific: Clearly describe requirements with constraints
- Use references: Use
@to specify files, avoid guessing - Step by step: Break complex tasks into smaller steps
- Interrupt early: Press
Escimmediately if output is wrong - Stay focused: One session for one task
- Compact regularly: Use
/compactwhen context gets long - Plan first: Create plans before complex tasks
- Let AI test: Have Claude write tests to verify its code
Next Steps¶
- Learn Workflow Tips for efficient development processes
- Explore Custom Commands to create your own commands
- Check out Codex Integration to use another AI tool