Skip to main content

Claude Code: A Guide With Practical Examples

Learn how to use Anthropic's Claude Code to improve software development workflows through a practical example using the Supabase Python library.
Updated Jan 15, 2026  · 12 min read

Claude Code is an agentic coding tool developed by Anthropic that operates directly in the terminal, assisting developers in refactoring, documenting, and debugging code efficiently. By understanding the entire codebase, Claude Code helps simplify workflows, making it a powerful tool for software development. In January 2026, Anthropic launched Claude Code 2.1 and Claude Cowork.

In this tutorial, I’ll explain how to use Claude Code to improve software development workflows by refactoring, documenting, and debugging code. Specifically, we will:

  • Refactor a file from the supabase-py repository to improve code readability and maintainability.
  • Add documentation and inline comments to improve understanding of the existing codebase.
  • Identify and resolve errors using Claude Code’s debugging capabilities.

You will learn how to integrate Claude Code into your development process for a more efficient and automated experience. Before we start, make sure to also check our short video coverage of Claude 3.7 Sonnet and Claude Code:

What Is Claude Code?

Claude Code is a tool that operates directly in your terminal, understanding your codebase and assisting with development tasks using natural language commands. It integrates with your development environment with minimal setup, so you can focus on writing and improving code.

claude code features

Here are a few key capabilities of Claude Code:

  • Editing and refactoring: Modify, optimize, and enhance your codebase with AI-powered suggestions.
  • Bug fixing: Identify and resolve errors, missing dependencies, and performance bottlenecks.
  • Code understanding: Ask questions about your code’s architecture, logic, and dependencies.
  • Automated testing & linting: Execute and fix failing tests, run linting commands, and improve code quality.
  • Git integration: Search through git history, resolve merge conflicts, create commits, and generate pull requests effortlessly.

Whether working on an open-source project or managing enterprise-level codebases, Claude Code can help you with intelligent automation that adapts to your coding style and project requirements. The recent update to Claude Code 2.1 improves interactive usability, adds optional response-language settings, and expands customization and control for more reliable automated agentic workflows.

Here are some ideal users for this service:

  • Software Developers: Improving code quality and maintainability.
  • Open Source Contributors: Understanding and enhancing unfamiliar codebases.
  • DevOps Engineers: Automating code review and linting tasks.

Claude Code now uses Claude Sonnet 4.5, meaning you can use the same model Anthropic's researchers and engineers use right in your terminal, or build AI agents using the Claude Agents SDK.

Anthropic has also introduced Cowork for agent-style help with everyday file and document tasks beyond coding. It is available as a research preview for Max plan subscribers using the Claude Desktop app on macOS. Users on other plans can join the waitlist for future access.

Multi-Agent Systems with LangGraph

Build powerful multi-agent systems by applying emerging agentic design patterns in the LangGraph framework.
Explore Course

Let’s get started with our hands-on project.

Step 1: Setting Up Claude Code

To get started with Claude Code, you need a terminal, a code project to work in, and either a Claude subscription (Pro/Max/Teams/Enterprise) or a Claude Console account with active billing.​

Install Claude Code simply by running one of the following commands on your terminal, depending on your operating system and terminal.

macOS / Linux / WSL: 

curl -fsSL https://claude.ai/install.sh | bash

Windows PowerShell: 

irm https://claude.ai/install.ps1 | iex

Windows CMD:  

curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

Note: Installation via npm install -g @anthropic-ai/claude-code still exists but is deprecated, so you should prefer the native installation process mentioned above. If you previously installed via npm, you can migrate with claude install.

Once installed, navigate to your project directory and start Claude by running:

cd your-project-directory
claude

For authentication, you will be asked if you want to use Claude Code based on a paid subscription or API usage billing.

Screenshot 2026-01-16 at 9.01.43.png

Next, you will receive a login link leading to a verification code that you have to enter in the terminal running Claude Code. Then you're done, and a dedicated “Claude Code” workspace is automatically created for usage tracking and cost management.

Claude Initialized on terminal

Now, Claude Code is ready to use.

