Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

Claude Code (Agentic CLI)

The moves that make Claude Code fast — slash commands, file references, plan mode, memory, subagents, MCP, and headless runs.

Claude Code is an agent in your terminal: it reads files, runs commands and edits code in a loop until the task is done, asking before anything risky. Three ideas shape every session. Context is finite, so you choose what goes in (@ files, CLAUDE.md) and reset it when it fills (/clear, /compact). Permission modes set how much it may do without asking; Shift+Tab cycles them. And everything interactive also runs headless through claude -p, which is how it works in scripts and CI.

Rows reflect Claude Code 2.1; /help lists what your version has.

CLAUDE.md + rules@files, !outputMCP tools, skillstool resultscontext/context: look/compact: shrink/clear: resetfinite windowClaudeplans, actspermissionsdeny rule winsallow rule: runelse mode decidesplan: no editsoutput returns as tool results
Everything Claude knows enters one finite context window, which you can inspect and shrink. Everything it does passes the permission gate, where a deny rule beats any allow and the mode decides what still asks.

Prompt input

@path/to/file
pull a file into context; @src/ adds a directory listing, Tab completes paths
!npm test
bash mode: run a command yourself and put its output in the conversation
/
browse built-in commands, your custom commands and skills
Esc
stop the current action and redirect; the conversation so far is kept
Esc Esc
rewind picker: edit an earlier message or restore code (also /rewind)
Shift+Enter · \ Enter
new line in the prompt; /terminal-setup configures terminals that need it
Ctrl+V
paste an image (screenshot, mockup) from the clipboard; you can also drag files in

Keyboard shortcuts

Shift+Tab
cycle permission modes: normal → auto-accept edits → plan mode
Ctrl+O
detailed transcript with full tool output; press / to search it
Ctrl+B
send a running command or agent to the background and keep working
Ctrl+R
search your prompt history
Ctrl+G
edit the prompt in your $EDITOR — for long instructions
Ctrl+S
stash the half-written prompt, send something else, then restore it
Option+P
switch model while writing a prompt (Alt+P on Linux and Windows)
Ctrl+C twice
exit Claude Code; once clears the input or cancels

Slash commands

/init
scan the repo and draft a CLAUDE.md with build commands and conventions
/clear
start a fresh conversation — the cheapest fix for a confused session
/compact [focus]
summarize to free context; add what to keep, e.g. /compact keep the API decisions
/context
what fills the context window: tools, memory files, messages, free space
/model
switch models mid-session
/plan
enter plan mode; /plan fix the auth bug starts planning straight away
/rewind · /undo
roll the conversation and code back to an earlier point
/resume
pick up a past session from this directory; Ctrl+A shows every project
/memory
open and edit the memory files loaded this session, including auto-memory
/permissions
review and edit allow and deny rules; the Recent tab shows denials
/agents
create and manage subagents with their own prompts, tools and models
/mcp
connected MCP servers, their tools and sign-in status
/hooks
the hooks configured for tool and session events
/cost · /usage
token spend for this session · your plan’s usage limits
/security-review
check pending changes for vulnerabilities; /review does a general review
/btw
ask a side question without derailing the main task
/config
settings such as theme and editor mode (Vim keys live here now)
/doctor
diagnose installation, settings and MCP problems

Memory & settings files

