Post 3: Setting Up Claude Code — The Brain Behind the Agent

Post 3: Setting Up Claude Code — The Brain Behind the Agent

In Post 2 we set up Hermes — the project manager. Now we set up the developer. The one that actually reads your codebase, understands the bug, writes the fix, runs the tests, and opens the PR.

This is Claude Code, Anthropic’s autonomous coding agent. And I’m going to show you how to set it up the way Boris Cherny (its creator) actually uses it — not the “type a prompt and pray” way most people do.


What Claude Code Actually Is

Claude Code is a CLI tool. You type claude in a terminal inside your project, and it becomes an AI pair programmer that can read files, write code, run shell commands, manage git, and even spawn subagents. It works in two modes:

1. Interactive mode: A full TUI (terminal UI) where you have a conversation. Good for exploration.
2. Print mode (-p): One-shot, non-interactive. You give it a task, it works, it exits. Perfect for automation.

For our agent pipeline, we use print mode exclusively. The cron job fires, Hermes spawns claude -p "fix this bug", Claude does its thing, and exits. No human in the loop during execution.


Step 1: Install Claude Code

Standard npm install:

npm install -g @anthropic-ai/claude-code

Authenticate (choose one):

claude auth login             # browser OAuth (Pro/Max subscribers)
claude auth login --console   # API key billing (what I use)
claude auth login --sso       # Enterprise SSO

Verify:

claude doctor    # all green = ready
claude --version # should be v2.x+

Test it:

It should read your project files and answer correctly. If it does, Claude can see your codebase.


Step 2: The .claude Directory — Your Agent’s Memory

This is where most people stop and where the real setup begins. The .claude/ directory is a layered configuration system that compounds over time.

Key concept: project files describe the project, global files describe you.


Step 3: CLAUDE.md — The Boris Cherny Way

CLAUDE.md is loaded at the start of every session. Get it wrong and Claude repeats mistakes. Get it right and the same prompt produces dramatically better output.

Boris has two rules:

1. Keep it short. For every line, ask: “Would removing this cause Claude to make a mistake?” If not, cut it.
2. Let Claude write rules for itself. Every mistake becomes a rule.

Here’s the actual CLAUDE.md the Claude Code team checks into their own repo:

That’s it. Build commands Claude can’t guess, the exact order to run things, single-test invocations, the pre-PR ritual. No style preferences. No codebase tours. No platitudes.

Here’s mine for my ERP project:

The Gotchas section is the magic. Every entry is a mistake Claude made, captured the moment it happened. After two weeks of “Update CLAUDE.md so you don’t repeat this,” the same prompts produce night-and-day better output. Boris calls this “Compounding Engineering.”


Step 4: CLAUDE.local.md — Your Personal Rulebook

CLAUDE.local.md sits alongside CLAUDE.md, gets loaded the same way, but never leaves your machine. Add it to .gitignore.

I use it to capture PR feedback I receive:

Claude now knows to include auth-failure tests and update the OpenAPI spec without me mentioning it. My PR nitpick comments dropped noticeably within two weeks.

Rule: prune after a few weeks. Things that have become muscle memory can go. The file captures what you’re still learning, not what you already do automatically.


Step 5: Skills — Reusable Expertise

A skill is a markdown file that teaches Claude a repeatable workflow. Boris says: “If you do something more than once a day, turn it into a skill.”

For our junior dev agent, the most important skill is the bug fix workflow:

.claude/skills/bugfix/SKILL.md:

Why skills over just prompting? Because skills support progressive disclosure (Claude only loads the full file when needed), bundling (templates, scripts, reference docs), and inline shell commands.


Step 6: Subagents — The Writer/Reviewer Pattern

A subagent runs in its own context window with its own tool permissions. It can read 50 files without filling up your main session. This is the whole value proposition.

Our PR reviewer subagent (.claude/agents/pr-review.md):

Key design choice: tools is read-only. A reviewer that can modify code gets biased toward defending its own edits.

The Writer/Reviewer pattern: Session A implements, Session B reviews with zero implementation bias, copy feedback back, fix, repeat. Two Claudes, two contexts, one result. The Anthropic team swears by this.


Step 7: Permission Settings

Prevent Claude from doing anything dangerous with proper permission settings in ~/.claude/settings.json.


Step 8: Verify Everything

Quick integration test to verify CLAUDE.md is loading, Claude can read your project, understands conventions, and permissions are working.


What We Just Built

Claude Code now:

  • Loads project conventions from CLAUDE.md on every session
  • Remembers personal preferences from CLAUDE.local.md
  • Follows a structured bug fix workflow via skills
  • Reviews its own PRs via subagents (Writer/Reviewer)
  • Has safe, restricted permissions
  • Can be spawned by Hermes with one terminal command

Next post: [Post 4] Multi-Agent Architecture — Supervisor, coder, reviewer, QC agent all working together. The full team.

Series: “AI Junior Developer” — Part 3 of 6

Related: Post 4: Building the Agent Team — Supervisor, Coder, Reviewer, QC.

Related: Alibaba’s AI Just Coded for 35 Hours Straight Without Human Help.


Discover more from Susiloharjo

Subscribe to get the latest posts sent to your email.

Discover more from Susiloharjo

Subscribe now to keep reading and get access to the full archive.

Continue reading