What's the fundamental difference between Claude Code and claude.ai's Artifacts? When should I use which?
Artifacts (claude.ai interface): runs in sandbox, can't access local files, can't install packages, can't run your real code. Good for: quick code prototypes, logic demonstrations, small tool quick previews.
Claude Code (command line): runs in your real dev environment, can read your entire codebase, install packages, run tests, directly modify files. Good for: real development tasks — debug, refactor, write tests, analyze entire projects.
Selection guide: just want to quickly see code effect or prototype an idea → Artifacts. Any meaningful work in your real codebase → Claude Code.
Practical example: 'write me a sorting function' → Artifacts is enough. 'Find out why my sorting behaves abnormally with duplicate values and fix it' → Claude Code (needs to read your code, possibly run your tests).
When Claude Code executes tasks, how do you ensure it doesn't make unwanted changes?
Built-in mechanisms: for all side-effect operations (create/modify/delete files, run terminal commands, install packages), Claude Code defaults to showing what it plans to do and waiting for your confirmation before executing. This lets you review each impactful step.
Your protections: most importantly, work under Git control. Before each batch of changes: ensure git status is clean. After Claude Code finishes: use git diff to carefully review all changes, git commit once confirmed; git checkout . to revert in one second if unsatisfied.
Use /permissions command to check and adjust Claude Code's operation permissions.
For complex tasks, use 'tell me what you plan to do, don't execute' mode to get a plan first, then execute after confirming it's reasonable.
Practical habit: after each meaningful sub-task (e.g., 'tests written'), do a git commit with a clear description. Gives you a clear progress record; any step that goes wrong can be precisely reverted.
How do you control Claude Code API Key costs? Is there an estimation method?
Rough estimates: small task (fix a bug, read 2-3 files): $0.05-0.20; medium task (write test suite, read 5-10 files): $0.20-0.80; large task (refactor a module, read 20+ files): $1-5.
Cost control methods: specify file scope — don't let Claude Code read the entire codebase; tell it 'only look at files in src/auth/ directory.' Regularly use /clear to reset context — long conversations accumulate costs faster. Set monthly spending limit in console.anthropic.com.
Usage monitoring: type /cost at end of Claude Code conversation to see cost statistics for that session.
Claude Pro users: if you have Claude Pro, preferably log in via claude.ai account (included in subscription); only switch to API Key when Pro usage limit is exhausted.
What advanced Claude Code features are worth exploring after mastering the basics?
Subagents: spawn multiple child Claude Code instances in parallel from main instance. Example: 'simultaneously analyze three modules of this codebase, each finding potential performance issues' — three child agents run in parallel, much faster than serial.
MCP Integration: connect GitHub, Jira, databases, and other tools via MCP. Example: 'find all open bug-related Issues on GitHub, sort by priority, then start fixing from highest priority' — Claude Code autonomously executes the entire flow.
Headless mode: claude --print "your task" runs Claude Code non-interactively. Good for CI/CD integration or automation scripts.
Plan mode: output a complete execution plan before any operations; you review and approve before execution. Especially useful for high-risk operations.
Recommendation: explore these after you're comfortable with basic task execution and Git workflows.
Claude Code is a command-line AI agent that reads, modifies, and executes your code directly in the terminal. Unlike claude.ai's chat interface, Claude Code can directly operate on your local files — reading entire codebases, finding bug root causes, writing tests, refactoring code — without copy-pasting.
Requirements: Node.js 18+; macOS, Linux, or Windows (WSL2 recommended); Anthropic API Key or Claude Pro/Max subscription. Cost: Claude Pro ($20/month) includes Claude Code with usage limits; API Key users pay per token (~$0.10-0.50 per coding conversation depending on complexity).
Run: npm install -g @anthropic-ai/claude-code. Launch with claude. First launch asks you to authenticate via Claude.ai account or API Key. Verify success: run claude in any directory and see the interactive prompt (`>`).
Start with a medium-difficulty task from your real codebase. Good first tasks: fixing a known bug, writing tests for existing code, refactoring a complex function.
For 'writing tests' example: navigate to project → run `claude` → describe the task: 'Write unit tests for all functions in src/utils/formatter.js using Jest, place test files in tests/utils/.' Claude Code reads the file, analyzes each function, and starts writing tests — showing each step.
Create a CLAUDE.md file in your project root with: tech stack, project structure, code style guidelines, common commands, special configurations. Every Claude Code session automatically reads this — no need to re-explain context each time.
Describe outcomes not steps. Use /clear to reset context between tasks. Work under Git tracking (git diff to see changes, git checkout to revert). Use /compact to compress long conversations. For complex tasks, ask for a plan before execution.