Starting Your First Session
Open your terminal, navigate to any project directory (or create a new one), and type claude. That single command launches an interactive session where you can begin conversing with the AI agent.
# Create a practice project and start Claude Code
mkdir ~/claude-practice && cd ~/claude-practice
claude
When Claude Code starts, you will see a welcome message and a prompt waiting for your input. This is your conversation interface — everything you type here is natural language, and Claude will interpret it, plan actions, and execute them.
Let us walk through building a real utility from scratch to see how the agentic loop works in practice.
Step 1: Ask Claude to Create a Project
Start by describing what you want to build:
> Create a Node.js CLI utility called "logparse" that reads a log file,
counts occurrences of each log level (INFO, WARN, ERROR, DEBUG),
and outputs a summary table. Include a package.json with the project name.
Claude will immediately begin working. Watch the output — you will see it executing a sequence of tool calls:
Claude: I'll create the logparse utility for you.
📁 Creating package.json...
✏️ Writing src/index.js...
✏️ Writing src/parser.js...
✏️ Writing sample.log for testing...
Let me explain what I've created:
- package.json with the project name and a "bin" entry
- src/index.js - the CLI entry point that reads file arguments
- src/parser.js - the parsing logic with level counting
- sample.log - a test file with mixed log levels
Step 2: Understanding Permission Prompts
When Claude Code needs to create or modify files, it will show you a permission prompt. This is a critical safety feature — Claude never writes to your filesystem without explicit approval.
Claude wants to create file: src/index.js
[Y]es [N]o [A]lways allow [D]eny always
You have four options:
- Y (Yes) — Allow this specific action, one time only
- N (No) — Reject this specific action
- A (Always allow) — Allow this type of action for the rest of the session (recommended for trusted operations)
- D (Deny always) — Block this type of action for the rest of the session
For your first session, press Y for each prompt so you can see exactly what Claude is doing. As you build confidence, you will start using A to allow file creation and editing across the session.
Pro tip: You can also configure default permissions in your settings so trusted operations are auto-approved. We will cover this in a later lesson.
Step 3: Examining and Running the Code
After Claude finishes creating the files, ask it to explain what it built:
> Walk me through the code you just created. Explain the parsing logic.
Claude will read back through the files it created and provide a detailed explanation. Then, test the utility:
> Run the logparse utility against the sample.log file
Claude will execute the command in your terminal:
$ node src/index.js sample.log
Log Level Summary
─────────────────────
INFO │ 142 occurrences
WARN │ 38 occurrences
ERROR │ 17 occurrences
DEBUG │ 89 occurrences
─────────────────────
Total │ 286 entries
Step 4: Iterating on the Code
Now request a modification to see how Claude handles edits to existing files:
> Add a --json flag that outputs the results as JSON instead of a table.
Also add a --filter flag that only shows specific log levels.
Watch as Claude reads the existing files, plans the changes, and makes targeted edits. It uses the Edit tool with precise old_string / new_string replacements rather than rewriting entire files:
Claude: I'll add both flags to the CLI utility.
📖 Reading src/index.js...
✏️ Editing src/index.js - adding argument parsing for --json and --filter
📖 Reading src/parser.js...
✏️ Editing src/parser.js - adding filter logic
After the edits, Claude will typically run the utility again to verify the changes work:
$ node src/index.js sample.log --json --filter ERROR,WARN
{"ERROR": 17, "WARN": 38}
Step 5: Adding Tests
A key strength of Claude Code is its ability to write and run tests as part of the workflow:
> Write unit tests for the parser module using Jest. Run them to make sure they pass.
Claude will:
- Install Jest as a dev dependency (
npm install --save-dev jest) - Create a test file (
tests/parser.test.js) - Write comprehensive test cases covering normal input, edge cases, and the filter feature
- Execute
npx jestand verify all tests pass - If any test fails, it will automatically fix the issue and re-run
$ npx jest
PASS tests/parser.test.js
LogParser
✓ counts all log levels correctly (3 ms)
✓ handles empty log files (1 ms)
✓ filters specific log levels (2 ms)
✓ ignores malformed lines (1 ms)
✓ handles case-insensitive log levels (1 ms)
Test Suites: 1 passed, 1 total
Tests: 5 passed, 5 total
Step 6: Git Integration
Finally, let Claude handle the git workflow:
> Initialize a git repository, create a .gitignore for Node.js,
and make an initial commit with a descriptive message.
$ git init
$ # Creates .gitignore with node_modules/, .env, etc.
$ git add -A
$ git commit -m "feat: initial logparse CLI utility with JSON output and filtering"
Understanding the Session Flow
Throughout this walkthrough, notice how the session maintained continuous context. Claude remembered every file it created, every change it made, and the purpose behind each decision. You never had to re-explain what "logparse" was or remind it about the --json flag. This persistent context is what makes agentic coding so powerful compared to one-off code completions.
The session also demonstrated the full agentic loop multiple times: you gave a high-level instruction, Claude planned and executed multiple steps, observed the results (including test output), and adjusted as needed.
Ending Your Session
When you are done, exit the session cleanly:
# Press Ctrl+D or type:
/exit
Your conversation history is saved automatically and can be resumed later with the --session flag.
Key Takeaways
- Start a session by typing
claudein any project directory — Claude immediately understands the project context - Permission prompts give you full control over every file creation, edit, and command execution
- Claude Code iterates on code just like a human developer: read existing code, make targeted edits, run tests, fix issues
- A single conversational session can take you from zero to a working, tested, version-controlled utility
- The agentic loop means you describe the what and Claude handles the how, including multi-step plans with dozens of tool calls