claude-code-mcp
0/15 complete

Module 1: Claude Code Fundamentals · 20 min

Your First Session: Reading, Editing, and Running Code

// sabak

Turn this lesson into one checked practice output

By the end, you should be able to explain the core idea behind “Your First Session: Reading, Editing, and Running Code” in your own words, apply it to one small real or sample task, and identify what still needs human review.

  1. 1

    Learn

    Read the 20-minute lesson without copying an output blindly.

  2. 2

    Try

    Use a small, non-sensitive example that you can inspect line by line.

  3. 3

    Review

    Check facts, fit, and risk; save one improvement note for next time.

A professional session follows inspect → plan → edit → verify → review. Claude’s final explanation is not evidence; the diff, tests, and observed behavior are.

Define the Task Contract

State exact behavior, scope, and checks:

Problem: negative quantity is accepted
Required: reject non-integer and non-positive quantity
Preserve: valid quotation totals and public API
Allowed files: src/quote.ts and tests/quote.test.ts
Verify: npm test and npm run lint
Stop: unclear requirement or same failure twice

Ask Claude to inspect before editing. Review its understanding and file list. A plan is useful when it exposes assumptions; it is not permission to expand scope.

Make the Change Reviewable

Keep the patch small. Avoid unrelated formatting, dependency upgrades, or generated-file churn. Run targeted tests first, then broader relevant gates. Read the diff yourself and test an edge case the model did not mention.

If a command is destructive, changes external state, accesses credentials, publishes, deploys, sends a message, or modifies production data, stop and use a separate authorized workflow.

Worked Example

Claude reads the quotation function and tests, proposes an integer/positive guard, and edits two files. The targeted tests pass. The developer inspects the diff and adds a maximum-quantity business rule only after confirming that it is actually required; it is not smuggled into the first patch.

An independent command run confirms lint and tests. git status shows only the intended files. The completion note names behavior, evidence, and remaining assumptions.

Failure Cases to Diagnose

  • “Fix this” with no observable requirement: write acceptance criteria.
  • Agent edits before inspecting: restore and begin from current facts.
  • Test rewritten to accept the bug: compare against the requirement.
  • Large formatting diff hides logic: separate mechanical changes.
  • Command output assumed successful: check exit code and relevant result.
  • Untracked generated files ignored: review complete status.

🇵🇰 Pakistan Angle

Test exact PKR handling with integers or decimal-safe types; floating-point shortcuts can corrupt money. Use local examples but label sample tax, delivery, or discount rules rather than inventing legal or business policy.

For freelance work, preserve client changes already in a dirty worktree. Do not reset or overwrite unknown edits. Record what you changed and let the client reproduce checks without access to your Claude session.

Hands-On Exercise

  1. Write a bounded bug contract.
  2. Ask for inspection and plan only.
  3. Approve the smallest edit.
  4. Run targeted and broader checks independently.
  5. Review diff/status and produce evidence-based handoff.

Completion Rubric

  • Required and preserved behavior are explicit.
  • File and command scope are bounded.
  • The diff contains no unrelated change.
  • Tests represent requirements, not implementation.
  • Checks are independently verified.
  • Handoff names assumptions and evidence.

Sources

Key takeaway: treat Claude Code output as a proposed patch; completion comes from a small diff and independently reproducible behavior.

Self-check

Before you mark Lesson 1.2 complete

  • Can I explain “Your First Session: Reading, Editing, and Running Code” without reading the lesson back word for word?
  • Did I complete the lesson’s practice step on a real or clearly labelled sample task?
  • Did I check the result for invented facts, private data, unsafe actions, and mismatch with the brief?