DEV Community

Cover image for Beyond Cursor: Building a Terminal-First AI Dev Environment with Claude Code CLI
Dinesh M
Dinesh M

Posted on Originally published at neuralcraft-dev.blogspot.com

Beyond Cursor: Building a Terminal-First AI Dev Environment with Claude Code CLI

The Shift From Inline Autocomplete to Autonomous Execution

For a long time, "AI-assisted development" meant a ghost text suggestion hovering in your IDE. You accept it or you don't. The model has no idea what your test suite looks like, no access to your shell, and no way to verify whether what it just suggested actually compiles. You're still doing most of the work — the AI is just a faster, weirder autocomplete.

That model is being replaced by something structurally different.

Claude Code CLI doesn't wait for you to ask it a question. You drop it into a project, describe a goal, and it moves through a Read-Plan-Act-Verify loop: reads your files, writes a plan, executes edits, runs your test suite, checks results, and iterates — all inside your terminal, without you holding its hand through each step.

The difference matters. Inline suggestions help you type faster. Autonomous execution loops let you step away from the keyboard while real work gets done.

This post covers how to set that up: installation, project memory with CLAUDE.md, and three production-grade workflows you can adapt immediately.


Why Terminal AI Agents Win

Before getting into the setup, it's worth being specific about what terminal-native execution actually unlocks that IDE popups can't match.

Multi-File Refactoring Without the Overhead

When you ask an IDE extension to rename a type, it works inside the editor's language server view. When you ask Claude Code to refactor an authentication module, it reads the entire repository, traces every import, and edits every affected file — then runs your build to confirm nothing broke. It's not bound by what's currently open in a tab.

Shell Access Is the Real Unlock

The reason autonomous loops work is shell execution. Claude Code can run npm test, pytest, cargo build, git diff — and feed the output back into its reasoning. This is the feedback loop that transforms a language model from "text generator" into something closer to a junior engineer who can actually check their own work.

When tests fail, it reads the error output, identifies which assertion broke, traces it back to the code it just wrote, and fixes it. Then it reruns the tests. This loop runs until green — or until it hits a decision it can't make without asking you.

Context That Persists Across a Session

IDE extensions are stateless by design. They read your current file; they don't remember what you told them about your project two prompts ago. Claude Code maintains full context for the duration of a session and loads repo-level memory at startup via CLAUDE.md — which we'll build out below.


Step-by-Step Setup

Installation

The current recommended install is the native binary, which requires no Node.js or Docker runtime. On macOS and Linux:

curl -fsSL https://claude.ai/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

On Windows (PowerShell):

irm https://claude.ai/install.ps1 | iex
Enter fullscreen mode Exit fullscreen mode

