TL;DR
Mastering your first conversations with Claude Code comes through concrete examples, from simple prompts to full explore-plan-code orchestration. Here are 10 practical demonstrations, sorted by difficulty, that you can copy and adapt to your projects right now. Each example includes the context, the exact command, and the expected result.
Mastering your first conversations with Claude Code comes through concrete examples, from simple prompts to full explore-plan-code orchestration. Here are 10 practical demonstrations, sorted by difficulty, that you can copy and adapt to your projects right now. Each example includes the context, the exact command, and the expected result.
Examples for your first conversations with Claude Code are the fastest way to learn how to interact with this command-line development assistant. Claude Code processes refactoring requests and generates functional code directly in your terminal, often returning a targeted edit within a few seconds for small changes. You can pick the model with /model (for example Sonnet or Opus) depending on the task.
In practice, a well-formulated prompt noticeably reduces the time spent on routine development tasks.
SFEIR Institute trainings
Claude Code Training
1 day · Fundamentals
AI-Augmented Developer
2 days · Intermediate
How to structure your first prompt in Claude Code?
Prompting in project context differs from generic prompting. Claude Code accesses your file tree, Git history, and dependencies. Formulate instructions that leverage this context.
A contextual prompt produces noticeably more accurate results than a generic one. In practice, a short, targeted prompt outperforms a long, vague one.
| Prompt type | Example |
|---|---|
| Generic | "Write a sort function" |
| Contextual | "Refactor the sortUsers function in lib/users.ts to use a stable sort" |
| Contextual + constraint | "Refactor sortUsers in lib/users.ts to stable sort, keep the TypeScript signature" |
To get started properly, check the guide on your first conversations which lays the foundations for interacting with Claude Code. Always prioritize specificity: file name, function name, target language.
Key takeaway: an effective prompt names the file, the function, and the technical constraint in a single sentence.
What are the beginner examples for discovering Claude Code?
Example 1 - Explore a project's structure
Context: You just cloned an unknown repository and want to understand its architecture.
$ claude
> Explore this project and give me a summary of the architecture: main folders, tech stack, entry point.
Expected result: Claude Code browses the file tree, reads the package.json (or pyproject.toml), identifies the framework, and produces a structured summary in a single pass.
Variant: Add "and list the 5 most modified files this month" to cross-reference architecture with Git activity.
Example 2 - Explain an existing function
Context: You come across a complex function in a legacy project.
> Explain the processQueue function in lib/queue.ts, line by line. Identify unhandled edge cases.
Expected result: Claude Code reads the file, breaks down the logic, and flags edge cases (empty queue, timeout, network errors) quickly.
If you encounter context comprehension difficulties, the context management tutorial will help you frame your exchanges. In practice, many who explicitly specify the target file get a usable response on the first try.
Example 3 - Fix a simple error
Context: Your build fails with a TypeScript error.
> Here is the error: "Type 'string' is not assignable to type 'number'" in src/utils/calc.ts:42. Fix the typing.
Expected result: Claude Code opens the file, identifies the type conflict, and proposes a targeted Edit. The fix applies quickly.
Variant: Directly paste the complete output of tsc --noEmit so Claude Code processes all errors in batch.
Key takeaway: for beginner examples, always name the file and line number. Claude Code works better with precise coordinates.
How to request code changes effectively?
Example 4 - Refactor a function
Context: You want to convert a callback function to async/await in a Node.js 22 project.
> Refactor the fetchData function in api/client.ts: replace callbacks with async/await. Keep the same return types.
Expected result: Claude Code rewrites the function, preserves the TypeScript signature, and verifies that existing calls remain compatible. The diff typically shows significant in line count.
Claude Code typically detects and adds missing imports during refactors. To avoid common mistakes in your first conversations, always specify the compatibility constraint.
Example 5 - Add data validation
Context: You need to add Zod validation to an existing API endpoint.
// Prompt in Claude Code:
// Add Zod validation to the POST /api/users route body in app/api/users/route.ts.
// Required fields: name (string, 2-50 chars), email (string, email format), role (enum: admin | user).
// Return 400 with formatted errors if invalid.
> Add Zod validation to the POST /api/users body in app/api/users/route.ts. Fields: name (string 2-50), email (email), role (admin|user). Return 400 if invalid.
Expected result: Claude Code creates the Zod schema, integrates it into the existing handler, and adds the structured error response. The generated code stays compact.
To control the modifications Claude Code applies to your files, first configure the permissions and security of your environment.
Key takeaway: detail the business constraints (length, format, enum) directly in the prompt for code generated without back-and-forth.
How to run commands and tests with Claude Code?
Example 6 - Run tests and fix failures
Context: You want to verify that your modifications haven't broken anything.
> Run npm test. If tests fail, analyze the errors and propose fixes.
Expected result: Claude Code runs the command, parses the output, identifies failing assertions, and proposes targeted Edits. Many simple test failures are resolved in a single exchange.
Advanced variant:
> Run npm test -- --coverage. If coverage is below 80%, add the missing tests for uncovered functions.
Before authorizing Claude Code to execute commands, check the permissions quickstart to understand the security model.
Example 7 - Analyze build performance
Context: Your Next.js build takes too long and you want to identify bottlenecks.
> Run ANALYZE=true next build and summarize the 5 largest bundles. Propose concrete optimizations.
Expected result: Claude Code executes the build with analysis, identifies heavy dependencies (e.g., moment.js at 300 KB) and suggests alternatives (e.g., date-fns at 45 KB). Swapping heavy dependencies for lighter alternatives can meaningfully shrink your bundle. The figures below are illustrative ecosystem sizes, not a measured Claude Code result.
| Dependency | Size before | Alternative | Size after |
|---|---|---|---|
| moment.js | 300 KB | date-fns | 45 KB |
| lodash | 71 KB | lodash-es (tree-shaking) | 12 KB |
| axios | 29 KB | native fetch (Node.js 22) | 0 KB |
Key takeaway: always combine command execution with an analysis request. Claude Code excels at interpreting CLI outputs.
What are the intermediate examples to progress?
Example 8 - Create a complete component with tests
Context: You need to create a React component with its unit test and Storybook story.
> Create a SearchBar component in components/SearchBar.tsx:
> - Controlled input with 300ms debounce
> - Props: placeholder, onSearch, isLoading
> - Unit test with Vitest in __tests__/SearchBar.test.tsx
> - Use the project conventions (look at existing components)
Expected result: Claude Code analyzes existing components to reproduce the style (CSS modules, Tailwind, etc.), generates the component and the test, and respects detected conventions. The output is spread across the two files (component and test).
To optimize Claude Code's context memory between your sessions, configure the CLAUDE.md memory system. Here is how: add your code conventions to the CLAUDE.md file at the project root.
Example 9 - The Explore → Plan → Code workflow
This three-phase workflow is the method recommended by SFEIR Institute for complex tasks. It typically reduces back-and-forth iterations compared to a single direct prompt.
Phase 1 - Explore:
> Explore the project's authentication system. Identify: the files involved, the login flow, the middleware, the token storage.
Phase 2 - Plan:
> Based on your exploration, propose a plan to add 2FA authentication via TOTP. List the files to modify, new dependencies, and steps in order.
Phase 3 - Code:
> Implement step 1 of the plan: install otplib, create the TOTP service in lib/auth/totp.ts with the functions generateSecret, verifyToken, and generateQRCode.
Expected result: Each phase produces a distinct deliverable. The Explore phase generates a code map. The Plan phase produces a structured, ordered list of steps. The Code phase implements one step at a time with clean diffs.
| Phase | Deliverable |
|---|---|
| Explore | Code map |
| Plan | Structured, ordered step plan |
| Code (per step) | Diff + modified files |
To go further on managing these phases, discover the tips for your first conversations which cover the workflow in detail.
Key takeaway: the Explore → Plan → Code workflow breaks down complexity. Execute each phase separately for total control.
How to manage long sessions and conversations?
Claude Code retains context in a window of approximately 200,000 tokens (the exact size depends on the selected model). As the conversation grows, the number of exchanges it can hold varies with the size of each message. Monitor the size of your context to avoid information loss.
> /compact
This slash command compresses the context while preserving important decisions. Claude Code also auto-compacts on its own as the context approaches capacity, but you can run /compact manually at any time when the context grows large.
Example 10 - Resume a session with context
Context: You worked yesterday on a refactoring and want to resume today.
> Read the CLAUDE.md file and the last commit. Summarize what was done yesterday on the auth module refactoring and what remains to do.
Expected result: Claude Code consults the project memory and Git history to reconstruct the context quickly. It produces an actionable summary with remaining tasks.
The FAQ on your first conversations covers frequent questions about context persistence and resumption strategies.
Key takeaway: start each new session with a request for a summary of the previous context. This aligns Claude Code with your progress.
What advanced examples illustrate the power of Claude Code?
Example 11 - Orchestrate a multi-file refactoring
Context: You are migrating a project from Next.js Pages Router API to the App Router. This task touches at least 15 files.
> Explore phase: list all files in pages/ that use getServerSideProps or getStaticProps. For each, identify the fetched data and passed props.
> Plan phase: propose a migration plan to the App Router with Server Components. Prioritize by increasing complexity. Indicate potential breaking changes.
> Code phase: migrate pages/products/[id].tsx to app/products/[id]/page.tsx. Convert getServerSideProps to async fetch in the Server Component. Verify that typing remains correct.
Expected result: Claude Code migrates each file in a focused pass. It preserves types, adapts imports, and flags incompatibilities (e.g., useRouter from next/router → next/navigation).
The Claude Code training offered by SFEIR Institute over 1 day lets you practice this type of advanced workflow in guided labs, from simple prompts to multi-file orchestration.
Example 12 - Generate a complete API from a schema
Context: You have a Prisma schema and want to generate the complete CRUD routes.
> Read the file prisma/schema.prisma. For the Product model, generate:
> 1. GET /api/products route (paginated list, filter by category)
> 2. GET /api/products/[id] route (detail with relations)
> 3. POST /api/products route (creation with Zod validation)
> 4. PUT /api/products/[id] route (partial update)
> 5. DELETE /api/products/[id] route (soft delete)
> Use Next.js App Router conventions. Add error handling.
Expected result: Claude Code generates 5 route files, a shared Zod validation schema, and centralized error handling. The total represents roughly a few hundred lines of code, generated in a single pass.
For additional context management examples in long conversations, explore the context management examples.
Key takeaway: for advanced tasks, always break down into Explore → Plan → Code. Even experienced developers save time with this approach.
How to customize these examples for your project?
Each example above adapts to your stack. Here is how to effectively customize your prompts.
| Element to adapt | Generic example | Your version |
|---|---|---|
| Framework | "React component" | "Vue 3 component with Composition API" |
| ORM | "Prisma schema" | "Drizzle ORM schema" |
| Tests | "Vitest test" | "Jest test with React Testing Library" |
| Style | "Tailwind" | "CSS Modules + CSS variables" |
Add your conventions to the CLAUDE.md file so Claude Code applies them automatically:
# CLAUDE.md
- Framework: Vue 3 + Composition API
- Tests: Vitest + Vue Test Utils
- Style: UnoCSS
- Conventions: camelCase for functions, PascalCase for components
In practice, a well-maintained CLAUDE.md file reduces post-generation manual corrections and improves the consistency of generated code. Teams that document their conventions in CLAUDE.md tend to accept generated code with fewer adjustments.
If you want to deepen the art of prompting and AI-assisted development workflow, the AI-Augmented Developer training covers over 2 days prompt engineering techniques applied to code, with labs on real projects. For those who already master the basics, the AI-Augmented Developer - Advanced module goes deeper in 1 day into multi-agent strategies and complex task orchestration.
Key takeaway: invest 10 minutes in your CLAUDE.md file. It is the most cost-effective lever for improving the quality of code generated by Claude Code.
Recent articles about Claude

Claude Managed Agents: Anthropic's Platform for Production Agent Deployment
Anthropic launches Managed Agents: a cloud platform for deploying AI agents in production. Secure sandbox, checkpointing, multi-agent, autonomous sessions lasting hours. Notion, Rakuten, Asana and Sentry already use it.

Claude Code Dream & Auto Dream: Automatic Memory Consolidation
After 20 sessions, Auto Memory notes become a mess. Auto Dream solves this by automatically consolidating Claude Code's memory: deduplication, stale entry removal, relative-to-absolute date conversion.

Claude Code Auto Mode: Autonomy Without the Risk
Auto Mode in Claude Code eliminates permission interruptions while keeping a safety net. A classifier analyzes every action before execution and blocks destructive operations. The sweet spot between approving everything and letting everything through.
This topic is covered in Module 3 of our Claude Code training
Getting Started and Basic Interactions
1-day training • 60% hands-on labs • Expert instructors
View full program