How to Use Claude Code: Setup, Commands, and Workflows

Written by Coursera Staff • Updated on

Learn how to use Claude Code in the terminal, alongside VS Code and Cursor, and on the web. Explore practical coding workflows, debugging, Git, and tips for getting better results.

[Featured Image]: A person wearing a denim jacket sits in front of a laptop and looks at the screen, practicing how to use Claude Code.

Key takeaways

  • You use Claude Code by installing and authenticating it, then using natural language prompts to understand a codebase, write and refactor code, debug issues, and support Git workflows.

  • Beginners can use Claude Code, though familiarity with basic programming concepts and the command line makes it easier to evaluate its suggestions and work more confidently.

  • You can use Claude Code from the terminal, alongside VS Code and Cursor, or on the web, depending on your development workflow and project needs.

Review the code from Claude Code, test it in your development environment, and evaluate it before incorporating it into your project. Learn how to use Claude Code across common development workflows and find example prompts in the following article.

If you're ready to build AI-assisted development skills, enroll in the IBM AI Developer Professional Certificate to learn to develop AI-powered applications, work with generative AI tools, and apply AI to real-world software development workflows.

What is Claude Code?

Claude Code is Anthropic's agentic coding tool. You use it from your terminal to read, edit, test, and explain code using your codebase as context while working within your existing development workflow.

Claude Code on the web works a little differently. Unlike the terminal version, it runs remotely rather than on your local computer, and you submit tasks from claude.ai/code in your browser or from the Claude mobile app. You'll need a GitHub repository connected to get started with that version.

How to install and authenticate Claude Code

To start using Claude Code, install it, sign in with your Anthropic account, and open the project directory you want to work in. From there, you start a session and ask an initial question. Claude Code can orient itself in your codebase before you ask it to make changes.

Once you're comfortable with that first exchange, you can ask Claude Code to make an actual code change, introduce it to your Git workflow so it can commit and branch on your behalf, and try a few other common workflows, like fixing a bug or adding a small feature, to see how it handles real tasks. Each of these steps builds on the last, so it's worth working through them in your own project rather than throwaway files, since Claude Code uses your project repository as context when responding to prompts.

Is Claude Code good for beginners?

Beginners can use Claude Code, but it helps to know the basics of programming and feel comfortable working at the command line. Recent updates allow Claude Code to handle longer and more complex tasks with less manual guidance, which makes it more important to understand and review each proposed change.

Where to use Claude Code: Terminal, VS Code, and Cursor

Where you run Claude Code affects how you interact with Claude Code and which features are available, whether that's the terminal, VS Code or Cursor, or the web. Use Claude Code on the web when you want to run several independent tasks in parallel, work with repositories you haven't checked out locally, and explore a codebase without a local setup.

How to use Claude Code in the terminal

To use Claude Code in the terminal, open your terminal and run the command-line interface (CLI) directly inside your project directory to work in Claude Code's native environment. This gives you the most direct control: full slash-command support, keyboard-driven workflows, and access to every configuration flag as Anthropic adds it. If you need to reach your local terminal setup from another machine, Remote Control extends that same environment without requiring you to work locally.

How to use Claude Code in VS Code

In VS Code, install the Claude Code extension to add a visual panel directly to your editor, so you can review changes and manage sessions without leaving the interface you already use. The extension shows proposed edits as inline diffs, lets you rewind to an earlier checkpoint if a change doesn't work out, and lets you review Claude Code's plan before it touches any files. If you need features that aren't available in the extension, open VS Code's integrated terminal and use Claude Code there. Cursor shares the same editor foundation as VS Code, so you can set up Claude Code's terminal keybindings, like Shift+Enter, in the same way you would in VS Code.

How do I understand a codebase with Claude Code?

Understanding a codebase gives you the context to make more informed changes. Claude Code can identify key files, explain how components interact, and trace the flow of data or requests through an application, helping you build a clearer picture of how a project is organized before you begin editing code.

This workflow can be especially helpful when you're joining a new project or contributing to an existing repository. Rather than opening files one by one, you can ask Claude Code focused questions about the application's architecture, specific features, or the relationships between different parts of the codebase.