Step 2: Set Up Development Environment

For this demo, I’ll use the Supabase Python library supabase-py, an open-source Python client for interacting with Supabase, a backend-as-a-service built on PostgreSQL. Supabase provides a suite of tools, including authentication, real-time subscriptions, storage, and auto-generated APIs.

Let’s begin by cloning the repository and setting up our development environment.

1. Open your terminal, navigate to the directory where you want to clone the Supabase-py repository (e.g cd Desktop), and run the following command:

git clone https://github.com/supabase/supabase-py.git
cd  supabase-py

2. Next, create a virtual environment and install the required dependencies by running the following commands in your terminal one at a time

python3 -m venv env
source env/bin/activate  # On Windows, use ./env/Scripts/activate
pip install -e .

Your Python environment is now set up with all the necessary dependencies to run the Supabase library, and your repository is ready to be explored. 

Step 3: Identify Areas for Contribution

A great way to contribute is by exploring the Issues tab on GitHub. In the Supabase repository, I identified an issue in client.py related to code readability, structure, and lack of meaningful comments.

Here is what we are going to do with Claude Code:

  • We’ll refactor the code to enhance readability, maintainability, and structure.
  • Add meaningful docstrings and inline comments to clarify the purpose of different components.
  • Identify and fix bugs by analyzing issues and other potential errors.

Step 4: Experimenting With Claude Code

Since we are already in the supabase-py folder, navigate to the supabase directory containing the client.py file and run Claude Code:

cd supabase
claude

Claude Code in terminal

Claude Code now has access to every file and folder within the Supabase-py folder. Now, let’s experiment.

Refactoring code

As part of improving the Supabase Python SDK, let's refactor the client.py file to enhance readability, maintainability, and organization. Simply enter the following prompt in the command line:

Prompt: Refactor the code in the client.py file located in the Supabase folder.

Claude will ask for confirmation before proceeding. Press Enter to approve the changes. Once complete, Claude Code will update the file, display the modifications in the terminal, and provide a summary of the changes made.

Using Claude Code, we applied the following improvements to client.py:

  • Organized imports:  Claude Code grouped related imports into logical sections (auth errors, API types, function errors), renamed imports for clarity, and removed redundant aliases for consistency.
  • Enhanced readability: It added section comments to classify imports and removed duplication in the __all__ list for cleaner organization.
  • Simplified client options: It also reduced multiple lines by combining similar imports into a single statement.

Here is a side-by-side comparison of original and refactored code.

comparison of original and refactored code

comparison of original and refactored code

Documenting code

In addition to refactoring, Claude Code is a powerful tool for generating, enhancing, and standardizing code documentation. It can identify undocumented sections, generate structured docstrings or comments, and ensure compliance with project documentation standards.

We used Claude Code to improve the documentation in client.py, resulting in:

  • Clear module-level docstrings explaining the purpose of the file.
  • Detailed section comments categorizing imports (error types, client implementations, storage services).
  • Inline comments to describe error types, client functions, and important components.

Here is a side-by-side comparison of refactored and documented code.

Prompt: Document the client.py code by adding comments to improve understanding.

comparison of refactored code and documented code.

Once the documentation is added, you can verify its compliance with your project standards by prompting Claude:

Prompt: Check if the documentation follows our project standards.

Fixing bugs

Debugging can be time-consuming, but Claude Code makes it easier by analyzing error messages, identifying root causes, and suggesting fixes. Whether you're dealing with missing imports, runtime errors, or logic issues, it helps streamline the process by providing actionable solutions.

Here is how to use Claude Code for debugging:

  1. Identify the issue:  Share the error message with Claude.
  2. Get fix recommendations: Ask Claude for possible solutions.
  3. Apply and verify the fix:  Implement Claude’s suggestions and check if the issue is resolved.

Claude Code made the following arrangements to resolve import-related issues within the client.py file: 

  • Type ignore comments: Added # type: ignore comment to suppress IDE and type-checking warnings for unresolved imports.
  • Consistent error categorization: Claude Code ensured that error imports from authentication, database, storage, and functions are clearly grouped.
  • Maintained code readability: Comments were added to indicate why certain imports were ignored rather than removing them.

