CoursesAI-powered Sanity developmentClaude Code
AI-powered Sanity development

Claude Code

An introduction to Claude Code, Anthropic's AI-powered coding tool. Learn how to install it, navigate its interface, and use it to write and edit code with AI assistance.
Log in to mark your progress for each Lesson and Task

Claude Code is a terminal-based AI coding agent. Instead of a GUI, you work in your shell. It reads your project files, applies changes, runs commands, and explains what it's doing, all from the command line.

It's a good fit if you're already comfortable in the terminal and prefer not to maintain a full IDE setup, or if you're working on a remote machine or in a CI context.

Claude Code is installed as a global npm package. Before you begin, make sure you have Node.js installed on your machine. npm comes bundled with it.

To install Claude Code, run the following command in your terminal:

npm install -g @anthropic-ai/claude-code

Claude Code is free to try, with usage-based pricing. You pay only for what you use. If you're already on a Claude Pro, Max, or Team plan, Claude Code usage is included.

Install Claude Code by running npm install -g @anthropic-ai/claude-code in your terminal

Once installation is complete, you can verify it worked by running claude --version in your terminal. You should see the installed version number printed to the screen.

Unlike GUI-based IDEs, Claude Code has no separate application window. You do not launch it from a dock, a desktop shortcut, or an applications folder. It lives entirely in the terminal.

Navigate to your project directory and run claude to start a session

Claude Code can read any file in the directory where you ran claude, and its subdirectories. The closer your working directory is to the task, the better its responses will be.

This opens an interactive session. Claude reads your project structure and is ready for prompts. You can describe what you want to build, and it will work through the task: editing files, running commands, iterating on errors.

Once Claude Code is running, you interact with it through a REPL-style interface. You type a prompt, press Enter, and Claude Code responds.

There are two broad ways to use it.

You can ask Claude Code questions or request explanations about your code. This is similar to Ask mode in Cursor: you get a response in the terminal, but nothing in your project changes. It is useful for understanding unfamiliar code, exploring options, or getting a second opinion before making changes.

You can also give Claude Code tasks to perform autonomously. In this mode, it will read files, write new ones, and edit existing code in your project, all without you having to copy and paste anything. By default, Claude Code shows you exactly what it intends to do and asks for your confirmation before applying any changes. You stay in control, and can loosen these guardrails later once you trust it for routine edits.

A concrete example. From a Sanity Studio project, a prompt like "Add a category field to my post schema, with references to a new category document type, and regenerate the TypeGen types" triggers a predictable pattern:

  1. Claude Code reads schemas/post.ts and nearby schema files.
  2. It drafts schemas/category.ts, adds a reference field to post, and shows you both diffs.
  3. After you approve, it runs npx sanity schema typegen and shows the updated sanity.types.ts.
  4. If the TypeGen run fails, it reads the error, proposes a fix, and asks again.

The pattern holds for most tasks: read → propose → confirm → apply → verify.

Type a question or task into the Claude Code prompt and press Enter to see it respond

Claude Code supports slash commands for common workflows. Type / in a session to see what's available. The Sanity Agent Toolkit (covered in the next lesson) adds its own slash commands here, which is one reason Claude Code pairs well with Sanity development.

The main difference is the environment, not the capability. Claude Code uses the same underlying model as Cursor's Agent mode. The practical difference is that Claude Code is fully keyboard and terminal-driven, with no GUI for reviewing file diffs visually. Some developers find this faster; others find the Cursor interface easier to navigate when changes are complex.

In the following lessons you'll prepare your environment for the best possible Sanity implementation. You could skip these steps, but your results wouldn't be nearly as good.

Let's prepare for success.

You have 3 uncompleted tasks in this lesson
0 of 3