Vibe Coder · Unit 9: Claude Code Commands and Extensions · Lesson 9 of 10

Headless and the Agent SDK

Engineers: run Claude Code without the interactive prompt, from scripts and pipelines, and build your own agents on the same engine.

Read the short notes and pictures.Do everything inside a blue frame.

Automation

Headless mode runs a single prompt non-interactively and prints the result, which makes Claude Code scriptable. The Agent SDK exposes the same agent loop, tools and permission system as a library, for building agents inside your own applications.

A 3D scene of coloured blocks and cards. One command, one result: $ claude -p "summarise the,   changes since the last tag".
Pass a prompt, get a result, no interactive session.

Headless uses

Nightly checks

Summarise failures and open an issue.

Bulk changes

Apply the same migration across many files or repositories.

Reports

Release notes from merged pull requests.

A 3D scene of coloured blocks and cards. The Agent SDK: the same engine, your tools, your agent.
The SDK gives you the engine to build your own agents.

Doing it safely

  1. Restrict tools

    Allow only what the job needs.

  2. Use a dedicated credential

    With the least access possible.

  3. Capture the output

    Log what it did.

  4. Start read-only

    Add write access once you trust the job.

ActivityBuild stepYour Claude Code setup

Script one task

Write a script that runs Claude Code headlessly to produce release notes from your recent commits, with read-only tools. Run it and save the output.

Done when

You will run a job like this in CI in the next lesson.

Keep these

  • Headless mode makes Claude Code scriptable.
  • The Agent SDK is the same engine as a library.
  • Restrict permissions in unattended runs.