Effective Claude Code Usage

From CLI to Cognitive Partner

Indrajeet Patil  ·  2026

Source code on GitHub

$ claude
 Claude Code

# Your AI pair programmer
# in the terminal

> How can I help?

What you’ll learn

  • Agents vs chatbots — what Claude Code actually is
  • Tools — what Claude can call and why it matters
  • Skills & slash commands — reusable playbooks and session control
  • Context window — what fills it and how to manage it
  • CLAUDE.md, memory, hooks & dream — persistent context and consolidation
  • Subagents & workflows — parallel and orchestrated work
  • Planning mode — explore before you edit
  • Prompting — intent over instructions
  • Git worktrees — parallel Claude sessions

Goal · turn Claude Code from a smart autocomplete into a capable cognitive partner for complex engineering tasks.

Prerequisite · Claude Code installed; you can run claude in a terminal.

What Is Claude Code?

“It’s not a chatbot in a terminal. It’s an agent that reads, writes, searches, and executes — and loops until the task is done.”

Claude Code is a CLI Agent

CLI-first · runs in your terminal, next to your shell, files, and Git history. Also available as desktop app, IDE extensions (VS Code, JetBrains), and web app.

Agentic · not one-shot Q&A — loops: perceive → plan → act → observe → repeat

Tool-using · reads files, writes code, runs bash, searches the web, spawns subagents, and can run workflows when enabled

Key insight · the model decides which tools to use, in what order, and how many times.

$ claude "add unit tests
  for src/auth.ts"

 Reading src/auth.ts
 Scanning test patterns
 Writing tests/auth.test.ts
 Running: npm test

 12 tests passing

Agents vs. Everything Else

“The difference between a chatbot and an agent is the difference between giving advice and doing the work.”

Intelligence Spectrum

Three-column diagram showing the intelligence spectrum from tab completion to chatbot to agent

ReAct Agent Loop

Diagram showing the ReAct agent loop: perceive, think, act, observe, repeat

Claude Code can run many tool calls in one turn: read code, inspect test output, make changes, and re-run checks before it stops.

Tools & Capabilities

“A tool is a function the model can call. The model decides when — and how many times.”

Tool Ecosystem

Hub-and-spoke diagram showing Claude Code connected to File I/O, Shell, Search, Agents, and MCP tools

Tool Categories

Category Enables
File I/O Read any file; create or surgically modify code
Pattern Search Find files by name; search content by regex
Shell Run tests, git, npm, docker — any terminal command
Web Fetch docs, read changelogs, search answers
Agents Spawn subagents, isolate context, and run workflow orchestration when available
MCP GitHub PRs, Jira tickets, Postgres, and more

Permission model · dangerous operations (file deletion, git push) require explicit user approval. You control the blast radius.

Skills & Slash Commands

“Skills are reusable playbooks. Slash commands are session controls. Together they automate your workflow.”

Skills — Reusable Playbooks

Skills are reusable prompt playbooks. Some are bundled, some come from plugins, and teams can add project-specific ones. When exposed as commands, invoke them as /skillname.

Skill Purpose
/code-review Review diff for bugs and cleanups
/simplify Refactor for clarity and efficiency
/security-review Security audit of pending changes
/deep-research Multi-source research with citations
Skill Purpose
/verify Test that a change actually works
/run Launch and drive the app
/init Generate CLAUDE.md for this repo
/review Review a pull request

Install-dependent · available skills vary by setup. Use /help or the command palette in your Claude Code install to see the current list.

Slash Commands — Session Control

Session & Context

Command Purpose
/clear Reset conversation history
/compact Compress history, keep summary
/context Inspect context usage and heavy inputs
/usage Show usage and limit breakdown
/status Show session, model, MCP, and sandbox status
/config Configure settings

Modes & Control

Command Purpose
/plan Enter planning mode
/fast Toggle faster output when supported
/model Switch Claude model
/help List all commands
/doctor Diagnose config issues
/workflows Watch live workflow progress

Commands move fast · use /help as the source of truth for your install. Older aliases such as /cost may still work, but /usage and /context are the clearer defaults.

