Claude Recursive Spawn banner
haasonsaas haasonsaas

Claude Recursive Spawn

Development community

Description

Bash script for recursive Claude Code execution with depth control, JSON output parsing, and automatic session management

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

README

Claude Recursive Spawn

A flexible bash script for recursive Claude Code execution with depth control, multiple output modes, and extensive configuration options.

Features

  • 🔄 Recursive execution with configurable depth limits
  • 📊 Multiple output modes: JSON, extracted results, or status messages
  • 🎨 Colored output with verbose mode for debugging
  • 🔧 Flexible configuration via CLI options or environment variables
  • 📁 Automatic output management with timestamped files
  • 🚀 Smart Claude detection across different installation methods

Installation

git clone https://github.com/haasonsaas/claude-recursive-spawn.git
cd claude-recursive-spawn
chmod +x claude_spawn

Usage

./claude_spawn [options] [depth] [prompt]

Options

  • -h, --help - Show help message
  • -m, --max-depth NUM - Set max recursion depth (default: 4)
  • -o, --output-dir DIR - Set output directory (default: /tmp/claude_spawn)
  • -v, --verbose - Enable verbose output
  • -j, --json-only - Only output JSON (no status messages)
  • -c, --claude-path PATH - Set path to Claude executable
  • -e, --extract-result - Extract and display the result field from JSON

Examples

# Basic usage
./claude_spawn 0 "What is 2+2?"

# With custom max depth
./claude_spawn -m 6 0 "Analyze this codebase"

# JSON output only (for piping)
./claude_spawn -j 0 "List files" | jq .result

# Extract result directly
./claude_spawn -e 0 "What is the capital of France?"

# Verbose mode for debugging
./claude_spawn -v 0 "Debug this issue"

# Custom Claude path
./claude_spawn -c /opt/claude/bin/claude 0 "Hello"

Environment Variables

  • CLAUDE_MAX_DEPTH - Override default max depth
  • CLAUDE_TMP_DIR - Override default output directory
  • CLAUDE_CMD - Override default Claude command
  • CC_PROMPT - Default prompt if none provided

Output Structure

Output files are saved as: `depth-{depth}-{timestamp}.json`

Example JSON output:

{
  "t