Ineffective:
fix this code
Effective:
Fix the memory leak in the user authentication service by properly closing database connections
With context:
Implement a user profile page that matches our existing UI style in `src/components/auth/`
and integrates with the `userService` in `src/services/`.
For complex tasks, break them into steps:
Refactor the authentication system:
1) Identify all authentication-related files
2) Analyze the current implementation
3) Suggest a cleaner architecture
4) Implement the changes one file at a time
Use XML tags for complex prompts:
<instructions>
Review this code for security vulnerabilities
</instructions>
<example>
Check for SQL injection, XSS, and authentication bypasses
</example>
<formatting>
Return findings in a markdown table with severity ratings
</formatting>
Claude Code supports different thinking depths:
| Keyword | Thinking Level | Use Case |
|---|---|---|
think |
Basic extended thinking | Standard analysis |
think more |
Medium depth | Complex problems |
think harder |
Deep analysis | Architectural decisions |
ultrathink |
Maximum thinking budget | Critical system design |
Use ultrathink for maximum reasoning:
ultrathink: Analyze this codebase and suggest architectural improvements
for handling 10x current traffic
Best for:
Press Tab to activate Plan Mode - Claude analyzes and plans without making changes.
Combining Ultrathink and Plan Mode:
Claude code is only as good as context you give to it.
| Command | Description |
|---|---|
<esc> + <esc> |
Rewind conversation to earlier point |
/compact |
Summarize conversation and continue |
/clear |
Clear context for new task |
/context |
Show current context usage |
@# Reference a single file
> Explain the logic in @src/utils/auth.js
# Reference a directory
> What's the structure of @src/components?
# Multiple files
> Compare @file1.js and @file2.js for consistency
# Specific lines
> @src/api/users.ts:50-100
/context regularly/clear between unrelated tasks/compact for long sessions~/.claude/CLAUDE.md # Global preferences (all projects)
~/project/.claude/CLAUDE.md # Project-specific instructions
~/project/src/.claude/CLAUDE.md # Subsystem-specific context
# Project Name
## Project Description
Brief overview of your project's purpose.
## Tech Stack
- Frontend: [Technologies]
- Backend: [Technologies]
- Database: [Technologies]
## Code Conventions
- [Coding standards]
- [Naming conventions]
- [Styling guidelines]
## Development Commands
- Start: [Command]
- Test: [Command]
- Build: [Command]
## Project Structure
- `/src`: Main source code
- `/tests`: Unit and integration tests
## Important Notes
- [Specific instructions]
| Guideline | Description |
|---|---|
| Keep Focused | Each file addresses a single concern |
| Be Specific | Provide clear, actionable instructions |
| Use Descriptive Names | api-validation.md not rules1.md |
| Regular Updates | Review as project evolves |
Tell Claude to use subagents for parallel work:
Use 3 sub-agents to analyze these files:
1. Security analysis of auth.ts
2. Performance review of cache system
3. Type checking of utils.ts
| Mode | Description | Use Case |
|---|---|---|
| Parallel | Independent tasks | No dependencies |
| Sequential | Dependent tasks | Results feed next step |
Sequential Workflow:
Parallel Workflow: Multiple subagents on independent tasks simultaneously.
Hooks are shell commands that execute in response to events.

| Hook Type | Trigger | Use Case |
|---|---|---|
PreToolUse |
Before tool runs | Validation, logging |
PostToolUse |
After tool completes | Cleanup, notifications |
Notification |
Claude notifications | Alerts |
Stop |
Claude finishes | Final actions |
SubagentStop |
Subagents complete | Coordination |
.claude/settings.json (shared)~/.claude/settings.json (personal).claude/settings.local.json (not shared){
"hooks": {
"PreToolUse": [
{
"matcher": "Edit",
"hooks": [
{
"type": "command",
"command": "echo 'File being edited' >> ~/claude-ops.log"
}
]
}
]
}
}
Check available hooks with /hooks command.
Create Markdown files in .claude/commands/ (project) or ~/.claude/commands/ (personal).
Example - deploy.md:
---
description: Deploy application to staging environment
---
Please perform a production-ready deployment:
1. Run all tests and ensure they pass
2. Build the application for production
3. Run security checks and linting
4. Deploy to staging environment
5. Verify deployment health checks
6. Provide deployment summary
---
argument-hint: [issue-number] [priority]
description: Fix a GitHub issue
---
Fix issue #$1 with priority $2.
Check the issue description and implement the necessary changes.
Invoke with: /fix-issue 123 high
---
allowed-tools: Bash(git add:*), Bash(git status:*), Bash(git commit:*)
description: Create a git commit
---
## Context
- Current status: !`git status`
- Current diff: !`git diff HEAD`
## Task
Create a git commit with appropriate message based on the changes.
Model Context Protocol (MCP) connects Claude Code to external tools and data sources.
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_TOKEN": "${GITHUB_TOKEN}"
}
}
}
}
"Add the feature described in JIRA issue ENG-4521 and create a PR on GitHub."
"Check Sentry and Statsig to check the usage of the feature."
"Find emails of 10 random users from our Postgres database."
"Update our email template based on the new Figma designs posted in Slack."
Configure LSP servers for better code intelligence:
| Mode | Activation | Description |
|---|---|---|
| Normal | Default | Prompts for each action |
| Plan Mode | Tab |
Analyzes without changes |
| Auto-Accept | Shift+Tab |
Auto-approves file edits |
| YOLO Mode | --dangerously-skip-permissions |
Bypasses all prompts |
Security Note: Use Auto-Accept and YOLO modes only in controlled environments.
claude -p "Your prompt here" --allowedTools "Bash,Read" --permission-mode acceptEdits
Key Flags:
-p / --print: Non-interactive mode--allowedTools: Specify permitted tools--output-format: Set output format (text, json, stream-json)name: AI Code Review
on:
pull_request:
paths:
- '**/*.js'
- '**/*.ts'
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run Claude Code Review
run: |
claude -p "Review this PR for code quality" --allowedTools "Read,Glob,Grep"
Run multiple Claude Code sessions on different branches:
# Create worktrees for parallel development
git worktree add ../project-feature-a -b feature-a
git worktree add ../project-feature-b -b feature-b
# Run Claude Code in each worktree
cd ../project-feature-a && claude
cd ../project-feature-b && claude
Benefits:
| Strategy | Description |
|---|---|
| Selective File Reading | Specify only necessary files |
| Use Grep Before Read | Search to identify relevant files |
| Targeted Mentions | Use specific file/line references |
| Limit Output Verbosity | Request concise outputs |
| Batch Operations | Combine related tasks |
Propose a few fixes for issue #123, then implement the one I pick
Identify edge cases not covered in `@app/run.py`, then update tests. think hard
Use 3 parallel agents to brainstorm ideas for cleanup of `@services/xxx.cpp`
commit, push, pr
Check why this function changed, use git history
Use bk CLI to create project
| Anti-Pattern | Problem | Solution |
|---|---|---|
| Windows-style paths on Unix | Compatibility issues | Use forward slashes |
| Too many options | Confuses users | Provide clear default |
| Testing mock behavior | Unreliable tests | Test actual behavior |
| Not encoding intent upfront | Misaligned results | Define standards clearly |
| Vague instructions | Ambiguous outputs | Be specific and actionable |
/compact, /clear, /context)