Claude Code & CLI Tools

Agentic Features and Checkpoints

5 min read

Claude Code's agentic architecture lets it work autonomously on complex tasks. Checkpoints ensure you can always recover if something goes wrong.

Understanding Agentic Mode

In agentic mode, Claude Code can:

  • Break complex tasks into subtasks
  • Spawn subagents for parallel work
  • Execute commands and verify results
  • Self-correct based on errors
  • Continue until the task is complete

Enabling Extended Thinking

For complex reasoning:

claude config set thinking-mode extended

Thinking modes:

  • normal: Standard reasoning
  • extended: Deeper analysis, shows thinking process
  • extended_max: Maximum depth for very complex tasks

Subagents

Claude Code can spawn specialized agents:

Main Task: "Refactor authentication system"
├── Subagent 1: Analyze current implementation
├── Subagent 2: Research best practices
├── Subagent 3: Create new schema
└── Subagent 4: Write migration tests

Example prompt:

Refactor the user authentication system:
- Analyze the current implementation in src/auth
- Research JWT best practices for 2026
- Create a new token-based system
- Write comprehensive tests
- Ensure backward compatibility

Use subagents for parallel research and implementation.

Checkpoints

Checkpoints save your project state at a point in time.

Creating a Checkpoint

# In Claude Code session
/checkpoint create "Before auth refactor"

Or via CLI:

claude checkpoint create "Before auth refactor"

What Gets Saved

Checkpoint Contents:
├── All file changes since last commit
├── Current conversation context
├── Pending operations
└── Configuration state

Listing Checkpoints

/checkpoint list

# Output:
# 1. [2026-01-06 14:30] "Before auth refactor" (3 files)
# 2. [2026-01-06 13:15] "Initial state" (1 file)

Restoring a Checkpoint

/checkpoint restore 1
# or
/checkpoint restore "Before auth refactor"

Auto-Checkpoints

Enable automatic checkpoints before major operations:

// .claude/config.json
{
  "checkpoints": {
    "autoCreate": true,
    "beforeMajorChanges": true,
    "maxCount": 10
  }
}

Practical Agentic Workflows

Workflow 1: Feature Implementation

Implement a notification system for our app:

1. Design the notification schema
2. Create database migrations
3. Build API endpoints (CRUD)
4. Add WebSocket support for real-time notifications
5. Create React components for the notification center
6. Write tests for all components
7. Update documentation

Execute step by step, creating checkpoints before major changes.

Claude will:

  • Create checkpoint "Before notification system"
  • Design schema and show for approval
  • Implement each step sequentially
  • Run tests to verify
  • Create intermediate checkpoints

Workflow 2: Bug Investigation

There's a memory leak in production. Investigate and fix:

1. Analyze error logs in logs/error.log
2. Profile memory usage in src/services
3. Identify the leak source
4. Propose fixes with minimal impact
5. Implement the fix
6. Add monitoring to prevent recurrence

Show your analysis at each step.

Claude will:

  • Read and analyze log files
  • Search codebase for memory patterns
  • Show findings before making changes
  • Implement fix with explanation
  • Add monitoring code

Workflow 3: Code Migration

Migrate from JavaScript to TypeScript:

Phase 1: Setup
- Add TypeScript configuration
- Install dependencies
- Create type definitions

Phase 2: Core Files (src/lib)
- Convert utility functions
- Add strict typing

Phase 3: Components (src/components)
- Convert React components
- Add prop types

Phase 4: API (src/api)
- Convert API routes
- Add request/response types

Create checkpoints between phases.

Background Agents

Run agents in the background while you work:

# Start background task
claude background "Run tests and fix any failures"

# Check status
claude background status

# View results
claude background results

Multiple Background Tasks

claude background "Optimize images in public/" --name "image-opt"
claude background "Update dependencies" --name "deps-update"
claude background "Generate API docs" --name "api-docs"

# Check all
claude background list

Error Recovery

When Claude makes a mistake:

Option 1: Undo Last Change

/undo

Option 2: Restore Checkpoint

/checkpoint restore "Before auth refactor"

Option 3: Git Reset (if committed)

git reset --soft HEAD~1

Option 4: Iterative Correction

That change broke the tests. Specifically:
- The user lookup fails because of the new schema
- Keep the new schema but fix the lookup query

Best Practices

1. Checkpoint Before Major Changes

# Always
/checkpoint create "Before [description]"

2. Use Extended Thinking for Complex Tasks

# For architectural decisions
claude config set thinking-mode extended

3. Break Large Tasks Into Phases

Instead of:

"Rewrite the entire backend"

Use:

"Rewrite the authentication module. Stop after this phase for review."

4. Verify at Each Step

After each change, run the tests and show me any failures.

5. Keep Context Focused

# Clear conversation when starting new task
/clear

Cost Management

Agentic tasks can be expensive. Monitor usage:

# Check current session cost
/cost

# Output:
# Current session: $0.42
# Input tokens: 45,230
# Output tokens: 12,450

Set spending limits:

// .claude/config.json
{
  "limits": {
    "maxCostPerSession": 5.00,
    "warnAtCost": 2.00
  }
}

Agentic Insight: The power of Claude Code lies in trusting it with multi-step tasks while maintaining checkpoints for safety. Think of checkpoints as git commits for your AI session.

In the next lesson, we'll explore MCP integrations to connect Claude Code with external tools. :::

Quiz

Module 3: Claude Code & CLI Tools

Take Quiz