Skip to main content

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.
Jan 12, 2026  · 10 min read

Claude Code is an agentic coding tool developed by Anthropic that runs directly in your terminal and can also operate through a connected web interface. Instead of working on isolated prompts, Claude Code understands the entire repository, can reason across files, edit code, and run tools. 

Compared to earlier versions, which focused primarily on interactive code assistance, Claude Code 2.1 has additional support for agents, hooks, and reusable skills that can actively shape how and when code changes occur.

Claude Code is designed for developers who want AI assistance embedded directly into real workflows, rather than switching back and forth between an editor and a chat UI. Although it is still in research preview, it already demonstrates strong practical utility in real development workflows. 

If you want to learn more about the Claude models, I recommend taking the Introduction to Claude Models course

What’s New in Claude Code 2.1?

Claude Code 2.1 builds on the core terminal experience by introducing a set of upgrades that make agent-driven workflows more flexible. These changes extend how Claude Code reasons about a codebase and how developers interact with it during real development tasks.

Some of the most notable additions in Claude Code 2.1 include:

  • Agent and skill hooks in frontmatter, allowing developers to enforce checks and constraints before any code edits are applied.
  • Expanded skills support with forked context, hot reload, and custom skill definitions, making reusable workflows more flexible and powerful.
  • Slash (/) skill invocation enables quick access to frequently used actions during interactive sessions.
  • Agents in Claude Code 2.1 no longer stop reasoning when a tool invocation is denied, allowing workflows to continue without interruption.
  • The tool supports language-controlled responses, which are especially useful for multilingual documentation, reviews, and team collaboration.
  • Wildcard tool permissions, such as Bash(*-h*), provide finer-grained automation controls.
  • The CLI now supports Shift+Enter for multiline input, improving the interactive authoring experience without requiring additional setup.

In this guide, we focus on a set of practical experiments that demonstrate how these new capabilities are applied in real-world projects.

Setting Up Claude Code Cloud-Based Web Experience

Claude Code 2.1 is available as a web-based experience that runs entirely in the cloud. This mode is especially useful for collaborative workflows, pull request reviews, and repository-level automation without requiring a local setup.

Step 1: Sign in and access Claude Code

To get started, navigate to https://claude.ai/code, and you’ll land on the Claude Code (Research Preview) interface. 

Connect Claude to GitHub

Step 2: Connect Claude Code to GitHub

To work with real repositories, Claude Code needs access to GitHub. Click on Connect to GitHub, which installs the Claude GitHub App

Connect repositories

During authorization, GitHub will ask for permission to connect to repositories by:

  • Verifying your GitHub identity
  • View which repositories Claude can access
  • Act on your behalf (for example, creating branches or commits)

Install & authorize claude code

You can choose between:

  • All repositories, or
  • Only select repositories (recommended for tighter control)

Typical permissions include:

  • Read access to repository metadata and checks
  • Read and write access to code, issues, pull requests, and workflows

Click on Install & Authorize, and you can modify or revoke access later directly from GitHub’s app settings. This step is required for Claude Code to read repositories, open pull requests, and push commits when working in the web environment.

Step 3: Create a cloud environment

Before starting your first session, Claude Code prompts you to create a cloud environment. This environment controls Claude’s network access and execution boundaries.

Create cloud environment

The available options include:

  • None: This option has no internet access, mainly useful for maximum security.
  • Trusted (recommended): It provides access to verified package sources.
  • Full: This setting provides unrestricted internet access.

For most use cases, the Trusted option provides the best balance between security and flexibility.

Step 5: Start a web session

After setup is complete, you’re taken to the Claude Code web editor as shown in the screenshot below.

image2.png

From here, you can:

  • Select a repository and a branch
  • Run refactors and reviews
  • Create new branches and commits
  • Resume previous sessions (if any)
  • Switch between repositories without changing environments

Setting Up Claude Code Terminal-Based CLI Experience

The CLI is the most direct way to work with Claude Code 2.1. It’s ideal for local development, step-by-step refactors, and situations where you want fine-grained control over what Claude does in your repository.

Step 1: Installation

Claude Code can be installed directly from the terminal using a platform-specific installer.

macOS, Linux, WSL:

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

MacOS installation

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

Once installation completes, you should see a confirmation message indicating the Claude Code version along with the installation path. For additional setup options, you can refer to the official setup guide.

Step 2: Getting started

After installation, navigate to the root of your project and start Claude Code:

cd your-project-directory
Claude Code

When Claude Code starts, it immediately scans the repository and builds an initial understanding of the codebase. 

