4 min read · EN

Automation & Multi-Surface Workflows

Run Claude Code headlessly, review CI integration patterns, and distinguish session loops from Remote Control workflows.

Updated

Claude Code can run scripted tasks in CI pipelines and scheduled jobs. Non-interactive runs need explicit authentication, tool permissions and failure handling; an interactive workflow does not automatically become safe unattended automation. Remote Control is a separate way to access a running local session.

This module covers practical automation patterns and the multi-surface workflow that makes Claude Code effective beyond the interactive terminal.


Headless Mode

The -p flag runs Claude Code non-interactively and writes the result to stdout. Tools that need approval require an explicit permission configuration; a run can fail or leave work incomplete. See the headless guide for input, output and tool-approval options.

claude -p "Explain what this project does"

This is the foundation for every automation pattern in this module. If it goes to stdout, you can pipe it, redirect it, or capture it in a script.

Practical Examples

Generate a changelog from recent commits:

claude -p "Summarize the changes in the last 5 commits as a changelog" > changelog.txt

Pipe a diff for review:

git diff | claude -p "Review these changes for bugs and security issues"

Staged change review before committing:

git diff --staged | claude -p "Review these staged changes. Flag anything that looks wrong."

Output Formats

Format Flag Use case
Text (default) Human-readable output, scripts that parse text
JSON --output-format json Structured data for downstream tools, APIs
Stream JSON --output-format stream-json Real-time processing of long-running tasks

Headless mode JSON output from a piped git diff review


CI/CD Integration

Headless mode makes Claude Code a natural fit for CI pipelines. The pattern: install Claude Code, pass it a prompt with relevant context, use the output.

For supported setup instructions and workflow examples, see the official GitHub Actions and GitLab CI/CD guides. These are platform-specific integrations, not official Azure DevOps templates. Use least-privilege credentials and review generated changes before merging.

Creative CI Use Cases

Code review is the obvious CI integration, but there's much more:

Use case Prompt pattern
Changelog generation git log --oneline v1.2..HEAD | claude -p "Write release notes from these commits"
Test gap analysis claude -p "Identify functions in src/ that have no corresponding test coverage"
Documentation sync claude -p "Check if the API docs in docs/ match the actual endpoint signatures in src/routes/"
Migration validation claude -p "Verify all database migration files are reversible and follow our naming convention"
Dependency audit claude -p "Review package.json for outdated or vulnerable dependencies and suggest updates"

These prompts can assist a CI review, but they are not deterministic tests, vulnerability scans or proof that a migration is safe. Keep those checks as separate pipeline gates.


/loop — Recurring Tasks

Some tasks aren't one-shot. /loop runs a prompt or command on a recurring interval within your current session.

/loop 5m Check if the deployment to staging has completed. Look at the
output of 'kubectl get pods -n staging' and tell me when all pods are
Running.

The first argument is the interval (defaults to 10 minutes if omitted). The rest is the prompt that runs each cycle.

Use Cases

Monitor a deployment:

/loop 2m Run 'kubectl rollout status deployment/api -n production' and
summarize the current state. Alert me when it's complete or if there
are errors.

Watch a long-running test suite:

/loop 5m Check if the integration test suite is still running. Look at
the latest output in test-results/ and report any new failures.

Periodic health check during development:

/loop 10m Run the smoke tests and tell me if anything has broken since
last check.

Remote Control

Claude Code sessions running in your terminal can be accessed from other devices. Start a long-running task on your workstation and monitor it from your phone or laptop while away from your desk.

Use Cases

Monitor from mobile: You kicked off a large refactor before lunch. Check progress from your phone to see if Claude hit any issues that need your input.

Approve from anywhere: Claude needs permission to run a destructive command or push to a branch. Approve it from your phone instead of walking back to your desk.

Review results on the go: A long task completed. Review the results and decide next steps from your tablet.


Multi-Surface Workflows

Claude Code runs across multiple surfaces — terminal, VS Code, JetBrains IDEs, Chrome extension, desktop app, and mobile (via remote control). Each has different strengths.

The General Rule

Use the terminal for doing, use an IDE for reviewing, use mobile for monitoring.

A typical workflow across surfaces:

  1. Terminal or IDE: Give Claude a task, watch it work
  2. VS Code / JetBrains: Review the diffs visually, check the changes make sense
  3. Terminal: Run tests, commit, push
  4. Mobile: Monitor CI pipeline, approve deployment

Want to discuss a project like this?

SFLOW helps companies implement practical AI solutions — from custom platforms to industrial integrations with your existing systems.

← All courses