← All articles
AI Tools1 min read

Working with Claude Code: A Practical Example

Setup done, let's use Claude Code for real — asking questions about a codebase, making a scoped change, and running it non-interactively in a script.

S

Swapnika Voora

Author

Claude Code earns its keep on tasks that span multiple files. Once it's set up, the workflow is conversational: you describe intent, review its plan, and approve changes. Here's what that looks like in practice.

Ask before you change

Start by understanding the code. Claude reads files on demand, so you can ask questions without opening anything yourself.

explore.sh
claude
> Where is rate limiting implemented, and which endpoints use it?

It searches the project, cites the files it found, and explains the flow — a fast way to onboard to an unfamiliar repo.

Make a scoped change

Describe the change and constrain its scope. Being specific about files and tests keeps the edit focused.

prompt
> Add an Idempotency-Key header check to POST /api/payments.
> Only touch PaymentController and PaymentService, and add a unit test.

Claude proposes a diff, you review it, and approve or refine before anything is written.

Run it non-interactively

For automation, the -p (print) flag runs a single prompt and exits — useful in scripts and CI pipelines.

ci-review.sh
git diff main | \
  claude -p "Review this diff for security issues. List findings only." \
  > review.md

Takeaways

  • Use conversation to explore a codebase before making changes.
  • Constrain edits by naming files and required tests in the prompt.
  • The -p flag makes Claude scriptable for one-shot, headless tasks.

Treat every change as a normal pull request: review the diff, run the tests, and commit deliberately rather than trusting the agent blindly.

#claude#anthropic#cli#example

More in AI Tools