Skip to content
effective-prompting logo

Effective Prompting for Claude Code

effective-prompting

Master effective prompting techniques for Claude Code. Use when learning prompt patterns, improving task descriptions, optimizing Claude interactions, or troubleshooting why Claude misunderstood a request. Covers @ mentions, thinking keywords, task framing, and iterative refinement.

SKILL.md

Full skill instructions

Effective Prompting for Claude Code

Write prompts that Claude Code understands and executes correctly the first time.

Quick Reference

TechniqueWhen to UseExample
@ mentionsInclude specific context@src/​api/​users.ts
ultrathinkComplex reasoning tasks"ultrathink about the architecture"
Success criteriaClear deliverables"Done when tests pass"
Task decompositionMulti-step work"First X, then Y, finally Z"
/​compactLong sessionsSummarize and continue

@ Mentions (Context Injection)

@ mentions pull specific context into your prompt. Use them liberally.

Types

MentionPurposeExample
@fileSingle file@src/​utils/​auth.ts
@folderDirectory contents@src/​api/
@urlWeb content@https://docs.example.com/​api
@gitGit context@git:diff, @git:log

File Patterns

@src/​api/​*.ts           # All TS files in api folder
@src/​**/​*.test.ts       # All test files recursively
@package.json           # Specific file
@src/​components/        # Entire folder

Best Practices

  • Be specific: @src/​api/​users.ts > @src/
  • Include tests: @src/​auth.ts @src/​auth.test.ts
  • Add related files: @types/​user.ts @src/​api/​users.ts
  • Limit scope: 3-5 relevant files > entire codebase

Thinking Keywords

Trigger deeper reasoning with specific keywords.

KeywordDepthUse Case
thinkStandardGeneral problem-solving
think harderExtendedComplex bugs, edge cases
ultrathinkDeepArchitecture, security, optimization
megathinkMaximumCritical decisions, complex refactors

When to Use Extended Thinking

  • Architecture decisions
  • Security-sensitive code
  • Performance optimization
  • Complex debugging
  • Multi-system integration
  • Breaking changes analysis

Example

ultrathink about how to refactor the authentication system
to support OAuth2 while maintaining backward compatibility
with our existing session-based auth @src/​auth/

Task Framing

Structure prompts for clarity and precision.

The WHAT-WHY-HOW Pattern

WHAT: [Specific task]
WHY: [Context/​motivation]
HOW: [Constraints/​approach]

Example:

WHAT: Add rate limiting to the /​api/​upload endpoint
WHY: Users are uploading large files too frequently, causing server strain
HOW: Use a sliding window approach, 10 requests per minute per user

Success Criteria

Always define "done":

Add user search to the dashboard.

Done when:
- Search input filters users in real-time
- Debounced to 300ms
- Shows "No results" for empty matches
- Tests cover happy path and edge cases

Constraints Pattern

Specify boundaries:

Implement caching for API responses.

Constraints:
- Use Redis (already configured in docker-compose)
- TTL of 5 minutes for user data
- No caching for POST/​PUT/​DELETE
- Must work with existing middleware

Multi-Step Tasks

For complex work, structure as steps.

Sequential Steps

Implement user authentication:

1. First, add the User model with email/​password fields
2. Then, create login/​register API endpoints
3. Next, add JWT token generation and validation
4. Finally, protect routes with auth middleware

Run tests after each step.

Parallel Work Indicators

These can be done in parallel:
- Add UserCard component
- Add UserList component
- Add UserSearch component

Then combine them in the UserDashboard page.

Checkpoints

Refactor the payment module.

Checkpoint 1: Extract PaymentService class
- Run tests, commit if green

Checkpoint 2: Add Stripe integration
- Run tests, commit if green

Checkpoint 3: Add webhook handling
- Run tests, commit if green

Iterative Refinement

Build complex features incrementally.

Start Simple

# Round 1
Add a basic todo list component with hardcoded items.

# Round 2
Now add the ability to add new todos.

# Round 3
Add delete functionality and persist to localStorage.

Feedback Loop

# Initial
Add pagination to the user list.

# After seeing result
Good, but the page buttons are too small on mobile.
Make them at least 44px tap targets.

# After fix
Perfect. Now add keyboard navigation (arrow keys).

Session Management

Using /​compact

When context grows large:

/​compact

Continue with: We're implementing user auth.
Done: User model, login endpoint.
Next: JWT middleware.

Context Reset

Let's start fresh on the auth system.
Ignore previous attempts.
Here's the new approach: [approach]

Common Prompt Patterns

PatternTemplate
Bug fix"Fix [bug]. Reproduce: [steps]. Expected: [X]. Actual: [Y]."
Feature"Add [feature]. Requirements: [list]. Done when: [criteria]."
Refactor"Refactor [code] to [goal]. Keep: [constraints]. Test: [how]."
Review"Review @file for [concerns]. Focus on: [areas]."
Debug"Debug why [symptom]. Context: @logs @code. Checked: [attempts]."

Reference Files

FileContents
PATTERNS.mdDetailed prompt patterns for specific tasks
EXAMPLES.mdReal-world prompt examples
ANTI-PATTERNS.mdCommon mistakes and how to avoid them

Validation Checklist

Before sending a complex prompt:

  • Included relevant context with @ mentions
  • Stated the goal clearly
  • Defined success criteria
  • Specified constraints
  • Used thinking keywords if needed
  • Broke down multi-step tasks
  • Provided examples if pattern is unclear

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View