If you prefer npm (or you're working in a Node-heavy environment and already have Node 20+):

npm install -g @anthropic-ai/claude-code
Enter fullscreen mode Exit fullscreen mode

Migration note: If you installed Claude Code before mid-2025 via npm and want to switch to the native binary, run /migrate-installer from inside a running Claude Code session. After migration, remove the old npm copy so there's no PATH conflict:

npm uninstall -g @anthropic-ai/claude-code
hash -r          # bash; use 'rehash' in zsh
which claude     # should now resolve to ~/.local/bin/claude
claude doctor    # confirms install type is 'native'
Enter fullscreen mode Exit fullscreen mode

Verifying the Installation

claude doctor
Enter fullscreen mode Exit fullscreen mode

This command checks your install type, auth status, and configuration. Run it before debugging anything by hand — it saves a lot of guessing.

Starting a Session and Authenticating

claude
Enter fullscreen mode Exit fullscreen mode

On first launch, Claude Code opens a browser to complete OAuth. Once authenticated, all future sessions pick up the credentials automatically.

If you're on a headless server or CI environment where browser auth isn't possible, set the environment variable directly:

export ANTHROPIC_API_KEY="your-key-here"
Enter fullscreen mode Exit fullscreen mode

Then start the session normally. No browser required.

On API keys vs. subscription: Claude Code works with a Claude Pro, Max, Team, or Enterprise subscription, or with an Anthropic Console account using an API key. If auth hangs during the localhost callback, copy the URL Claude Code prints, finish the login in any browser, and paste the returned code back into the terminal.


Mastering Project Memory With CLAUDE.md

What CLAUDE.md Actually Does

Every time you start a Claude Code session inside a project, it reads CLAUDE.md from the repository root and loads it into context before anything else happens. Think of it as a permanent system prompt that travels with your codebase.

Without it, you explain your stack, your conventions, and your test commands in every session. With it, Claude knows them on day one.

Anthropic's current guidance is to keep CLAUDE.md under 200 lines. Past that, you're feeding it noise. Put the most actionable context at the top — the stuff Claude needs before it touches a single file.

You can also generate a starter CLAUDE.md automatically by running /init inside a session. It analyzes your codebase and produces build commands, architecture notes, and conventions pulled from your actual project structure. Use it as a starting point, then customize.

A Production-Ready CLAUDE.md Template

Copy this into the root of your repo and fill in the specifics:

# Project: <your-project-name>
# Last updated: <date>
# Maintainer: <your-name>

---

## Stack

- **Runtime:** Node.js 20 / Python 3.12 / Go 1.22 (pick your stack)
- **Framework:** Express / FastAPI / Gin
- **Database:** PostgreSQL 15 with Prisma ORM
- **Testing:** Jest + Supertest / pytest / go test
- **Linting:** ESLint (Airbnb config) / Ruff / golangci-lint
- **Package manager:** pnpm / uv / go mod

---

## Build and Test Commands

Enter fullscreen mode Exit fullscreen mode


bash

Install dependencies

pnpm install

Start dev server

pnpm dev

Run all tests (unit + integration)

pnpm test

Run tests in watch mode

pnpm test --watch

Lint

pnpm lint

Type check

pnpm typecheck

Build for production

pnpm build


---

## Code Conventions

- All functions must have JSDoc / docstrings with at least a one-line description.
- No inline `any` types in TypeScript. Use explicit types or `unknown`.
- Errors are always logged with context: `logger.error('what failed', { userId, error })`.
- No `console.log` in committed code. Use the `logger` module.
- Database queries go in `/lib/db/` — never raw SQL in route handlers.
- Feature flags live in `/config/features.ts`.

---

## Workflow Rules

- Run `pnpm test` before every commit. Fix failures before moving on.
- Run `pnpm lint` after any significant edit. Don't leave lint errors for CI.
- When touching auth-related files, tag me for review — don't merge directly.
- Use `git worktree` for parallel work. Don't branch off branches.
- Migrations go in `/db/migrations/`. Never modify existing migrations.

---

## Project Structure (Key Paths)

Enter fullscreen mode Exit fullscreen mode


text
src/
api/ Route handlers
services/ Business logic
lib/ Shared utilities (db, logger, config)
types/ Shared TypeScript types
tests/
unit/ Unit tests (mirror src/ structure)
integration/ Integration tests
db/
migrations/ Database migrations (sequential, never edit old ones)
.claude/
commands/ Custom slash commands
agents/ Subagent configs


---

## Off-Limits

- Never delete files without asking.
- Never push directly to `main` or `production`.
- Never commit secrets, tokens, or API keys.
- Never modify `.env.production` without confirmation.
Enter fullscreen mode Exit fullscreen mode


plaintext

A few notes on what's in that template and why:

Build commands as a block — Claude runs these constantly. Having them here means it never guesses the right incantation for your test suite.

Code conventions as rules, not suggestions — "prefer functional components" is vague. "No inline any types in TypeScript" is something Claude can verify and enforce.

Off-limits section — This is your safety net. Irreversible actions (deletions, pushes to production, touching .env.production) should require confirmation. Writing these out explicitly means Claude asks before acting, not after.


Three Real-World Workflows

Workflow 1: Automated Test Generation and Zero-Intervention Bug Repair

This is the workflow that justifies the whole setup for most teams. The idea: point Claude at untested code, tell it to write tests, and then let it run npm test (or your equivalent) and fix anything that fails — without you in the loop for each iteration.

Step 1: Tell Claude what to cover.

Look at src/services/payment.ts. Write unit tests for every exported function.
Use Jest and the existing test patterns in tests/unit/. Run npm test after writing
each test file and fix any failures before moving on.
Enter fullscreen mode Exit fullscreen mode

Step 2: Watch the loop.

Claude reads the source file, identifies exported functions, writes test cases, runs the test suite, and patches failures. You'll see output like:

> Wrote tests/unit/payment.test.ts
> Running: npm test
> FAIL tests/unit/payment.test.ts
>   ● processRefund › should reject negative amounts
>     Expected: Error
>     Received: undefined
> Analyzing failure...
> Patching processRefund to throw on negative input.
> Running: npm test
> PASS tests/unit/payment.test.ts
Enter fullscreen mode Exit fullscreen mode

Step 3: Review, don't rewrite.

When Claude reports all-green, audit the test file. The loop handles mechanical correctness; you handle whether the tests are actually testing the right behavior.

This workflow also applies to bug repair. If you have a failing test you haven't been able to track down:

npm test is failing on tests/integration/auth.test.ts with a 401 on
the /refresh endpoint. Read the test file, trace the auth middleware,
and fix the root cause. Run the full test suite after your fix to
confirm nothing else broke.
Enter fullscreen mode Exit fullscreen mode

Workflow 2: Pre-Commit Git Diff Audits and Security Reviews

Claude Code ships with a /security-review command that scans for vulnerabilities. But you get more control by building a custom command that scopes it to your diff — so you're reviewing exactly what's about to be committed, not the entire codebase.

Create a custom slash command:

mkdir -p .claude/commands
Enter fullscreen mode Exit fullscreen mode
# .claude/commands/security-review.md

---
description: Security audit of the current git diff before commit
allowed-tools: Read, Grep, Glob, Bash
---

Run `git diff HEAD` and `git diff --staged` to capture all pending changes.
Audit those changes specifically for:
- Authentication and authorization logic changes
- New inputs that aren't validated or sanitized
- Secrets, tokens, or credentials added to source
- New npm/pip/go dependencies with known CVEs (check the lockfile changes)
- SQL or shell injection surfaces
- Logging changes that might expose PII

Report findings as a numbered punch list. For each finding: what the
issue is, which file and line, and a concrete fix. If nothing looks
wrong, say so explicitly — don't generate findings to seem thorough.
Enter fullscreen mode Exit fullscreen mode

Now run it any time before a commit:

/security-review
Enter fullscreen mode Exit fullscreen mode

This pattern is useful beyond security. You can build similar commands for:

  • API surface reviews (did any public endpoints change without docs updates?)
  • Dependency audits (new packages that aren't in the approved list)
  • Database migration checks (are any migrations destructive?)

The command lives in .claude/commands/ inside your repo, so it's version-controlled and shared across your team automatically.

Workflow 3: Multi-File Repository Onboarding and Architectural Mapping

The third workflow solves a specific pain: joining a new codebase (or returning to one you haven't touched in months) and needing to understand how the pieces connect before writing a line.

Read the entire repository structure. Start with package.json and any config
files in the root. Then read src/ top-down. Give me:

1. A plain-English summary of what this service does and where it fits in the
   broader system (based on what you can infer from the code).
2. The data flow for a typical request — entry point to database and back.
3. The three files I should read first if I'm about to add a new API endpoint.
4. Any obvious debt or known failure points you can spot in the current code.
Enter fullscreen mode Exit fullscreen mode

Claude reads the entire codebase, traces imports, and produces an architectural summary that would take a human developer half a day to piece together from scratch. It's not a substitute for reading the code yourself — but it's a fast way to get oriented before you do.

For larger repos (100k+ lines), you can scope it:

Focus only on src/api/ and src/services/. Ignore tests/ and db/migrations/
for now. Give me the same architectural summary, scoped to just those directories.
Enter fullscreen mode Exit fullscreen mode

Technical Comparison: Claude Code CLI vs. Local Open-Weight Terminal Agents

If you're weighing Claude Code against running a local setup (Ollama + OpenDevin, or similar), here's an honest comparison across the dimensions that matter in practice:

Feature Claude Code CLI Local Open-Weight Setup (Ollama / OpenDevin)
Reasoning Depth Claude Sonnet 4.6 / Opus 4.x — strong multi-step reasoning and code understanding out of the box Depends heavily on model choice; Qwen2.5-Coder and DeepSeek-Coder-V2 are competitive, but require careful selection and prompt tuning
Hardware / VRAM Overhead None — compute runs on Anthropic's infrastructure; works on any machine with a terminal High — 7B models need ~8GB VRAM for reasonable speed; 30B+ models need 24GB+ for code quality comparable to Claude
Execution Model Native agentic loop with shell access, file read/write, and git integration built in Varies; OpenDevin has a good agent loop, but tool integration requires more setup and is less battle-tested
Model Context Protocol (MCP) Support First-class — Claude Code is an MCP client; connect to databases, APIs, GitHub, and external services out of the box Experimental / partial — some local stacks support MCP but not uniformly; ecosystem is catching up
Data Privacy Code is sent to Anthropic's API; sensitive repos may require API key with zero-data-retention policy Full local execution — no data leaves your machine; strong option for regulated environments
Cost Model Subscription (Pro/Max/Team) or API usage billing Free at runtime; GPU hardware is the capital cost
Offline Use No Yes, once the model is downloaded

The honest answer: if your code isn't classified, Claude Code wins on setup time, tool quality, and reasoning depth. If you're working in a regulated environment, handling genuinely sensitive IP with legal constraints, or need air-gapped operation, a local stack is the right choice — and it's worth the setup investment.


Conclusion and Operational Best Practices

The terminal-first workflow covered here isn't experimental. As of mid-2026, Claude Code is in daily use across engineering teams of all sizes — from solo founders to larger organizations running parallel agent sessions across multiple workstreams.

A few things that will save you time once you're up and running:

Keep CLAUDE.md under 200 lines. Every line you add is context that loads into every session. Past a certain point, you're paying for noise. Link to extended docs instead of inlining them.

Use /branch before risky changes. Before asking Claude to do something you can't easily undo, branch the conversation. This gives you a checkpoint to roll back to if the approach goes sideways.

Lock down what matters in CLAUDE.md's off-limits section. The auto mode classifier handles a lot of safety checks automatically, but for operations specific to your project — touching production configs, modifying migrations, pushing to protected branches — write explicit rules and Claude will ask before acting.

Run claude doctor when things break. Before debugging your install by hand, let the diagnostic tool tell you what's wrong. Most install problems come down to PATH conflicts between old npm installs and the native binary.

Review, don't rubber-stamp. The test-fix loop and the security audit workflows handle mechanical verification. They don't tell you whether the solution makes architectural sense, or whether the tests are actually testing the right behavior. Claude speeds up execution; your judgment is still the thing that matters at merge time.

The shift from passive suggestion to autonomous execution is worth the setup time. Once your CLAUDE.md is solid and your custom commands are in place, you'll spend more time on the decisions that require you and less time on the work that doesn't.


Claude Code CLI documentation: docs.claude.com

Questions, corrections, or war stories from your own setup? Find us on the Neural Craft Discord.

"Originally published on Neural Craft. Read the full interactive walkthrough on the main blog."

Top comments (0)