Using Claude Projects and Extended Thinking
1. Creating Claude Projects
| Command | Description | Flags |
|---|---|---|
| claude init | Initialize a new Claude project | --template <template-name> to use a specific template |
| claude project create | Create a new project with specified name and settings | --name <project-name>, --description <desc> |
Note: The
claude init command sets up the basic project structure and configuration files needed for AI-assisted development workflows.
2. Uploading Project Knowledge Files
| File Type | Description | Upload Method | Notes |
|---|---|---|---|
| .txt | Plain text files containing project documentation or notes | claude upload |
Supports files up to 10MB |
| .md | Markdown files for structured documentation | claude upload |
Preserves formatting and links |
| .json | JSON configuration or data files | claude upload |
Must be valid JSON format |
| PDF documents with project-related content | claude upload |
Text extracted and indexed for context |
Note: Uploaded files are indexed and made available to Claude for context during project conversations.
Warning: Files must not contain sensitive or proprietary information that should not be shared with AI systems.
3. Using Claude Extended Thinking Mode
Example: Activating Extended Thinking Mode
{
"model": "claude-3-5-sonnet",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
],
"tools": [
{
"name": "extended_thinking",
"type": "claude_extended_thinking"
}
]
}
| Parameter | Description | Values |
|---|---|---|
| tools | Enables extended thinking mode | [{"name": "extended_thinking", "type": "claude_extended_thinking"}] |
Note: Extended Thinking Mode is available in Claude 3.5 Sonnet and later models.
Extended Thinking Mode Capabilities
- Enables deep reasoning for complex problems
- Improves accuracy on multi-step tasks
- Supports complex mathematical and logical reasoning
- Enhances code generation and debugging
Extended Thinking vs Standard Mode
- Standard: Fast responses, basic reasoning
- Extended Thinking: Slower but more accurate for complex tasks
4. Comparing Claude Opus, Sonnet, and Haiku
| Model | Capabilities | Best For | Performance |
|---|---|---|---|
| Claude Opus | Highly capable, reasoning, and creative |
Complex tasks, long context, code generation | High |
| Claude Sonnet | Fast and accurate |
General purpose, balanced performance | Medium-High |
| Claude Haiku | Fastest, most efficient |
Lightweight tasks, quick responses | High |
Example: Model Selection
const model = process.env.MODEL || "claude-3-opus"; // or sonnet, haiku
if (model === "claude-3-opus") {
// Use for complex reasoning and code
} else if (model === "claude-3-sonnet") {
// Use for balanced performance
} else if (model === "claude-3-haiku") {
// Use for fast responses
}
Summary of Model Characteristics
- Opus: Highest capability, best for complex tasks.
- Sonnet: Balanced performance, good for general use.
- Haiku: Fastest, ideal for lightweight tasks.
5. Using Claude Artifacts for Code Preview
Example: Creating a Claude Artifact
claude artifacts create --name "my-artifact" --description "A sample artifact for code preview"
| Field | Description | Values |
|---|---|---|
| name | The name of the artifact | string |
| description | A brief description of the artifact | string |
| content | The content of the artifact (e.g., code) | string |
Note: Artifacts can be used to preview code changes or simulate development workflows.
Warning: Ensure that the artifact content is properly sanitized to avoid security risks.
Key Features of Claude Artifacts
- NEW Support for real-time code previews
- Integration with Claude's extended thinking capabilities
- Version control for code artifacts
6. Managing Claude Conversation Context
| Context Type | Description | Management Method | Notes |
|---|---|---|---|
| System Prompt | Initial instructions that define the AI's role and behavior | Predefined in project configuration or via API | Can be updated to change AI behavior without retraining |
| User Messages | Inputs from the developer during conversation | Logged and can be reviewed or edited in UI | Each message contributes to conversation history |
| Assistant Messages | Responses generated by Claude during the conversation | Automatically managed; can be cleared or summarized | May include code suggestions, explanations, or feedback |
| Memory Limits | Maximum number of messages retained in context window | Configurable up to 100 messages (default is 50) | Exceeding limit causes truncation of older messages |
Example: Setting Context Limits in Claude API
const claudeClient = new ClaudeClient({
maxContextLength: 100,
systemPrompt: "You are a senior software engineer specializing in React and Node.js development.",
temperature: 0.7
});
// Example usage with conversation history
const response = await claudeClient.sendMessage({
messages: [
{ role: "user", content: "How do I implement a login flow in React?" },
{ role: "assistant", content: "To implement a login flow in React..." }
],
maxTokens: 500
});
Note: Claude's context window is limited to 100 messages by default. For longer projects, consider using external tools or summarizing key parts of the conversation to maintain context.
Best Practices for Managing Conversation Context
- Keep system prompts concise but descriptive to guide AI behavior effectively
- Review and edit user messages before sending to ensure clarity and completeness
- Use assistant responses as a reference point for future queries to avoid repetition
- Summarize long conversations or extract key insights when approaching context limits
7. Using Claude Computer Use Features
| Feature | Description | Usage | Notes |
|---|---|---|---|
| Computer Use Mode | Enables Claude to interact with computer interfaces | claude --computer-use |
Requires Claude 3.5 Sonnet or newer |
| Screen Reading | Allows Claude to read screen content | claude --screen-read |
Supports multiple screen readers |
| File Operations | Enables file creation, modification, and deletion | claude --file-op |
Requires explicit permission to execute |
| Web Browsing | Enables Claude to browse the web for information | claude --web-browse |
May require API key for external services |
Note: Computer use features are experimental and may not be available in all environments.
Warning: Ensure proper permissions before enabling file operations to prevent unintended system changes.
| Feature | Status | Version Introduced | Notes |
|---|---|---|---|
| Computer Use Mode | NEW | 3.5 Sonnet | Enhanced interface support |
| Screen Reading | DEPRECATED | 3.0 | Replaced by Computer Use Mode |
| File Operations | NEW | 3.5 Sonnet | Requires explicit user consent |
| Web Browsing | BETA | 3.5 Sonnet | May have rate limits |
8. Configuring Claude System Prompts
| Property | Value | Description |
|---|---|---|
| system_prompt | "You are a helpful AI assistant..." |
Defines the behavior and persona of Claude |
| max_tokens | 1000 |
Maximum number of tokens to generate |
| temperature | 0.7 |
Controls randomness in generation (0-1) |
Example: Setting System Prompt
const Claude = require('claude-sdk');
const client = new Claude({
system_prompt: "You are an expert JavaScript developer who explains concepts clearly.",
max_tokens: 500,
temperature: 0.5
});
client.sendMessage("Explain closures in JavaScript");
Note: System prompts are effective for setting tone and context but don't override user input.
Warning: Overly restrictive system prompts may limit Claude's ability to adapt to user queries.
9. Understanding Claude Context Window Limits
| Limit Type | Value | Description |
|---|---|---|
| Input Context Window | 200K tokens |
Maximum number of tokens that can be processed as input in a single request |
| Output Context Window | 4K tokens |
Maximum number of tokens that can be generated in a single response |
| Total Context Window | 204K tokens |
Combined input and output token limit for a single interaction |
Note: Claude's context window is measured in tokens, not characters. A single token typically represents ~4 characters of English text.
Example: Token Estimation
// Estimate tokens in a string using Claude's tokenizer
const inputText = "This is a sample text to estimate token count.";
// Using Claude's tokenizer (e.g., via the client library)
const tokenCount = tokenize(inputText).length;
console.log(`Token count: ${tokenCount}`);
Managing Context Window Limits
- Break long prompts into smaller chunks to stay under the 200K input limit
- Use summaries or key points from previous conversations to reduce context
- Implement caching strategies for frequently used prompts or responses
- Monitor token usage to avoid exceeding the 204K total context window