Context Window

“The context window is finite. What’s in it decides what Claude can reason about.”

What Fills the Context?

Diagram showing five inputs flowing into the context window: CLAUDE.md, history, files, tool outputs, images

Fills fast · large tool outputs (full files, verbose logs) consume tokens rapidly.

Fix · Claude can compact long sessions, but you still control the inputs. Use /compact, limit reads to relevant files, and trim verbose bash output.

CLAUDE.md & Memory

“CLAUDE.md is persistent memory — what Claude should always know, even after /clear.”

How CLAUDE.md Is Loaded

Diagram showing how global, project-root, subdirectory CLAUDE.md files and @imports merge into the system prompt

CLAUDE.md Anatomy

# My Project CLAUDE.md

## Stack
TypeScript monorepo, Node 22, pnpm

## Conventions
- ESM only (no require())
- Tests: Vitest + @testing-library
- Branch: feat/<ticket>-description

## Commands
- Test:  pnpm test
- Build: pnpm build

## Never
- Push directly to main
- Commit .env files

Auto-generate

Run /init in any repo — Claude inspects the codebase and writes a CLAUDE.md for you. Edit it to add conventions and “never do” rules.

It compounds · add a rule once, Claude follows it forever.

Auto-memory · Claude can save reusable learnings such as preferences, project context, and reference pointers. Review what it stores, and disable or redirect it in settings when a project needs stricter boundaries.

Hooks — Automated Validation

# .claude/settings.json
{
  "hooks": {
    "PostToolUse": [{
      "matcher": "Edit",
      "hooks": [{
        "type": "command",
        "command": "pnpm lint"
      }]
    }]
  }
}

What hooks do · run shell commands automatically at lifecycle events — no per-prompt reminder needed.

Key events · PreToolUse · PostToolUse · Stop · UserPromptSubmit — and more

Use cases · lint after edits · run typecheck before stopping · block risky bash commands · log file writes

Keep them scoped · prefer narrow matchers and non-mutating checks unless automatic edits are truly intentional.

Dream — Memory Consolidation

Over time, auto memory accumulates noise: stale facts, relative dates that lose meaning, and contradictions. Dream runs a reflective consolidation pass to clean this up.

Four phases · orient (read existing memories) → gather signal (scan recent session logs) → consolidate (merge, update, fix dates) → prune (keep index under 200 lines)

Experimental · the feature exists in the UI (/memory shows auto-dream toggle) but /dream may not be fully wired up in all versions. Review its output before trusting it.

# In a Claude Code session
> /memory
  Auto-memory:  on
  Auto-dream:   on
  Last dream:   13h ago

# Dream consolidates memories
# between sessions, like sleep
# does for the brain:
#  - Merges duplicates
#  - Fixes stale dates
#  - Removes contradictions
#  - Prunes the index

Subagents & Workflows

“Subagents handle parallel work. Workflows are for the cases where simple fan-out is not enough.”

Subagent Orchestration

Diagram showing orchestrator fanning out to four parallel subagents and merging results

When to Use Subagents

Let Claude decide

  • Describe what you want done, not how to orchestrate it
  • Opus picks the right subagent type and parallelism strategy
  • Works well for: multi-file exploration, independent module tasks, context isolation

Define custom subagents when

  • You need a repeatable, team-shared specialist (e.g. security reviewer)
  • Specific tool restrictions or system prompts are required
  • The built-in agent types don’t fit your domain

Default · trust Opus to orchestrate subagents on its own. Only define custom subagents or reach for workflows when you need durable orchestration, progress tracking, or team-shared specialists.

Workflows — Advanced Orchestration

Diagram showing advanced workflow orchestration coordinating subagents, parallelism, progress tracking, structured output, and reviewable results

Advanced automation · workflows can coordinate many agents with scripts, background runs, progress views, and structured outputs. Verify the exact API in your installed Claude Code version.

Workflow Patterns — Use Sparingly