Here is a side-by-side comparison of the original code and the fixed code.

Prompt: I see some bugs, such as 'Import gotrue.errors' could not be resolved. Help me fix all errors in client.py.

comparison of the original code and bug fixed code.

Claude Code Commands

Here are a few commands for you to try with Claude.

Commands

Action

/clear

Clear conversation history and free up context  

/compact

Clear conversation history, but keep a summary in context  

/cost

Show the total cost and duration of the current session

/doctor

Check the health of your Claude Code installation, including version and update status

/help

Show help and available commands

/init

Initialize a new CLAUDE.md file with codebase documentation

/bug  

Submit feedback about Claude Code

/review

Review a pull request

/config

View and change Claude Code configuration, including permissions

/stats

View usage stats for your Claude Code sessions

I also recommend checking the Anthropic tutorials.

Advanced Claude Code Features

Once you are comfortable with the basics of refactoring and debugging, you can unlock significantly more power by customizing how Claude Code behaves. Hooks and Plugins allow you to automate repetitive tasks and integrate external systems.

Claude Code hooks

Claude Code hooks are automated triggers that execute shell commands when specific events occur during your Claude Code session. They automate repetitive tasks like code formatting, running tests, and security checks that Claude might otherwise skip.

Hooks use an event-action system, where you define three things:

  • The event: When is the hook triggered?

  • The matcher: Which actions are affected?

  • The command: What is run when the hook triggers?

For example, a hook might trigger after Claude writes a Python file and automatically run black to format the code. Hooks receive JSON context about what happened, enabling intelligent decisions based on file types or paths. They can output to Claude's transcript or send error messages directly to Claude to block operations.

Common use cases for hooks include the following

  • Code formatting: Automatically run linters and formatters after code writes

  • Testing: Execute test suites after modifications to catch bugs early

  • Security: Block modifications to sensitive files like production configs or API keys

  • Documentation: Auto-generate API documentation when source files change

  • Git automation: Create smart commits and validate branch protection policies

  • Notifications: Alert your team via Slack when important files change

  • Compliance: Enforce license headers or coding standards before allowing modifications

Set up hooks using the /hooks command in Claude Code or edit ~/.claude/settings.json directly.

Claude Code plugins

Plugins are extensions that connect Claude Code to external tools, services, and APIs. While hooks automate local shell commands, plugins integrate with your broader development ecosystem like CI/CD pipelines, project management tools, and team communication platforms.

Plugins can bundle multiple components, including subagents (specialized Claude assistants for specific tasks), MCP servers (standardized tool integrations), and hooks, into a single package that orchestrates them together seamlessly.

A plugin might analyze code changes and automatically file issues in Jira, or connect to your internal testing infrastructure. Plugins respond to the same events as hooks but send data to external services and process responses to influence Claude's workflow.

Here are a few tasks Claude Code plugins are great for:

  • CI/CD integration: Trigger builds, tests, and deployments when files change

  • Project management: Auto-create or update issues in Jira, GitHub, or Linear

  • Team communication: Post updates to Slack or Teams when changes occur

  • Code review: Auto-create pull requests and manage reviews on GitHub/GitLab

  • External analysis: Call SonarQube, CodeClimate, or Snyk for enterprise code scanning

  • Custom tools: Integrate with proprietary company systems and workflows

  • IDE extensions: Add custom commands and navigation helpers

Install plugins from a registry or build them internally for your organization, then configure which events they respond to. Hooks and plugins together create an extensible platform that adapts Claude Code to your existing infrastructure.

Conclusion

In this tutorial, we used Claude Code to refactor, document, and debug a file in the Supabase Python SDK. We improved code readability, added structured documentation, and resolved import issues. By integrating Claude Code into your workflow, you can streamline development and enhance code quality. As it evolves, it will offer even more precise solutions—try it on your own projects and see the impact!

To be up to date on the latest AI news, I recommend these blogs:

Claude Code FAQs

Do I need a paid Claude subscription to use Claude Code?

