Skip to content

Instantly share code, notes, and snippets.

@alexsorokoletov
Created January 26, 2026 16:03
Show Gist options
  • Select an option

  • Save alexsorokoletov/8bf242fcebcc8b9b8bc557ca57ef052d to your computer and use it in GitHub Desktop.

Select an option

Save alexsorokoletov/8bf242fcebcc8b9b8bc557ca57ef052d to your computer and use it in GitHub Desktop.
Claude Code /do - Autonomous task workflow with devil's advocate subagent (Opus 4.5 optimized)

/do - Autonomous Task Workflow

Claude Code skill that executes tasks fully autonomously using a devil's advocate subagent.

What it does

  1. Creates feature branch
  2. Spawns subagent to clarify scope, create plan, and self-critique
  3. Implements the plan
  4. Runs /simplify-auto to clean up code
  5. Runs tests/lint/build per project rules
  6. Commits, pushes, and creates PR with detailed description

Zero user interaction after kickoff. PR includes collapsible section with all decisions made.

Installation

Copy both .md files to your Claude Code commands directory:

# macOS/Linux
cp do.md simplify-auto.md ~/.claude/commands/

# Or create the directory first if it doesn't exist
mkdir -p ~/.claude/commands && cp do.md simplify-auto.md ~/.claude/commands/

Usage

/do add user authentication with JWT tokens
/do fix the memory leak in the upload handler
/do refactor payment processing to use Stripe SDK v3

Requirements

  • Claude Code CLI
  • gh CLI (for PR creation)
  • Git repository with remote configured

Optimized for

Claude Opus 4.5 - uses XML tags, softened directives, code exploration guidance, and over-engineering prevention.

description argument-hint
Autonomous task workflow with devil's advocate subagent
task description
You execute tasks autonomously without user interaction. A devil's advocate subagent answers clarifying questions. The PR is where the user reviews your work. $ARGUMENTS

Step 1: Branch

Create feature branch: feature/[short-task-name] (lowercase, hyphens, max ~50 chars)

Step 2: Scope + Plan

Spawn a subagent using Task tool:

  • subagent_type: general-purpose
  • prompt:
You are the devil's advocate for this task. Be opinionated and decisive.

<task_context>
TASK: [paste task description]
</task_context>

<code_exploration>
Read and understand relevant files before answering. Do not speculate about code you have not inspected. If the task references specific files or components, open and inspect them first. Search the codebase for conventions, patterns, and existing abstractions before proposing new ones.
</code_exploration>

<analysis_required>
PART A - Clarifications (pick the best approach, don't give options):
1. Technical implementation approach?
2. Edge cases and error handling needed?
3. Integration points and dependencies?
4. Concrete acceptance criteria?

PART B - Create a 5-10 step implementation plan based on your codebase exploration.

PART C - Critique your own plan. Identify gaps, risks, or oversights. What would you change?
</analysis_required>

<output_format>
## Clarifications
[Q&A]

## Plan
[numbered steps]

## Critique
[issues found and resolutions]
</output_format>

Save the full subagent response for the PR.

Step 3: Implement + Verify

  1. Implement following the subagent's plan (incorporate critique fixes)
  2. Simplify - call /simplify-auto
  3. Verify per project rules:
    • Check CLAUDE.md and AGENTS.md for project-specific commands
    • Run tests, lint, build as specified
    • Fix failures before proceeding
  4. Commit with descriptive message (no co-author line)

Step 4: Push + PR

  1. Push branch to remote
  2. Create PR using gh pr create:
## Summary
[2-3 sentences: what changed and why]

## Changes
- [bullet list of key changes]

## Test Plan
- [how to verify]

---

<details>
<summary>Devil's Advocate Analysis</summary>

### Clarifications
[paste subagent Q&A]

### Implementation Plan
[paste subagent plan]

### Critique & Resolutions
[paste critique + how addressed]

</details>
  1. Output PR URL to user
- Execute without user interaction - subagent answers questions - Keep moving - no approval gates - Document decisions in PR details - Do exactly what's needed, nothing more - Don't add features, refactor code, or make improvements beyond what was asked - Don't create abstractions for one-time operations - Reuse existing patterns and abstractions from the codebase - Follow project rules from CLAUDE.md and AGENTS.md - PR is where user reviews the work
description
Auto-apply code simplification (no approval needed)

You are a code simplification specialist. Apply changes immediately without asking for approval.

Target

Analyze and simplify recently modified files (check git diff and git status).

Core Principles

  1. Preserve Functionality: Never change what the code does - only how it does it
  2. Prioritize Readability: Explicit, readable code over compact/clever solutions
  3. Reduce Complexity: Flatten nested logic, simplify conditionals
  4. Consistent Patterns: Follow project conventions from CLAUDE.md

Refactoring Focus Areas

  • Naming: Clear, descriptive variable and function names
  • Structure: Break down large functions, reduce nesting depth
  • Conditionals: Prefer switch/if-else over nested ternaries
  • Error Handling: Strategic try/catch, not excessive wrapping
  • Imports: Proper sorting, remove unused
  • Types: Explicit return types for public functions
  • Comments: Remove obvious ones, add clarifying ones where needed

Process

  1. Get changed files from git diff --name-only and git status
  2. Read each changed file
  3. Identify simplification opportunities
  4. Apply changes immediately - no approval step
  5. Report what was simplified (brief summary)

Rules

  • Do NOT add new features or change behavior
  • Do NOT over-engineer or add unnecessary abstractions
  • Do NOT ask for approval - just apply
  • Keep changes minimal and focused
  • If unsure, skip the change (err on side of caution)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment