Claude Code 101
· Claude code is an agentic coding tool to understand the code base, edit files, run commands and integrates with existing coding tools. Available in VS Code, Terminal, Claude Desktop App, etc..
· Claude Vs Claude Code:
o Direct access to files by Claude code, have to copy paste files in Claude.ai.
o Claude code works as an agent
· Agent is a software which interact with environments and performs a defined goal.
· Claude Code what it does:
o Read and understand your codebase.
o Edit files across your project
o Edit files across your project(execute, build script, run scripts, install packages, and use the o/p to decide what to do next)
o Search the web
How Claude Code Works
The Agentic Loop:
1. You enter a prompt into Claude Code.
2. Claude gathers the context it needs by interacting with the model, which returns text or a tool call that Claude Code can execute.
3. It takes action — for example, editing a file or running a command.
4. It verifies the results and determines whether they achieve what your prompt set out to do.
5. If they do, Claude finishes and waits for the next prompt. If they don’t, it loops back and tries again until the results are complete and verifiable.
Context:
· Claude has a context window – how much of your conversation, file contents, command outputs, and more it can store and reference
· Once you reach that limit, Claude Code compacts your conversation — automatically determining what it can remove or summarize to bring the context window back down to a usable size.
Tools:
· Backbone of how agents work
· Most AI Assistants – Text Take-in and return Text out
· Tools let Claude code when to execute code and get close to complete the task
Permissions:
- Default behavior: Claude asks for explicit permission before editing a file or running a shell command.
- Auto-accept: Files are edited without asking, but commands still require approval.
- Plan mode: Uses read-only tools to compile a plan of action before starting any work.
All of this can be configured in your settings file.
Installing Claude Code:
On macOS, Linux, or WSL, use the curl command to install it in one go. If you prefer Homebrew, you can also use brew install, but note that this method doesn’t support auto-updates.
On Windows, there are a few options. In PowerShell, use the Invoke-RestMethod command. In CMD, use the curl command. There’s also a winget command available, though like Homebrew, it won’t auto-update.
Visual Studio Code
· Open your Extensions panel and search for “Claude Code.” Install
· Restart VS Code
· open the command palette with Ctrl/Cmd + Shift + P and search for “Claude Code Open in New Tab.” You can also click the Claude logo if it’s visible in your sidebar.
Web:
Going to claude.ai/code, or by clicking the “Code” label in the sidebar of the chat app. This works similarly to the desktop app, but you’re restricted to GitHub repositories.
Which One Should I Use?
· The terminal is your best bet — features ship there first.
· The IDE integrations offer a nearly identical experience if you prefer Claude Code to feel more intertwined with your code editor.
· Desktop is great for letting Claude run in the background while you handle other tasks.
· Claude Code on the web is a solid option if you want to remotely work on projects through a GitHub repository.
First Prompt:
Auto-Accept vs. Approval
· choose whether Claude auto-accepts every file change it suggests, or whether it asks for your explicit permission each time. Press Shift + Tab to cycle between modes.
· Approval mode: Claude asks permission each time it wants to edit a file or run a command.
· Auto-accept mode: File edits are automatically approved, but commands still require your permission.
· Plan Mode: Within the Shift + Tab menu is Plan Mode. Plan mode takes your prompt and uses read-only tools to analyze your codebase and research your suggested implementation. It will ask clarifying questions along the way, then return a detailed plan it can execute.
· Plan mode is great for planning complex changes or doing a safe code review. Many times you’ll be asking Claude to handle multi-step implementations toward a feature, and this is exactly where Plan Mode excels.
Daily Workflows:
The Explore → Plan → Code → Commit Workflow
Explore and Plan
· The fastest way to handle these first two steps is with Plan Mode
· In plan mode, Claude can’t edit files — it just reads files to gather information about how it will tackle the implementation.
Code
- Code is the back and forth between you and Claude before settling on the final outcome.
Commit
· Helps you review and push your code so you can start on your next feature.
Context Management:
Context is Claude’s working memory. Every file it reads, every command it runs, every message you send — it all takes up space in the context window.
What Happens When Context Fills Up
· The context window is automatically compacted when reach the limit
· Compaction summarizes important details and removes unnecessary tool call results to free up space.
· Note that this process can potentially lose details.
Commands
· /compact – can run compaction manually with the /compact command. This compacts everything up to that point. It’s handy when you want to free up context space while keeping a memory of what you previously worked on.
· /clear – completely start from scratch with no memory of the previous session
· /context – To check the state of your context, get a high-level overview of your context size, the categories taking up the most space, and a visual graphic showing the breakdown.
Saving Context Space:
· Be specific – A vague prompt might seem smaller, but it actually costs more context in the long run
· Manage your MCP servers – MCP servers load all of their available tools into context by default, even when you’re not using them. Use subagents. Subagents run in parallel with your main agent but have a completely separate context window
Code Review:
Claude Code has a few built-in features that make your git workflow faster.
Review with a Subagent
· Before you push a PR, ask Claude to use a subagent to review your changes. The subagent runs in its own context window with fresh eyes
· When creating a code-reviewer subagent, restrict it to read-only tools. A reviewer should flag issues, not edit files. Check the subagent configuration into your repo so your whole team uses the same reviewer.
· The /commit-push-pr Skill – skill handles the commit, push, and PR creation all in one step. Instead of doing each manually, just run the skill and Claude takes care of it.
· Session Linking with –from-pr – creates a PR through gh pr create, the session gets linked to that PR automatically. If you need to come back to it later — maybe to address review comments or fix a failing build — run:
claude –from-pr <PR_NUMBER>
This picks up right where you left off.
Customizing Claude Code
The CLAUDE.md File – It gives Claude Code persistent memory about your project.
· When you open Claude Code without a CLAUDE.md file, it starts fresh every time
· It’s a Markdown file
· Add to the root of your project
· Claude Code reads it automatically every time you start a session
· Think of it as an onboarding script for your codebase
· The contents of the CLAUDE.md file are appended to your prompt
CLAUDE.md file looks like:
Here’s what a typical CLAUDE.md file looks like:
# Project
This is a Next.js 15 app using the App Router, Tailwind, and Drizzle ORM.
# Commands
– Dev server: `pnpm dev`
– Run tests: `pnpm test`
– Lint: `pnpm lint`
# Code Style
– Use 2-space indentation
– Prefer named exports
– All API routes go in app/api/
– Use server actions instead of API routes where possible
CLAUDE.md is for Teams
· You can (and should) commit your CLAUDE.md to version control so your team benefits from it.
· There’s actually a hierarchy of memory files depending on who they’re for:
- Project-level CLAUDE.md lives in the root directory of your project. Shared with the team.
- User-level CLAUDE.md lives in your configuration folder. This one is just for you and applies across all your projects. Put your personal preferences here.
· Reference project docs – If you have documentation in your project that you want Claude to reference, use the @ symbol with the file path:
·
## README.md
Please read if you need more info: @README.md
· run /init to have Claude generate one for you for CLAUDE.md
Subagents
· Subagents are defined in Markdown files with YAML frontmatter.
· Create a sub agent run /agents
· Customization
- Persistent memory lets your subagent retain memory across conversations. This is great if you’re using it consistently on the same projects.
- Preload skills into subagents by adding the skill key and listing skills by name. Note that unlike skills in your main conversation, the entire skill is loaded into context here.
Skills
MCP
· Model Context Protocol (MCP) is an open standard that lets Claude Code connect to external tools and data sources
· Adding an MCP Server – claude mcp add command
· HTTP servers are for remote services
· Stdio servers are for local processes that run on your machine.
· Scoping Servers:
o Local — only available in the current project, just for you.
o User — available across all your projects.
o Project — uses a .mcp.json file that you check into version control so anyone on the codebase gets the exact same servers automatically.
· Context Costs:
o MCP servers add tool definitions to your context window — even when you’re not actively using them.
o Run /mcp to see what’s connected and disable anything you’re not actively using.
Hooks
· Hooks let you run commands at specific points in Claude Code’s lifecycle
· Hooks are deterministic — they always run.
Why Use Hooks:
You can tell Claude in your CLAUDE.md to run Prettier after every file edit. Most of the time it will. But sometimes it won’t. A hook makes it happen every single time, no exceptions.
Common use cases:
- Auto-formatting after file edits
- Logging all executed commands for compliance
- Blocking dangerous operations like modifying production files
- Sending yourself notifications when Claude finishes a task
How Hook Works:
· Hooks are configured in your settings.json
· Hook Events:
- PreToolUse — runs before a tool call
- PostToolUse — runs after a tool call completes
- UserPromptSubmit — runs when you submit a prompt, before Claude processes it
- Stop — runs when Claude finishes responding
- Notification — runs when Claude sends a notification
· You configure them through the /hooks command inside Claude Code, or by editing settings.json directly.
· The most common hook: auto-formatting after edits – Set a PostToolUse hook with a matcher of “Edit|MultiEdit|Write” so it fires whenever Claude modifies a file
· The command checks the file extension and runs the appropriate formatter — Prettier for TypeScript, gofmt for Go, whatever your project uses.
Blocking with PreToolUse
· PreToolUse hooks can block tool calls before they execute. Your hook receives the tool name and input as JSON on stdin. The exit code determines the behavior:
- Exit code 0 — proceed normally.
- Exit code 2 — block the action. The stderr message gets fed back to Claude as feedback so it knows why it was blocked and can adjust.
- Any other exit code — a non-blocking error that gets shown to you but doesn’t stop anything.
· This is how you enforce hard rules. Block writes to a production config directory. Block bash commands that contain rm -rf. Block commits to main. Whatever your team needs to be guaranteed, not suggested.
Sharing Hooks with Your Team
· Hooks configured in .claude/settings.json are project-level and can be checked into your repo. This means your entire team gets the same hooks automatically. Use the CLAUDE_PROJECT_DIR environment variable in your commands to reference scripts stored in your project, so they work regardless of Claude’s current working directory.


Leave feedback about this