image3.png

This initial context allows Claude Code to reason more effectively in later steps.

Experimenting With Claude Code 2.1

For this demo, I used one of my projects from GPT 5.2. Here is a quick overview of the project.

Project overview

Once Claude Code has access to every file and folder within the folder, we can start experimenting.

Refactor using forked context skills 

As part of evaluating Claude Code 2.1, I performed a repository-wide refactor to enhance the pipeline. This experiment highlights skills with forked context, where Claude can reason across multiple files instead of making isolated single-file edits.

Prompt:

Refactor the CSV parsing and slide generation logic across the repository.
Improve readability, split responsibilities, and avoid duplicated logic.

Claude first generates a detailed refactoring plan, including the proposed module structure, duplication points, and an implementation sequence, and then asks for approval before changing anything. 

image17.png

Once you approve, Claude applies the refactor incrementally, showing diffs and progress as it goes.

Using Claude Code, I achieved the following improvements:

  • Split responsibilities across modules: Claude separated CSV loading, transformations, Excel building, PowerPoint generation, and LLM planning (basically all modules) into dedicated components.
  • Reduced duplicated logic: It centralized repeated utilities (such as column detection and formatting) and moved shared constants into a common configuration layer.
  • Improved maintainability: Claude also reduced the size of the app.py while keeping the application’s external behavior consistent.

Here is a comparison of the project structure and refactoring output before and after the changes.

Before:

Refactor using forked context skills  2

After:

image8.png

Finally, I tried the same refactor in Claude Code Web. The key difference is workflow:

  • CLI proceeds step-by-step with explicit approvals.
  • Web can push the refactor directly to a new branch, which is convenient for collaboration and PR-based workflows.

Refactor using forked context skills  4

Refactor using forked context skills  5

Finally, Claude refactored and pushed the code to a branch.

Refactor using forked context skills  6

Pre-edit validation hook

Data pipelines often fail for a simple reason, namely that the input CSV schema doesn’t match what the code expects. In Claude Code 2.1, you can reduce this class of failures by using pre-edit hooks. This new capability lets an agent run validation checks before Claude is allowed to modify code.

In this example, I asked Claude Code to create an agent that validates CSV structure before any edits are applied.

Prompt:

Create a Claude Code agent that validates the CSV schema before modifying any code. The agent should reject edits if the CSV schema is unclear.

image14.png

Claude Code first generated a CSV schema validation agent and wired it into the workflow so it can act as a gatekeeper. The CLI output shows that Claude didn’t just create a single script, it assembled a small validation system that includes:

  • A core schema validator module that checks required columns, missing values, and basic consistency.
  • A pre-edit gatekeeper hook runs validation automatically before edits proceed.
  • Finally, a test suite and some usage examples to verify the validator across valid/invalid CSV cases.

image13.png

In practice, the workflow becomes simple:

  • Claude automatically runs schema checks before making any code changes, enforcing a precondition.
  • If the schema is unclear or invalid, the agent hard-blocks edits and returns actionable error messages to guide the fix.
  • Once validation passes, Claude proceeds with modifications, keeping changes guardrail-driven and predictable.

The web output shows a similar result, but with a key difference. Claude Code Web can push the changes directly to a new branch, including the validation module, hook integration, documentation, and tests. 

Pre-edit validation hook 3

Overall, Claude Code 2.1 enforces guardrails before edits happen by embedding hooks directly into agents and skills. This makes hooks especially valuable in data-heavy projects, where input correctness is often a bigger source of bugs than the code itself.

Slash-command skills for repeated tasks

Claude Code 2.1 introduced reusable slash-command skills, which are self-contained workflows that can be invoked interactively inside a Claude session or executed directly from the command line. 

In this example, we create a reusable /generate-slides skill that converts a CSV file into a professional PowerPoint presentation.

Prompt:

Create a reusable skill called /generate-slides that converts a CSV into a PPT.

Tip: Use /statusline to configure a custom status line that appears beneath the input prompt (handy for showing repo, branch, or mode).

Claude Code generates a complete skill definition under .claude/skills/, including documentation, validation logic, and a runnable Python entry point.

  • Skill creation: Claude writes a fully documented generate-slides skill, describing its purpose, inputs, validation steps, and execution flow.
  • Schema validation: The skill validates the CSV schema before any processing, ensuring data quality and clear error messages.
  • Execution: The skill can be run directly from the terminal, behaving like a standalone command-line tool.
  • Error handling: Missing files, invalid schemas, or missing API keys result in clear, actionable errors.
  • Automation: A single command generates Excel artifacts, charts, and a PowerPoint deck.