CLAUDE.md
Project instructions auto-loaded every session — conventions, commands, do/don’t
~/.claude/CLAUDE.md
personal instructions applied in every project
@path in CLAUDE.md
import another file into memory, so CLAUDE.md itself stays short
.claude/rules/*.md
topic rule files; paths: frontmatter loads one only for matching files
Auto-memory
Claude saves useful facts itself; for team rules ask it to edit CLAUDE.md (the # shortcut was removed)
.claude/settings.json
shared project settings: permissions, hooks, env; settings.local.json is your git-ignored copy
~/.claude/settings.json
user-wide settings that apply to every project
Bash(git diff *)
permission rule: a tool plus a pattern, in permissions.allow or deny; deny wins
.mcp.json
project MCP servers committed with the repo; each needs approval on first use

Extend it

.claude/agents/*.md
subagents: prompt, tools and model per file; each runs in its own context window
SKILL.md
a skill in .claude/skills/NAME/: instructions Claude loads only when the task matches
.claude/commands/x.md
a custom slash command: the file’s text becomes the prompt for /x
Hooks
shell commands on events like PreToolUse, PostToolUse, Stop — format or test after edits
exit 2 in a hook
blocks the tool call (PreToolUse) and hands the hook’s stderr to Claude as the reason
claude mcp add
add a server: --transport http NAME URL, or a local command after --
mcp add --scope
local (default, just you), project (writes .mcp.json) or user
/plugin
install bundles of commands, agents, skills and hooks from a marketplace

Headless & CLI flags

claude -p "prompt"
print mode: answer once and exit — for scripts and pipes
git diff | claude -p
pipe input in: git diff | claude -p "write a commit message"
claude -c · claude -r
continue the latest session here · resume one by ID or from a picker
--output-format json
machine-readable result with cost and session ID; stream-json streams events
--permission-mode plan
start in a mode: plan, acceptEdits, default and others
--allowedTools
pre-approve tools for the run, e.g. "Bash(npm test) Edit"; --disallowedTools denies
--model sonnet
choose a model by alias or full name for this session
--add-dir ../lib
give Claude access to a directory beyond the working one
--append-system-prompt
add your own instructions on top of the default system prompt
-w NAME
start in a fresh git worktree so parallel sessions never share a checkout
--max-budget-usd 5
stop a print-mode run once it has spent $5
Skip all permissions
--dangerously-skip-permissions — only in a sandbox without internet access
In CI
Headless mode + a scoped prompt = code review, triage, or codemods in a pipeline

Worked example: from a failing test to a commit, then the same check in CI

  1. Run claude in the repo and press Shift+Tab twice to reach plan mode.
  2. Prompt: @tests/test_billing.py fails on leap years. Find the cause and propose a fix. Claude reads the test and the code it imports, and changes nothing.
  3. Read the plan. If it is wrong, say why and let it re-plan. If it is right, accept it with auto-accept edits, so file changes apply without a prompt while shell commands still ask.
  4. It edits, then asks to run pytest tests/test_billing.py. Approve it with the don’t-ask-again option and a matching Bash rule is saved, so the next run goes straight through.
  5. Tests pass. Read git diff yourself, then /context: if history dominates, /compact keep the leap-year cause before a related task, or /clear before an unrelated one.
  6. Ask: commit this, with a message that explains the leap-year cause. If you had to correct Claude along the way, add that correction to CLAUDE.md so tomorrow’s session starts with it.

The same diagnosis, headless, as a CI step that never edits:

claude -p "Run pytest. For each failure print FILE:LINE and the cause in one sentence. Do not edit files." \
  --allowedTools "Read" "Grep" "Bash(pytest *)" \
  --output-format json --max-budget-usd 1 > out.json
jq -r '.result' out.json
jq '.total_cost_usd, .num_turns, .session_id' out.json

No edit tool is allowed, so the job can only read and report. The session ID lets a developer reopen the exact run with claude -r to ask follow-up questions.

Recipes

Review a branch in CI with a spending cap

git diff origin/main...HEAD | claude -p "Review this diff for bugs and security issues. List each with file and line." --output-format json --max-budget-usd 2 > review.json
jq -r '.result' review.json

Print mode runs once and exits; the JSON carries the answer in .result plus cost and session details, and the budget cap stops a runaway review.

Give Claude a project memory

claude
/init
Add to CLAUDE.md: tests run with "npm test -- --include=PATH", and files under generated/ are build output, so never edit them.

/init drafts the file and the follow-up adds what Claude would otherwise get wrong. It is loaded into every session, so keep each line specific.

Run two tasks in parallel without collisions

# terminal 1
claude -w fix-auth "Fix the token refresh bug in src/auth"
# terminal 2
claude -w add-tests "Add tests for src/billing"

Each session gets its own git worktree and branch, so the two agents never edit the same checkout. Merge or open a pull request from each branch when it is done.

Connect an MCP server and check it

claude mcp add --transport http sentry https://mcp.sentry.dev/mcp
claude mcp list
claude
/mcp

Servers that need OAuth let you sign in from /mcp; add --scope project to share the server with the team through .mcp.json.

Lock down a scripted run

claude -p "Update CHANGELOG.md for the last release" --allowedTools "Read" "Edit" "Bash(git log *)" --permission-mode acceptEdits --max-budget-usd 1

In print mode nobody is there to approve prompts, so pre-approve exactly the tools the task needs; anything else is refused rather than left waiting.

When to use it, and when not

Claude Code fits work that spans files and needs a real checkout: tracing a bug through its call sites, a refactor across a package, getting a red test suite green, or the same scripted change across many repos with claude -p. It runs your build and tests, so it can check its own work.

  • Plan mode for unfamiliar code or anything that touches many files: you review the intent before any edit.
  • Auto-accept edits once the plan is agreed and the change is easy to review in git diff.
  • Headless for repeatable jobs with a clear output: review comments, release notes, triage labels.

Reach for something else for a one-line change you can type faster than you can describe it, for work that needs production credentials you would not hand to a script, and for decisions that are really product or design questions, where it will confidently pick an answer for you.

Trade-offs and limits

ChoiceGives youCosts you
Default modesee every edit and command before it runsconstant prompts on long tasks
Auto-accept editsuninterrupted editingreview moves to afterwards, in the diff
Broad allow rulesfewer prompts in every sessiona bare Bash rule lets every command through, rm included
Long sessionsearlier decisions stay in vieweach compaction blurs detail, and stale context steers later work
Subagentsexploration stays out of the main contextmore total tokens; only a summary comes back
A long CLAUDE.mdmore rules followedpaid for in every session; buried rules get missed

Every file read and command output takes context, so cost and quality both depend on focus. One task per session is the cheapest habit there is.

Common mistakes

  • Correcting the same thing twice in chat. A correction lasts only for the session. If you would have to say it again tomorrow, it belongs in CLAUDE.md or a rule file.
  • One session sprawling across tasks. Leftover files and failed attempts from the first task steer the second. /clear between unrelated tasks costs nothing.
  • Accepting a summary instead of a diff. “All tests pass” is a claim. Read git diff and the actual test output, especially after a stretch of auto-accepted edits.
  • Headless runs missing a tool. In -p mode nobody can approve a prompt, so an unlisted tool is refused and the job quietly does less than you asked. List every tool it needs in --allowedTools and read .result for refusals.
  • Hooks that were meant to block. A hook that exits 1 reports an error but lets the action go ahead. Only exit 2 blocks. Test a new hook on a harmless edit first.
  • Secrets in shared settings. .claude/settings.json and .mcp.json travel with the repo. Keep keys in environment variables and personal tweaks in settings.local.json.

Check yourself

A PreToolUse hook prints “generated file, do not edit” to stderr and exits 1. Is the Edit blocked?

No. Exit 1 is a non-blocking error, so the edit goes ahead. Only exit code 2 blocks the call and hands stderr to Claude as the reason.

Your allow list has Bash(git *) and your deny list has Bash(git push *). Claude tries git push origin main. What happens?

It is refused. Deny rules are checked first and win, so the narrow deny carves an exception out of the broad allow.

In a fresh session you press Shift+Tab twice. Which mode are you in, and can Claude edit files?

Plan mode (normal → auto-accept edits → plan). Claude can read and propose, but makes no edits until you approve the plan.

A CI step runs claude -p "…" --output-format json. Which field holds the answer, and which the spend?

.result holds the final text and .total_cost_usd the spend. .session_id lets you resume that exact run with claude -r.

Questions about Claude Code (Agentic CLI) Cheat Sheet

What is CLAUDE.md in Claude Code?

CLAUDE.md is a Markdown file of instructions that Claude Code loads into context at the start of every session. The project file at the repository root holds team knowledge such as build and test commands, conventions and directories not to touch; a personal one in ~/.claude applies to all your projects, and files in subdirectories load when Claude works there. Run /init to generate a first draft. Keep it short and specific, because every line is read in every session: record what Claude gets wrong, not what any engineer already knows.

How do I stop Claude Code from asking for permission every time?

Allow the specific tools and commands you trust. Choosing the always-allow option on a prompt, or editing rules in /permissions, adds entries such as a git diff or npm test pattern to your settings so they never prompt again. Shift+Tab switches to auto-accept edits, which applies file changes without asking while still checking commands, and plan mode does the opposite by changing nothing. Skipping every check with the dangerously-skip-permissions flag is meant only for isolated sandboxes without network access, because then nothing stands between the agent and your machine.

What is the difference between subagents, skills and slash commands?

A slash command is a saved prompt that you trigger yourself by typing its name. A skill is a folder of instructions and optional scripts that Claude loads on its own when a task matches the skill’s description, so the expertise is available without filling every session’s context. A subagent is a separate agent with its own system prompt, tools, model and context window; the main session delegates a task to it and gets back only the result, which keeps exploration-heavy work such as searching a large codebase out of the main conversation.

Can I use Claude Code in CI or scripts?

Yes. claude -p runs one prompt non-interactively and prints the result, so it composes with pipes and shell scripts. Add --output-format json for machine-readable output that includes cost and session details, or stream-json to process events as they happen. Because nobody is present to approve actions, list the allowed tools explicitly with --allowedTools, cap spending with --max-budget-usd, and keep credentials in the CI secret store. Typical uses are reviewing pull requests, triaging issues, writing release notes and running codemods across a repository.