35 Practical Claude Code Tips to Supercharge Your Development
This guide presents 35 hands‑on Claude Code techniques—from project initialization and session management to code quality, architecture reviews, automation, and debugging—each with ready‑to‑copy commands or prompts that help developers streamline AI‑assisted software creation.
1. Project Startup in Four Steps
New projects should begin with these actions to halve later effort.
/init /init Scans the entire codebase, generates CLAUDE.md documenting project structure, tech stack, and coding standards. Subsequent sessions automatically load this file, avoiding repeated project background explanations.
/memory – Write Persistent Rules /memory Opens the memory editor to add cross‑session rules, for example:
Always use TypeScript strict mode.
All public functions must have JSDoc comments.
After modifying any file under /src/core , run the test suite.
These rules are applied automatically in every new conversation.
Plan Mode (Shift + Tab) – Plan Before Coding
Switch to Plan mode (Shift + Tab). Claude Code only analyses and proposes an architecture. After confirming the plan, switch back to implementation mode. This habit prevents more bugs than all other tips combined.
Mode Constraints – Lock Style in CLAUDE.md
Add a style block to CLAUDE.md such as:
When creating a new file, follow these patterns:
- API routes: see src/api/example-route.ts
- Database queries: see src/repositories/example-repo.ts (repository pattern)
- React components: see src/components/ExampleComponent.tsx
Claude Code will automatically align new files with the project’s conventions.
2. Session Management: Context Is a Scarce Resource
/compact – Compress Context /compact After 30–45 minutes of chat, run this command. It condenses the whole conversation into a concise summary that retains key decisions and the current state, allowing Claude Code to refocus. Skipping this step gradually degrades output quality.
/clear – Start a Fresh Task /clear Clears the entire context when beginning a new task. Carrying database‑refactoring context into front‑end work produces chaotic code. Principle: one feature per conversation.
/cost – Check Token Usage /cost Shows the token consumption of the current session. Check it hourly and set a mental budget.
Model Switching
Use Opus for planning and architectural decisions, Sonnet for concrete implementation. Switch models in Claude Code settings or specify at conversation start. Opus is deeper but costly; Sonnet is faster and cheaper.
! Prefix – Direct Terminal Commands !git status !npm test !ls src/ Prefix a message with ! to execute terminal commands instantly, without opening a new window. Run tests, check git status, list directories—all within the same interface.
Parallel Sessions
Open two terminal windows: one for back‑end implementation, one for front‑end. Each keeps a clean context, and you later connect the two. This is more stable than switching back and forth in a single session.
3. Code Quality: Make Output Stable and Useful
Reference‑File Method
Instead of describing style in words, point to a concrete file:
Look at src/auth/login.ts for the authentication implementation and replicate the exact pattern for password‑reset.
This is ten times more precise, especially for maintaining consistency in team projects.
Screenshot Debugging
Paste a UI screenshot (Ctrl + V) and say:
Buttons and input fields are misaligned; card spacing is inconsistent. Fix both.
Much faster and clearer than a textual description.
Test‑First Implementation
Write test cases for a discount‑price function covering normal discount, zero discount, 100 % discount, negative price, and string input. Then implement the function so all tests pass.
Defining behavior first makes the implementation naturally correct.
Incremental Build
Break a large feature into steps, testing after each:
Step 1: Build only the database schema.
Verify OK, then:
Step 2: Build the API endpoint that uses this schema.
Five small steps with tests yield far higher quality than a single massive prompt.
Diff Review
Show the diff of all modified files and explain each change in one sentence.
This forces Claude Code to only modify what you explicitly ask for.
4. Exploring Unknown Codebases
Codebase Questioning
Read the src/services/ directory and explain the full data flow from API routes to the database. Which patterns are used? What must I know before modifying this part?
Understanding architecture first avoids conflicting changes.
5. Architecture and Refactoring
Architecture Audit
Analyze my project requirements (list them). Propose two distinct architecture options, each with component diagram, pros, cons, complexity estimate, and potential issues. Finally, recommend one and justify the choice.
Refactor Planning
Read src/services/user-service.ts . It has grown to 800 lines with too many responsibilities. Propose a split‑refactor plan: new file structure, which code moves where, and ensure external references remain intact. Do not start refactoring yet—only give the plan.
The “do not start refactoring” constraint prevents premature changes.
Database Migration Generation
I need to modify the user table schema: add a role enum field (admin, editor, viewer, default viewer) and rename name to display_name . Generate the migration file, update the repository layer, all API routes that reference the old schema, and the TypeScript type definitions. Before touching code, list every file that must be changed.
Multi‑layer coordinated changes showcase Claude Code’s strength.
6. API Design and Security
API Design Review
Review my API design (paste route definitions). Check for consistent naming, missing error responses, missing pagination, absent authentication, and REST violations. Provide concrete improvement suggestions.
Security Scan
Scan the codebase for security issues: SQL injection, XSS, exposed secrets, missing input validation, insecure direct object references, lack of rate limiting. For each issue, give severity, exact location, why it’s dangerous, and how to fix it.
Performance Analysis
Analyze performance problems in the codebase: N+1 queries, missing indexes, unnecessary React re‑renders, large bundles that could be lazy‑loaded, APIs that need caching. Prioritize by impact.
7. Engineering Automation
Git Hook
Create a pre‑commit hook that runs lint, type checking, and detects console.log in production code; abort the commit if any check fails. Install it to .husky/pre‑commit .
CI Pipeline
Create a GitHub Actions workflow that triggers on every PR, installs dependencies, runs the full test suite, runs lint, builds the project, comments the results on the PR, and caches node_modules .
Environment Setup Script
Write a script that a new developer can run once to set up the entire development environment: install dependencies, create .env from .env.example , spin up a local database, run migrations, seed test data, and verify everything with the test suite.
Release Notes Generation
Read the git log since the last tag and generate a changelog categorized as new features, bug fixes, performance improvements, and breaking changes. Write each entry in user‑friendly language and format it as markdown.
8. Documentation and Test Data
Feature Documentation Generation
After completing a feature, read every created or modified file and generate full documentation: each function’s purpose, how they connect, expected inputs/outputs, and any non‑obvious design decisions.
Doing this immediately yields more accurate docs than relying on memory later.
Test Data Construction
Create a comprehensive test‑data file for the development database: 5 users (1 admin, 2 editors, 2 viewers), 20 realistic sample projects, entity relationships, edge cases (archived projects, deleted users, projects without members). Use realistic values, not placeholder strings.
9. Dependency Management
Check Before Adding a New Dependency
I want to add [package name] for [specific scenario] . Check whether the package is still maintained, has known security issues, its impact on bundle size, and whether a lighter alternative exists that satisfies the requirement.
Resolve Dependency Conflicts
I encountered this conflict: [paste error] . Analyze the cause, identify which packages require the conflicting shared dependency version, and suggest the minimal‑change resolution with trade‑offs explained.
10. Debug and Issue Investigation
Full Error Paste
I hit this error: [paste full error message and stack trace] . Before giving a fix, walk through the root cause step by step.
The “step‑by‑step analysis” constraint prevents jumping to a premature conclusion.
Git Checkpoint
git add . && git commit -m "checkpoint: backup before change"Allows instant rollback to a known good state if something breaks.
Bug Reproduction Flow
User reported this bug: [paste bug report] . Create minimal reproduction steps (exact actions, expected vs. actual behavior). Write a failing test that captures the bug, then modify code until the test passes.
From reproduction to fix in a single pipeline.
Blame Investigation
This function started failing yesterday. Read its git log for the past week, identify the commit that likely introduced the issue, explain what changed, and suggest a fix.
11. Recovery Mode
Recovery Mode
When Claude Code produces a bad implementation after many iterations, stop and run: git show to retrieve the last known good version of the file, restate the original goal briefly, and restart with a new approach. Recognizing when to abort saves time.
Knowing when to cut losses is a key skill when using AI‑assisted development.
These 35 tips each include a ready‑to‑copy command or prompt. The core ideas are: bootstrap with /init and CLAUDE.md, plan first with Plan Mode, keep context clean with /compact, use incremental builds with tests, safeguard changes with Git checkpoints, and employ Recovery Mode when needed.
Su San Talks Tech
Su San, former staff at several leading tech companies, is a top creator on Juejin and a premium creator on CSDN, and runs the free coding practice site www.susan.net.cn.
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.