Yes, Claude Code requires either a paid Claude subscription (Pro, Max, Teams, or Enterprise plan) or a Claude Console account with active API billing. You cannot use Claude Code with the free Claude plan. During setup, you'll be asked to choose between subscription-based or API usage billing, and you'll authenticate with a verification code. This helps Claude track usage and manage costs for your Claude Code sessions.

Can Claude Code work on any programming language or just Python?

Claude Code works with virtually any programming language: Python, JavaScript, TypeScript, Java, C++, Go, Rust, and more. The examples in this tutorial use Python (Supabase-py), but Claude Code excels at refactoring, documenting, and debugging code in any language. The same workflows (refactoring, adding documentation, fixing bugs) apply regardless of what you're building.

What's the difference between Claude Code hooks and plugins?

Hooks are simpler automation tools that run local shell commands when specific events happen (e.g., format code after a file write). Plugins are more powerful extensions that integrate Claude Code with external systems like Jira, Slack, GitHub, or your company's internal tools. Plugins can bundle hooks, subagents, and MCP servers together, making them ideal for complex multi-step workflows. Use hooks for local automation and plugins for ecosystem-wide integration.

Does Claude Code have access to my entire codebase?

Yes, Claude Code has access to all files and folders in the directory where you run the claude command and its subdirectories. This is why you should navigate to your project root before starting Claude Code. However, you can configure permissions using the /config command to restrict what Claude can access or modify, which is useful for protecting sensitive files like .env or production configs.

Can I use Claude Code in a team environment, or is it personal-only?

Claude Code works well in teams. You can share project-level configurations (like MCP servers and hooks) by storing them in your project's .claude/settings.json file, which can be committed to version control. Plugins installed across your team will have consistent behavior. However, each team member needs their own Claude subscription or API billing. For enterprise environments, Anthropic offers Teams and Enterprise plans with centralized management and shared workspaces.


Aashi Dutt's photo
Author
Aashi Dutt
LinkedIn
Twitter

I am a Google Developers Expert in ML(Gen AI), a Kaggle 3x Expert, and a Women Techmakers Ambassador with 3+ years of experience in tech. I co-founded a health-tech startup in 2020 and am pursuing a master's in computer science at Georgia Tech, specializing in machine learning.

Topics

Learn AI with these courses!

Course

Building AI Agents with Google ADK

1 hr
4K
Build a customer-support assistant step-by-step with Google’s Agent Development Kit (ADK).
See DetailsRight Arrow
Start Course
See MoreRight Arrow
Related

Tutorial

Claude Code 2.1: A Guide With Practical Examples

Explore what’s new in Claude Code 2.1 by running a set of focused experiments on an existing project repository within CLI and web workflows.
Aashi Dutt's photo

Aashi Dutt

Tutorial

Imagine with Claude: A Guide With Practical Examples

Learn how Anthropic's Imagine with Claude introduces a new paradigm for AI-assisted software development, generating functionality on the fly.
François Aubry's photo

François Aubry

Tutorial

Claude Opus 4 with Claude Code: A Guide With Demo Project

Plan, build, test, and deploy a machine learning project from scratch using the Claude Opus 4 model with Claude Code.
Abid Ali Awan's photo

Abid Ali Awan

Tutorial

Claude Sonnet 4: A Hands-On Guide for Developers

Explore Claude Sonnet 4’s developer features—code execution, files API, and tool use—by building a Python-based math-solving agent.
Bex Tuychiev's photo

Bex Tuychiev

Tutorial

Getting Started with the Claude 2 and the Claude 2 API

The Python SDK provides convenient access to Anthropic's powerful conversational AI assistant Claude 2, enabling developers to easily integrate its advanced natural language capabilities into a wide range of applications.
Abid Ali Awan's photo

Abid Ali Awan

code-along

Introduction to Claude

Aimée, a Learning Solutions Architect at DataCamp, takes you through how to use Claude. You'll get prompt engineering tips, see a data analysis workflow, and learn how to generate Python and SQL code with Claude.
Aimée Gott's photo

Aimée Gott

See MoreSee More