Pattern Use when Simpler alternative
Adversarial verify A high-risk review needs independent challenge One subagent + manual review
Judge panel Several viable designs need comparison Ask for tradeoffs first
Loop-until-dry You need repeated search until no new findings One targeted verification pass
Pipeline Many items need the same multi-stage treatment Script + one Claude pass

Rule of thumb · start with one agent. Add workflows only when the coordination overhead is lower than managing the task manually.

Planning Mode

“Explore first. Edit second.”

Planning Mode Workflow

Horizontal workflow diagram: request, /plan, explore, draft, human review, execute, done

In planning mode Claude reads files and proposes an approach before edits happen. Start it with /plan or claude --permission-mode plan, then review the plan before execution.

When Planning Mode Pays Off

Situation Without Planning With Planning
Refactor across 20 files Broken imports, partial changes Coherent strategy, clean execution
Add auth to existing app Picks wrong pattern for codebase Existing patterns understood first
Multi-service change Inconsistent API contracts All surfaces identified upfront
Mysterious bug Treats symptoms, not cause Root-cause analysis before editing

Rule of thumb · if the task touches >3 files or crosses service boundaries, plan first. ~5 min of planning saves 1–2 hours of rework.

Pro tip · front-load clarity: state intent, constraints, and acceptance criteria upfront. Let Claude draft the plan. Approve it or give one round of feedback — then execute.

Keep the Blast Radius Small

Before broad edits

  • Use /plan for cross-file changes
  • Start a worktree for parallel sessions
  • State files, commands, and acceptance criteria
  • Ask for a diff summary before commit

Before accepting work

  • Inspect git diff
  • Run tests and lint
  • Check generated artifacts
  • Review the PR like any teammate’s work

Principle · let Claude move quickly inside boundaries you can verify.

Delegate Intent, Verify Work

“Claude Code is an execution engine. Give it intent, constraints, and a finish line; then verify what changed.”

Define the What, Not the How

Over-specified

“First read auth.ts. Then check the test file. Then look for mocks. Then write a test for login using the existing mock pattern.”

Step-by-step instructions limit Claude’s ability to explore and adapt.

Intent + acceptance criteria

“Add unit tests for the auth module. Done when: all public functions covered, edge cases tested, conventions followed, pnpm test passes.”

Define what done looks like. Claude figures out how.

The one prompting rule that still matters · Claude can explore the codebase, choose tools, and loop on failures. The one thing it can’t infer is your definition of done. End every task with acceptance criteria, then verify those criteria before accepting the result.

Mental model · delegate the work, but keep ownership of the result. Inspect the diff, run checks, and review the PR before merging.

Git Worktrees

“When two Claude sessions edit the same files, you don’t get double the speed — you get merge conflicts. Worktrees give each session its own universe.”

Why Parallel Sessions Need Isolation

Without worktrees

  • Two sessions share the same working directory
  • Uncommitted changes bleed across sessions
  • One context reset can overwrite the other’s work
  • Stash/pop gymnastics just to switch tasks

With worktrees

  • Each session gets its own directory and branch
  • Edits, builds, and tool calls are fully isolated
  • Shared commit history and remote connections
  • Merge when both are done — on your schedule

Key insight · a git worktree is a second checkout of the same repo — same .git/ database, different working tree. Claude Code manages them with a single flag.

Worktrees — How They Work

Diagram showing a single shared .git/ object store at the top with three isolated worktree directories and three parallel Claude Code sessions below

Usage · claude --worktree feature-auth creates an isolated worktree and starts Claude in it. -w is the short alias.

Pro tip · add worktree directories to .gitignore. Use git worktree add/list/remove for manual control.

Summary

“Claude Code is most powerful when you treat it as a partner, not a search engine.”

Effective Usage: Mental Model

Four-step mental model for effective Claude Code usage: set context, choose depth, manage context, verify result

CLAUDE.md for memory · /plan for complex tasks · Worktrees for isolation · Subagents for parallel work · Skills for repeatable actions · /compact when context fills · Intent + acceptance criteria · Diff + tests before acceptance

Resources

Thank You


Other slide decks on software engineering practices

       


$ claude --help
Claude Code — AI pair programmer
Use it well. Ship great software.