35 Practical Claude Code Tips with Ready‑to‑Use Commands

This guide presents 35 concrete Claude Code techniques—each with a ready command or prompt—to streamline project bootstrapping, session handling, code quality, architecture, API design, automation, debugging, and recovery for faster, more reliable software development.

SpringMeng
SpringMeng
SpringMeng
35 Practical Claude Code Tips with Ready‑to‑Use Commands

1. Project Startup in Four Steps

Begin a new project by running /init to scan the repository and generate a CLAUDE.md that records the project structure, tech stack, and coding standards, which will be automatically loaded in subsequent sessions.

Use /memory to open the persistent rule editor and 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 tests.

These rules are applied automatically in every new conversation.

Switch to Plan Mode with Shift + Tab ( Plan Mode) so Claude Code only analyses and proposes an architecture without writing code; confirm the plan before switching back to implementation mode.

Lock style conventions in CLAUDE.md by adding sections such as:

New file guidelines: - API routes: see src/api/example-route.ts - Database queries: follow the repository pattern in src/repositories/example-repo.ts - React components: reference src/components/ExampleComponent.tsx

Claude Code will automatically align new files with these conventions.

Project startup configuration
Project startup configuration

2. Session Management: Context Is a Scarce Resource

Periodically run /compact after 30–45 minutes of conversation to compress the dialogue into a concise summary that preserves key decisions and the current state, preventing gradual quality degradation.

Start a fresh task with /clear to wipe the context, avoiding cross‑contamination between unrelated features.

Monitor token usage with /cost and set a mental budget by checking it hourly.

Switch models for different phases: use Opus for planning and architecture decisions (deep but expensive) and Sonnet for concrete implementation (fast and cheap).

Execute terminal commands directly in the chat by prefixing them with !, e.g.:

!git status
!npm test
!ls src/

Run parallel sessions for separate concerns (e.g., backend in one window, frontend in another) to keep contexts clean.

Session management commands
Session management commands

3. Code Quality: Make Output Stable and Useful

Reference existing files instead of describing style in words. For example, ask Claude to implement password‑reset logic by copying the approach used in src/auth/login.ts.

Paste screenshots of UI issues and ask Claude to fix them, e.g., misaligned buttons and inconsistent card spacing.

Adopt a test‑first approach: write test cases covering normal discounts, zero discount, 100% discount, negative prices, and string inputs before implementing the discount function.

Use incremental builds: break a large feature into small steps, testing each step before proceeding, such as first creating only the database schema, then adding the API endpoint that uses it.

After each change, request a diff review with explanations for every modification.

Code quality tips
Code quality tips

4. Exploring an Unknown Codebase

Before modifying an unfamiliar module, ask Claude to explain the data flow from API routes to the database, the patterns used, and any prerequisites for changes.

5. Architecture & Refactoring

Perform an architecture audit before starting a new project by providing the requirements and asking Claude to propose two distinct architectural options, each with component diagrams, pros, cons, complexity estimates, potential issues, and a final recommendation.

When a file becomes too large (e.g., src/services/user-service.ts at 800 lines), request a refactoring plan that outlines a new file structure and the movement of code while ensuring external references remain intact. Emphasize “don’t start refactoring yet; only provide the plan.”

Generate database migration scripts for schema changes, such as adding a role enum field to the user table and renaming name to display_name, while listing all affected files before any modifications.

Architecture and refactoring
Architecture and refactoring

6. API Design & Security

Submit API definitions for review, asking Claude to check naming consistency, missing error responses, pagination needs, missing authentication, and REST violations, then provide concrete improvement suggestions.

Run a security scan that looks for SQL injection, XSS, exposed secrets, missing input validation, insecure direct object references, and lack of rate limiting, with severity, location, risk explanation, and remediation steps for each issue.

Perform a performance analysis to identify N+1 queries, missing indexes, unnecessary React re‑renders, large bundles that could be lazy‑loaded, and cache‑able API endpoints, prioritising fixes by impact.

7. Engineering Automation

Create a pre‑commit Git hook that runs lint, type checks, and detects stray console.log statements, aborting the commit on failure.

Set up a GitHub Actions CI pipeline that triggers on pull requests, installs dependencies, runs the full test suite, lints the code, builds the project, comments results on the PR, and caches node_modules.

Write an environment‑setup script that installs dependencies, creates a .env from a template, provisions a local database, runs migrations, seeds test data, and validates the setup with the test suite.

Generate release notes by reading the Git log since the last tag, categorising changes into new features, bug fixes, performance improvements, and breaking changes, and formatting them as markdown.

Engineering automation
Engineering automation

8. Documentation & Test Data

After completing a feature, ask Claude to generate comprehensive documentation by reading every modified file and describing each function’s purpose, connections, inputs, outputs, and hidden design decisions.

Construct realistic test data: five users (1 admin, 2 editors, 2 viewers), twenty sample projects with proper relationships, and edge cases such as archived projects, deleted users, and projects without members.

9. Dependency Management

Before adding a new package, request an assessment of its maintenance status, known security issues, bundle size impact, and lighter alternatives that satisfy the same requirements.

If a dependency conflict arises, ask Claude to analyse the conflict, identify the packages causing version clashes, and propose the minimal‑impact resolution with trade‑offs explained.

10. Debug & Issue Investigation

When an error occurs, paste the full stack trace and ask Claude to analyse the root cause step‑by‑step before suggesting a fix.

Create a Git checkpoint before large changes with git add . && git commit -m "checkpoint: pre‑change backup" to enable instant rollback.

For a reported bug, ask Claude to produce minimal reproduction steps, write a failing test that captures the bug, then fix the code until the test passes.

Use git blame to trace the commit that introduced a regression, explain the change, and suggest a fix.

Debug techniques
Debug techniques

11. Recovery Mode

If Claude Code repeatedly produces broken implementations, pause and restore the last known good version using git show, restate the original goal, and restart with a new approach.

Recognising when to stop and reset prevents wasted effort and is a key skill when leveraging AI‑assisted development.

Overall, the 35 tips emphasise initializing with /init and CLAUDE.md, planning before coding, compacting context, incremental builds with tests, Git checkpoints, and using Recovery Mode to stop loss.

AutomationPrompt Engineeringdevelopment workflowAI Coding AssistantClaude Code
SpringMeng
Written by

SpringMeng

Focused on software development, sharing source code and tutorials for various systems.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.