Slash-command skills for repeated tasks 1

image15.png

You can test the skill locally with:

python .claude/skills/generate-slides.py --csv-file kpis.csv

Note: Make sure you add your API key before running this. 

Slash-command skills turn Claude Code into a workflow engine, not just an assistant. Instead of re-prompting for the same task repeatedly, you define it once and reuse it across projects, sessions, and environments. You can observe the updated repository structure below, reflecting the addition of the new skill.

Slash-command skills for repeated tasks 3

This example demonstrates how:

  • Skills can be invoked interactively from the CLI.
  • Claude-generated skills integrate cleanly with existing codebases.

Language-controlled output 

Claude Code 2.1 can be configured to respond in a specific language, which is useful for multilingual teams, localized documentation, and non-English code walkthroughs. In this example, we asked Claude to explain the repository’s slide generation pipeline entirely in Japanese.

Prompt:

Explain the slide generation logic in Japanese.

Claude responded in Japanese and produced a structured explanation of the end-to-end flow. As shown in the output, it didn’t just translate a summary but also mapped the pipeline into clear phases and referenced the relevant modules involved in each step. The CLI output shows:

  • Japanese end-to-end: The response remains in Japanese throughout, including headings and bullet points.
  • Step-by-step flow: Claude breaks the pipeline into distinct stages (CSV validation, data processing, Excel workbook, LLM planning, and slide creation).
  • Codebase-aware references: It points to relevant files and directories while explaining what each component does.
  • Documentation-style formatting: The output reads like internal docs, making it easy to reuse in a README or onboarding guide.

image11.png

Note: I only tested this behavior in the CLI for this example, but the same language-control capability is part of Claude Code 2.1 overall.

This is a small feature on paper, but in practice, it’s a big productivity win when documentation and reviews need to happen in languages other than English.

Claude Code 2.1 Commands

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

Command

Actions

/clear

Clear conversation history and free up context

/compact

Clear history, but keep a summary in context

/config

Open the configuration panel

/cost

Show the total cost and duration of the current session

/doctor

Check the health of your Claude Code installation

/help

Show help and available commands

/init

Initialize a CLAUDE.md file with codebase documentation

/review

Review a pull request

/pr-comments

Fetch comments from a GitHub pull request

/approved-tools

List all currently approved tools

/login

Switch Anthropic accounts

/logout

Sign out of your Anthropic account

/exit

Exit the interactive session

Conclusion

In this guide, we explored Claude Code 2.1 by running hands-on experiments across both CLI and web workflows. We used Claude Code to refactor an existing repository using forked context skills, enforce data guarantees with pre-edit validation hooks, create reusable slash-command skills, and generate language-controlled explanations directly from the codebase.

These examples highlight how Claude Code 2.1 moves beyond simple AI-assisted editing toward more agent-driven development workflows. Although Claude Code 2.1 is still in research preview, it already demonstrates strong practical value in real projects.

Claude Code 2.1 FAQs

How do I share my custom slash commands (/skills) with my team?

Code 2.1 saves skill definitions directly into the .claude/skills/ directory of your project, you simply commit this folder to your Git repository. Once your teammates pull the latest changes, the new commands (like /generate-slides) will be immediately available in their CLI or web sessions.

Do the new "Pre-Edit Hooks" increase API costs?

Yes, slightly. Because hooks (like the schema validator in your example) act as autonomous agents that reason and run tools before the main edit occurs, they consume additional tokens. However, they typically save money overall by preventing Claude from wasting tokens on incorrect edits that would need to be reverted later.

Can I run these new CLI experiments in the Web interface?

Yes. Claude Code Web 2.1 provisions a cloud environment (Step 3 in the guide) that mirrors the CLI's execution capabilities. This means your slash commands, forked context refactors, and validation hooks will function in the browser just as they do locally, provided the cloud environment has the necessary permissions.

What is the difference between a "Skill" and an "Agent" in Claude Code 2.1?

Think of a Skill as a specific tool or function you give Claude (e.g., "Read this CSV" or "Generate a PPT"). An Agent is the reasoning loop that uses those skills to achieve a goal (e.g., "The Validator Agent" that calls the "Read CSV" skill, checks the output, and decides whether to approve an edit). Version 2.1 allows you to customize both.


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

Top DataCamp Courses

Course

Introduction to Claude Models

3 hr
1.3K
Learn how to work with Claude using the Anthropic API to solve real-world tasks and build AI-powered applications.
See DetailsRight Arrow
Start Course
See MoreRight Arrow