[Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview) is an agentic coding tool. As a [[command line interface|CLI]] you don't even need an [[IDE]]. Just `cd` into the project folder and tell Claude Code to (1) explain the code, (2) make changes and (3) deploy.
You'll use the Anthropic API directly so set up a billing account at the [Developer Console](https://cosole.anthropic.com/dashboard). Claude should set up an API key for you automatically within the Claude Code workspace.
The session cost is printed at the end of your session. Use the `/cost` command to track cost during a session.
## install
To install Claude Code, you must first enable [[Windows Subsystem for Linux|WSL]] on your machine.
- Open your Linux terminal (Ubuntu or other distribution, depending on your setup of WSL)
- Update package list: `sudo apt update`
- Install Node.js using `nvm` (node version manager)
```bash
curl -o- https://raw.githubusercontent.com/nvm-sh/v0.39.3/install.sh | bash
```
- Close and reopen your terminal (or [[source your profile]])
- Install Node.js 22
```bash
nvm install 22
```
- Verify installation with `node --version`.
- Install Claude Code
```bash
npm install -g @anthropic-ai/claude-code
```
- `cd` into the desired directory (where your code lives, which is also limits the scope of what Claude is allowed to edit).
- Start Claude Code with command `claude`
- Exit with `quit`
## Claude Code best practices
The folks at Anthropic provided a list of [best practices](https://www.anthropic.com/engineering/claude-code-best-practices) for coding with Claude Code.
### create a `CLAUDE.md` file
In your project root, create a new file called `CLAUDE.md`. Claude references this when starting a conversation. There is no format, just keep it clean and human-readable. Here is an example
```markdown
# Bash commands
- npm run build: Build the project
- npm run typecheck: Run the typechecker
# Code style
- Use ES modules (import/export) syntax, not CommonJS (require)
- Destructure imports when possible (eg. import { foo } from 'bar')
# Workflow
- Be sure to typecheck when you’re done making a series of code changes
- Prefer running single tests, and not the whole test suite, for performance
```
Adjust the instructions in this file if you are not getting the results you want. In a Claude Code session, press the `#` key to add instructions to this file. Use [prompt improver](https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/prompt-improver) to fine tune even further.
You can also store this in your `projects` folder (root for all projects), your home folder, or a child of the directory like `ai/CLAUDE.md`.
Consider including this file in your `.gitignore`.
### explore, plan, code, commit
While Claude Code can be successful in building boilerplate apps in one go, it's best to help it work through the process by first exploring files in the repo, planning the next step, coding the next step, and then commit.
You can ask Claude to read documentation by giving it the URL.
### testing
Ask Claude Code to write tests and run tests so it can iterate through to a working solution.
### provide feedback
Help Claude access its work. Use [Puppetter](https://github.com/modelcontextprotocol/servers/tree/c19925b8f0f2815ad72b08d2368f0007c86eb8e6/src/puppeteer) MCP server to give Claude access to screenshots of the browser. You can also simply drag-and-drop screenshots directly into the prompt input.
### clear the context window
Use `/clear` to clear the context window after long sessions or when you want to start on a task fresh.
### run multiple instances in parallel
You can spin up multiple Claude instances on the same repo to have one code and another check its work (or simply use `/clear` after coding to get a fresh start and `/clear` again after verifying).
> [!Tip]- Additional Resources
> - [Claude Code Best Practices](https://www.anthropic.com/engineering/claude-code-best-practices)