timeout-prevention
Prevent request timeouts in Claude Code sessions by chunking long operations, implementing progress checkpoints, using background processes, and optimizing tool usage patterns. Use when performing bulk operations, processing large datasets, running long-running commands, downloading multiple files, or executing tasks that exceed 2-minute timeout limits. Implements strategies like task decomposition, incremental processing, parallel execution, checkpoint-resume patterns, and efficient resource management to ensure reliable completion of complex workflows.
What this skill does
# Timeout Prevention Skill
Expert strategies for preventing request timeouts in Claude Code by breaking down long operations into manageable chunks with progress tracking and recovery mechanisms.
## When to Use This Skill
Use when:
- Performing bulk operations (100+ files, repos, etc.)
- Running long commands (>60 seconds)
- Processing large datasets
- Downloading multiple files sequentially
- Executing complex multi-step workflows
- Working with slow external APIs
- Any operation that risks timing out
## Understanding Timeout Limits
### Claude Code Timeout Behavior
- **Default Tool Timeout**: 120 seconds (2 minutes)
- **Request Timeout**: Entire response cycle
- **What Causes Timeouts**:
- Long-running bash commands
- Large file operations
- Sequential processing of many items
- Network operations without proper timeout settings
- Blocking operations without progress
## Core Prevention Strategies
### 1. Task Chunking
Break large operations into smaller batches:
```bash
# ❌ BAD: Process all 1000 files at once
for file in $(find . -name "*.txt"); do
process_file "$file"
done
# ✅ GOOD: Process in batches of 10
find . -name "*.txt" | head -10 | while read file; do
process_file "$file"
done
# Then process next 10, etc.
```
### 2. Progress Checkpoints
Save progress to resume if interrupted:
```bash
# Create checkpoint file
CHECKPOINT_FILE="progress.txt"
# Save completed items
echo "completed_item_1" >> "$CHECKPOINT_FILE"
# Skip already completed items
if grep -q "completed_item_1" "$CHECKPOINT_FILE"; then
echo "Skipping already processed item"
fi
```
### 3. Background Processes
Run long operations in background:
```bash
# Start long-running process in background
long_command > output.log 2>&1 &
echo $! > pid.txt
# Check status later
if ps -p $(cat pid.txt) > /dev/null; then
echo "Still running"
else
echo "Completed"
cat output.log
fi
```
### 4. Incremental Processing
Process and report incrementally:
```bash
# Process items one at a time with status updates
TOTAL=100
for i in $(seq 1 10); do # First 10 of 100
process_item $i
echo "Progress: $i/$TOTAL"
done
# Continue with next 10 in subsequent calls
```
### 5. Timeout Configuration
Set explicit timeouts for commands:
```bash
# Use timeout command
timeout 60s long_command || echo "Command timed out"
# Set timeout in tool calls
yt-dlp --socket-timeout 30 "URL"
git clone --depth 1 --timeout 60 "URL"
```
## Practical Patterns
### Pattern 1: Batch File Processing
```bash
# Define batch size
BATCH_SIZE=10
OFFSET=${1:-0} # Accept offset as parameter
# Process batch
find . -name "*.jpg" | tail -n +$((OFFSET + 1)) | head -$BATCH_SIZE | while read file; do
convert "$file" -resize 800x600 "thumbnails/$(basename $file)"
echo "Processed: $file"
done
# Report next offset
NEXT_OFFSET=$((OFFSET + BATCH_SIZE))
echo "Next batch: Run with offset $NEXT_OFFSET"
```
**Usage**:
```bash
# First batch
./process.sh 0
# Next batch
./process.sh 10
# Continue...
./process.sh 20
```
### Pattern 2: Repository Cloning with Checkpoints
```bash
#!/bin/bash
REPOS_FILE="repos.txt"
CHECKPOINT="downloaded.txt"
# Read repos, skip already downloaded
while read repo; do
# Check if already downloaded
if grep -q "$repo" "$CHECKPOINT" 2>/dev/null; then
echo "✓ Skipping $repo (already downloaded)"
continue
fi
# Clone with timeout
echo "Downloading $repo..."
if timeout 60s git clone --depth 1 "$repo" 2>/dev/null; then
echo "$repo" >> "$CHECKPOINT"
echo "✓ Downloaded $repo"
else
echo "✗ Failed: $repo"
fi
done < <(head -5 "$REPOS_FILE") # Only 5 at a time
echo "Processed 5 repos. Check $CHECKPOINT for status."
```
### Pattern 3: Progress-Tracked Downloads
```bash
#!/bin/bash
URLS_FILE="urls.txt"
PROGRESS_FILE="download_progress.json"
# Initialize progress
[ ! -f "$PROGRESS_FILE" ] && echo '{"completed": 0, "total": 0}' > "$PROGRESS_FILE"
# Get current progress
COMPLETED=$(jq -r '.completed' "$PROGRESS_FILE")
TOTAL=$(wc -l < "$URLS_FILE")
# Download next batch (5 at a time)
BATCH_SIZE=5
tail -n +$((COMPLETED + 1)) "$URLS_FILE" | head -$BATCH_SIZE | while read url; do
echo "Downloading: $url"
if yt-dlp --socket-timeout 30 "$url"; then
COMPLETED=$((COMPLETED + 1))
echo "{\"completed\": $COMPLETED, \"total\": $TOTAL}" > "$PROGRESS_FILE"
fi
done
# Report progress
COMPLETED=$(jq -r '.completed' "$PROGRESS_FILE")
echo "Progress: $COMPLETED/$TOTAL"
[ $COMPLETED -lt $TOTAL ] && echo "Run again to continue."
```
### Pattern 4: Parallel Execution with Rate Limiting
```bash
#!/bin/bash
MAX_PARALLEL=3
COUNT=0
for item in $(seq 1 15); do
# Start background job
(
process_item $item
echo "Completed: $item"
) &
COUNT=$((COUNT + 1))
# Wait when reaching max parallel
if [ $COUNT -ge $MAX_PARALLEL ]; then
wait -n # Wait for any job to finish
COUNT=$((COUNT - 1))
fi
# Rate limiting
sleep 0.5
done
# Wait for remaining jobs
wait
echo "All items processed"
```
### Pattern 5: Resumable State Machine
```bash
#!/bin/bash
STATE_FILE="workflow_state.txt"
# Read current state (default: START)
STATE=$(cat "$STATE_FILE" 2>/dev/null || echo "START")
case $STATE in
START)
echo "Phase 1: Initialization"
initialize_project
echo "PHASE1" > "$STATE_FILE"
echo "Run again to continue to Phase 2"
;;
PHASE1)
echo "Phase 2: Processing (Batch 1 of 3)"
process_batch_1
echo "PHASE2" > "$STATE_FILE"
echo "Run again for Phase 3"
;;
PHASE2)
echo "Phase 3: Processing (Batch 2 of 3)"
process_batch_2
echo "PHASE3" > "$STATE_FILE"
echo "Run again for Phase 4"
;;
PHASE3)
echo "Phase 4: Processing (Batch 3 of 3)"
process_batch_3
echo "PHASE4" > "$STATE_FILE"
echo "Run again for finalization"
;;
PHASE4)
echo "Phase 5: Finalization"
finalize_project
echo "COMPLETE" > "$STATE_FILE"
echo "Workflow complete!"
;;
COMPLETE)
echo "Workflow already completed"
;;
esac
```
## Command Optimization
### Optimize Bash Commands
```bash
# ❌ SLOW: Multiple commands sequentially
git clone repo1
git clone repo2
git clone repo3
# ✅ FAST: Parallel with wait
git clone repo1 &
git clone repo2 &
git clone repo3 &
wait
```
### Optimize File Operations
```bash
# ❌ SLOW: Process one file at a time
for file in *.txt; do
cat "$file" | process > "output/$file"
done
# ✅ FAST: Parallel processing
for file in *.txt; do
cat "$file" | process > "output/$file" &
done
wait
```
### Optimize Network Calls
```bash
# ❌ SLOW: Sequential API calls
for id in {1..100}; do
curl "https://api.example.com/item/$id"
done
# ✅ FAST: Batch API call
curl "https://api.example.com/items?ids=1,2,3,4,5"
```
## Claude Code Integration
### Strategy 1: Multi-Turn Workflow
Instead of one long operation, break into multiple turns:
**Turn 1**:
```
Process first 10 repositories and report progress
```
**Turn 2**:
```
Process next 10 repositories (11-20)
```
**Turn 3**:
```
Process final batch and generate report
```
### Strategy 2: Status Check Pattern
```bash
# Turn 1: Start background process
./long_operation.sh > output.log 2>&1 &
echo $! > pid.txt
echo "Started background process"
# Turn 2: Check status
if ps -p $(cat pid.txt) > /dev/null; then
echo "Still running... Check again"
tail -20 output.log
else
echo "Completed!"
cat output.log
fi
```
### Strategy 3: Incremental Results
Report partial results as you go:
```bash
echo "=== Batch 1 Results ==="
process_batch_1
echo ""
echo "=== Batch 2 Results ==="
process_batch_2
```
## Error Handling
### Graceful Degradation
```bash
# Try operation with timeout, fallback if fails
if timeout 30s expensive_operation; then
echo "Operation completed"
else
echRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.