Prompt example: Explain how user authentication works in this repository. Identify the primary files involved, describe how a login request moves through the application, and point out any middleware or configuration files that affect authentication.

Claude Code can use your repository as context to identify the relevant files, summarize how the authentication flow works, and explain how the components connect. You can continue the conversation with follow-up questions about individual functions, classes, or directories to develop a deeper understanding of the project before making changes.

How do I write and refactor code with Claude Code?

Writing and refactoring code with Claude Code can help you improve existing code, modernize older implementations, and make targeted changes within your project. Whether you're updating an existing implementation or refactoring old code, providing clear context and specific objectives can help Claude Code generate more useful suggestions.

Rather than requesting broad changes across an entire application, focus each prompt on a single feature, file, or module. Smaller, well-defined tasks make it easier to review proposed changes, test the results, and continue building on previous work as your project evolves.

Prompt example: Refactor the user authentication module to reduce duplicate logic while preserving the existing functionality. Explain each significant change before applying it, and recommend any additional tests that would help verify the refactored code.

Claude Code can suggest code changes, explain the reasoning behind them, and recommend tests or additional improvements based on the surrounding project context. 

How do I debug with Claude Code?

Debugging with Claude Code can help you investigate unexpected behavior, understand error messages, and explore potential solutions without losing sight of the surrounding project context. Sharing details such as error logs, stack traces, or the steps needed to reproduce an issue gives Claude Code the information it needs to provide more relevant suggestions.

As Claude Code investigates the issue, it can trace the execution path, identify files related to the error, and explain how different parts of the application may contribute to the problem. You can use its suggestions as a starting point, then verify the proposed solution by testing the changes in your development environment.

Prompt example: Users receive an HTTP 500 error after submitting the registration form. Analyze the relevant files, explain the likely cause of the error, recommend a fix, and suggest tests to verify the solution.

Claude Code can summarize its findings, recommend code changes, and suggest additional tests based on the repository context. 

How do I use Claude Code with Git? 

Using Claude Code alongside Git can help you organize changes and prepare your work for review. Rather than replacing Git, Claude Code supports common version control workflows throughout the development process.

As you work through a project, Claude Code can suggest commit messages, summarize the changes you've made, and draft pull request descriptions or project documentation, making it easier to communicate changes with collaborators.

Prompt example: Review the changes in this branch, suggest a clear commit message, and draft a pull request summary that explains the purpose of these changes.

Claude Code can summarize the changes in your repository, recommend commit messages, and generate documentation that reflects your edits. Before committing or opening a pull request, review the proposed summaries to confirm they accurately describe your work.

Learn more: What Is Git? Use Cases and FAQ

How do I get better results from Claude Code?

  • Give real context: Point Claude Code to the specific files or features involved instead of describing your project in general terms.

  • Break large tasks into steps: Ask for one meaningful change at a time rather than an entire feature in one prompt. The prompts above ask for several things at once, but they're all steps toward one task, not several tasks bundled together.

  • Review before you accept: Treat Claude Code's suggested changes the way you'd treat a colleague's pull request, not as a finished product.

  • Use checkpoints when available: Claude Code can save your code state before a change and let you rewind if something doesn't work out, which makes it easier to experiment without risk.

Can anyone use Claude Code?

Anyone with a Claude subscription or Anthropic Console account can use Claude Code. If you need to learn basic programming concepts and how to use the command line, you can still learn Claude Code alongside these skills. It just may take more patience to get there.

Keep building AI skills

Subscribe to our Career Chat newsletter on LinkedIn for industry insights, skill-building tips, and networking opportunities. Then, explore our free resources for building AI skills:

Whether you want to develop a new skill, get comfortable with an in-demand technology, or advance your abilities, keep growing with a Coursera Plus subscription. You’ll get access to over 10,000 flexible courses. 

Updated on
Written by:

Editorial Team

Coursera’s editorial team is comprised of highly experienced professional editors, writers, and fact...

This content has been made available for informational purposes only. Learners are advised to conduct additional research to ensure that courses and other credentials pursued meet their personal, professional, and financial goals.