HANDS-ON TASK · 1 OF 3

Your first headless prompt

Task: One question, one file

Goal

Ask Claude Code a question headlessly and capture the answer in /root/claude-answer.txt.

Practice

bash
claude -p "Explain the difference between a process and a thread in two sentences." > /root/claude-answer.txt
cat /root/claude-answer.txt

That's the whole pattern: -p makes Claude answer once and exit, stdout is the answer, and the shell does the rest.

Expected Result

A two-sentence explanation sitting in a file — produced by an AI agent you invoked like any other Unix tool.

Check Your Understanding

  • Where did the answer go before you redirected it?
  • What would claude -p "..." | wc -w tell you?

Ready To Continue

Press Submit when the file has content.

Start the lab on the right to run checks.

Pass the checks to continue
Spin up a fresh environment and practice live.
claude-code-ubuntu · fresh machine · ready in under a minute