Activate Claude's extended thinking mode for complex coding problems that require deep reasoning, architectural decisions, or multi-step problem solving.
By The Prompt Black Magic Team
How to Use
Use this prompt with Claude (Opus or Sonnet) when you need the model to think through a complex problem before answering. Works in Claude Code and the API.
The Prompt
I need you to think deeply about this problem before writing any code.
Problem: [DESCRIBE THE COMPLEX PROBLEM]
Context:
- Codebase: [LANGUAGE/FRAMEWORK]
- Constraints: [PERFORMANCE, COMPATIBILITY, OR DESIGN CONSTRAINTS]
- Scale: [DATA SIZE, USER COUNT, OR THROUGHPUT REQUIREMENTS]
Before you write a single line of code, I want you to:
1. **Analyze the problem space:** What are the core challenges? What makes this non-trivial?
2. **Consider approaches:** List 3 different architectural approaches with trade-offs for each (performance, maintainability, complexity)
3. **Identify edge cases:** What inputs, states, or conditions could break a naive implementation?
4. **Choose and justify:** Pick the best approach and explain your reasoning
5. **Plan the implementation:** Break it into ordered steps, noting dependencies between components
6. **Implement:** Write clean, production-ready code with error handling
7. **Verify:** Walk through your code mentally with a concrete test case
Take your time. Thoroughness matters more than speed here.
Pro Tips for Coding
Request code comments that explain the "why" not the "what" - future developers need reasoning, not obvious statement descriptions.
Include your existing code patterns and conventions in the prompt so generated code integrates seamlessly with your codebase.
Ask for unit tests alongside the implementation. Writing tests after the fact is harder than generating them together.
When to Use This Prompt
You are refactoring a monolithic function into smaller, testable units and need help planning the decomposition.
Your pull request needs comprehensive unit tests and you want to generate test cases that cover edge conditions.
You are integrating a third-party API and need boilerplate code with proper error handling and retry logic.
Expected Results
Refactoring plans that break monolithic code into modular, testable functions with clear interfaces.
Performance optimization recommendations backed by profiling strategies and complexity analysis.
API integration boilerplate with authentication, retry logic, rate limiting, and error response handling.
How to Customize This Prompt
Modify the testing framework references to match what your project already uses: Jest, Pytest, RSpec, or others.
Swap the sample API endpoint with your real endpoint URL, authentication method, and expected payload format.
Replace the language placeholder with your exact tech stack including framework version and runtime environment.