Claude Terminal Command Cheat Sheet – Minimal Copy‑Paste Version
This guide provides a concise, copy‑ready reference for installing Claude, launching it in various modes, managing sessions, optimizing context, handling project memory, switching models, exporting results, monitoring cost, using work modes, and applying handy shortcuts for efficient AI‑assisted coding.
Installation & Upgrade
For macOS/Linux run curl -fsSL https://claude.ai/install.sh | bash. On Windows PowerShell use iwr -useb https://claude.ai/install.sh | iex. Check the version with claude --version and update via claude update.
Startup Methods (most common three)
claude– start an interactive session in the current directory (covers ~99% of use cases). claude --dir ./project-name – launch Claude with a specific project directory.
claude "帮我重构这段代码、统一规范、修复报错"– execute a single‑line request without entering a persistent conversation.
Basic Session Control
/exit– quit the session. /help – list all commands. /help shortcuts – show shortcut keys.
Context Optimization (reduce latency, save tokens)
/clear– clear the current conversation. /compact – compress and summarize the context; essential for long dialogs. /resume – resume a previously interrupted session. /btw 问题 – ask a temporary side question without polluting the main context.
Safe Experimentation & Branch Reverting
/fork– duplicate the current session into a new branch for testing. /rewind – step back one action. /reset – reset the entire session state.
Project Intelligent Memory (key feature)
/init– automatically scan the project and generate CLAUDE.md . /memory – edit project rules, tech stack, coding standards. /config – view the current configuration.
Model Switching
/model sonnet– balanced speed and stability (default). /model opus – strongest reasoning for complex architectures or difficult bugs. /model haiku – ultra‑fast for small edits, Q&A, or copywriting.
Export & Copy
/export 记录.md– export the entire conversation to a markdown file. /copy – copy the last code snippet generated.
Cost & Review
/cost– display the token cost of the current session. /review – trigger AI‑powered code review.
Three Working Modes (toggle with Shift+Tab)
Default – all file changes require confirmation (most stable).
Auto‑Accept – automatically apply file changes while still confirming commands (preferred for daily development).
Plan – only analysis, no code changes (useful for architecture planning).
Common Keyboard Shortcuts
Ctrl + L – upload file or directory for analysis.
Ctrl + C – stop the current generation.
Double‑click Esc – quick rollback.
Shift + Tab – switch working mode.
New‑User Golden Usage Mnemonics
New project: run /init.
Long dialogs: run /compact.
Complex modifications: start with /fork.
Architecture bugs: use opus model.
Daily coding: use sonnet model.
Quick Q&A: use haiku model.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
liandk
Seasoned Java and mobile developer with years of experience, specializing in mini‑programs, public accounts, and full‑stack front‑end development. In the AI era, I continuously learn to broaden my knowledge and evolve. I revived a public account I started a decade ago during a dessert‑startup venture, using code as a vessel and knowledge as a companion. I share personal projects, technical articles, programming tips, and growth insights—let’s improve together and set sail.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
