Basic Commands
๐ก What you'll learn in this chapter: frequently used prompt patterns for file operations, code analysis, debugging, and Git integration
Prerequisites
You should have completed First Run and be comfortable with the basic interface.
Principles of Effective Promptsโ
How to give Claude Code instructions that work well:
โ
Good: "Read src/auth/login.js and explain the password hashing logic"
โ
Good: "Look at the README in the current directory and add the missing installation steps"
โ Bad: "Fix the code" (too vague)
โ Bad: "Write good code" (no criteria)
The key combination is a specific file name + a clear task + the result you want.
1. Reading and Analyzing Filesโ
Understanding File Contentsโ
> Read utils/helpers.js and explain what each function does
> Analyze the Props types in src/components/Button.tsx
> Find hardcoded values in config/database.js that should be moved to environment variables
Understanding a Whole Projectโ
> Look at this project's folder structure and explain the overall architecture
> Look at package.json and tell me what tech stack this project uses
> Read README.md and summarize the key points
2. Writing Codeโ
Creating New Filesโ
> Create a file called utils/validation.js.
Include validation functions for email, phone number, and password (8+ characters, must include a special character).
> Create components/Modal.jsx.
props: isOpen, onClose, title, children
Style it with Tailwind CSS
Adding Features to Existing Codeโ
> Add a user search feature to UserService.js.
Search by name or email, case-insensitive.
> Add pagination parameters to api/routes/products.js.
Use the format ?page=1&limit=20.
3. Debuggingโ
Analyzing and Fixing Errorsโ
> Run npm run build, check for errors, and fix them
> I got this error in the terminal: [paste the error message] โ explain the cause and how to fix it
> Run all the tests in the tests/ folder and fix the failing ones
Performance Issuesโ
> The UserList component seems to re-render too often. Find the cause and optimize it
> This SQL query is slow: [paste the query] โ suggest ways to optimize it
4. Refactoringโ
Improving Code Qualityโ
> utils.js is too big. Split it into separate files by feature
> Refactor this function to be more readable, keeping the behavior identical
> Convert the Promise-based code to async/await
Unifying Code Styleโ
> Update the entire controllers/ folder to match the project's .eslintrc rules
> Replace var with const/let across all components
5. Writing Testsโ
> Write Jest unit tests for each function in UserService.js
> Check the current test coverage and add tests for missing edge cases
> E2E test: write the login โ dashboard navigation โ logout flow with Playwright
6. Documentationโ
> Add JSDoc comments to all public functions
> Read the list of API endpoints and add an API documentation section to the README
> Update CHANGELOG.md based on the recent commit messages
7. Git Operationsโ
Claude Code can run git commands too:
> Check git status and summarize the modified files
> Review the changes, write an appropriate commit message, and commit
> Analyze the diff between the current branch and main, and draft a PR description
Frequently Used Slash Commandsโ
/model # Check the current model
/model claude-opus-4-6 # Switch to Opus (complex tasks)
/model claude-haiku-4-5-20251001 # Switch to Haiku (fast tasks)
/cost # This session's cost
/clear # Reset the conversation (start with fresh context)
/status # Check current settings
/help # Full help
Real-World Workflow Examplesโ
"Add a Feature" Workflowโ
1. > Get familiar with this project's structure (understand)
2. > Plan how to implement a user profile editing feature (plan)
3. > Implement it according to the plan (execute)
4. > Write tests (verify)
5. > Commit the changes (wrap up)
"Fix a Bug" Workflowโ
1. > Run npm test and show me the failing tests
2. > Analyze [the failing test file] and find the cause
3. > Fix it
4. > Run npm test again to confirm
Key Takeawaysโ
- A specific file name + a clear task is the effective combination
- Work in stages: read files โ analyze โ modify โ verify
- Pick the right model for the job with
/model(cost optimization) - Claude Code can run terminal commands directly โ git, npm, python, and more
Get weekly Claude Code tips by email
Real usage insights, delivered free. Subscribe โ
Level 1 Complete!โ
Congratulations! You've finished all of Level 1 โ Getting Started.
Found an issue on this page? Report it โ