# Claude Code Advanced workflows

> Practical Claude Code workflows with plan mode, subagents, background tasks, worktrees, headless execution, custom commands, and verification.

URL: https://docs.passion8.cc/en/docs/claude-code/tips
Language: en
Publisher: Passion8

This page connects the workflows that make Claude Code practical rather than repeating configuration. For individual capabilities, see [Memory and rules](https://docs.passion8.cc/en/docs/claude-code/memory), [MCP](https://docs.passion8.cc/en/docs/claude-code/mcp), [Hooks](https://docs.passion8.cc/en/docs/claude-code/hooks), [Permissions](https://docs.passion8.cc/en/docs/claude-code/permissions), and [Caching](https://docs.passion8.cc/en/docs/claude-code/prompt-caching).

## Structure a large task





### Plan first


```text
Read the relevant files first. List the smallest proposed change, risks, and validation commands.
Do not modify files yet.
```

Use `/plan` or `Shift+Tab` to enter plan mode.




### Implement next


```text
Implement the plan. Do not perform unrelated refactoring.
If the scope changes, stop and explain it first.
```




### Verify last


```text
Run lint, type checking, and relevant tests after the change.
For UI changes, check light mode, dark mode, and mobile layouts.
```







## Subagents

Subagents divide work between focused roles, isolate context, and reduce noise in the main conversation.

```markdown title=".claude/agents/test-runner.md"
---
name: test-runner
description: Run tests and identify the cause of failures
tools: Read, Bash, Grep
---

You are a testing specialist. Run the project tests and identify the cause of failures.
Do not make broad changes without authorization; suggest the smallest fix.
```

Usage:

- Ask Claude to create or update `.claude/agents/`.
- Store project agents in `.claude/agents/`.
- Store personal agents in `~/.claude/agents/`.
- Combine background tasks with `/tasks`, `/background`, and `claude agents`.

## Background and parallel work

| Command | Purpose |
| --- | --- |
| `/background` | Move the current session to the background and free the terminal |
| `/tasks` | Inspect background tasks in the current session |
| `/fork` | Dispatch the current context to a background subtask |
| `/batch` | Split a large migration across parallel worktrees |
| `claude agents` | Manage all background sessions |
| `claude attach <id>` | Return to a background session |

Start parallel work with a clean repository and clear task ownership. Large changes across files are better suited to `--worktree` or `/batch`, avoiding agents editing the same workspace.

## Checkpoints and rollback

| Tool | Use |
| --- | --- |
| Press `Esc` twice | Return to an earlier message for editing |
| `/rewind` | Rewind the conversation and file checkpoints |
| Git | Revert actual code changes |
| `/compact` | Keep a summary and continue the same task |
| `/clear` | Change tasks or reset context |

When the direction is wrong, try `/rewind` first. When the task is on track but the conversation is long, use `/compact`.

## Headless mode

`claude -p` works well in scripts and CI:

```bash
git diff --staged | claude -p "Summarize these changes in one sentence for a commit message"
claude -p "List repository TODOs grouped by file" --output-format json
claude -p "Fix lint failures" --allowedTools "Read,Edit,Bash"
```

Do not rely only on `--allowedTools` for unattended runs. It pre-approves tools; it does not restrict the available set. Use `--tools` to restrict built-in tools and `--disallowedTools` or permission deny rules to prohibit tools.

## Custom commands

Store recurring prompts in `.claude/commands/`:

```markdown title=".claude/commands/release-check.md"
---
description: Pre-release review
argument-hint: [version or module]
---

Review release risks for $ARGUMENTS.
Read the Git diff first, then check tests, documentation, configuration, and security risks.
Report blockers and non-blocking recommendations.
```

Invoke it with:

```text
/release-check billing
```

## Verification habits

| Change | Minimum check |
| --- | --- |
| Documentation | Build the page and open its route |
| TypeScript | `npm run typecheck` |
| Lint-related changes | `npm run lint` |
| UI | Desktop, mobile, light, and dark modes |
| MCP / hook | `/mcp`, `/hooks`, and one real trigger |
| Permissions | `/permissions` and positive/negative tool-call examples |

## Continue reading



- [Command reference](https://docs.passion8.cc/en/docs/claude-code/commands): Common CLI and slash commands.
- [Prompt caching](https://docs.passion8.cc/en/docs/claude-code/prompt-caching): Caching behavior for long sessions and cost optimization.

