Analyze complexity

From phenobarbital/ai-parrot · View interactive version

Analyze complexity is an AI agent skill from the GitHub repository phenobarbital/ai-parrot. Determine the optimal meta-prompting strategy for any task by analyzing complexity factors and routing to the appropriate approach.

How to use this skill

Skill file

SKILL: Analyze Task Complexity

Purpose

Determine the optimal meta-prompting strategy for any task by analyzing complexity factors and routing to the appropriate approach.

Description

Analyzes task complexity on a 0.0-1.0 scale based on four factors:

Returns a structured assessment with recommended strategy.

Usage

/analyze-complexity "Create a distributed rate-limiting system for 100k req/s"

Output Format

<complexity score="0.78" level="COMPLEX">
<factors>
  <word_count>0.15</word_count>
  <ambiguity>0.08</ambiguity>
  <dependencies>0.18</dependencies>
  <domain_specificity>0.37</domain_specificity>
</factors>
<strategy>autonomous_evolution</strategy>
<reasoning>
  Technical domain (distributed systems, rate-limiting) detected.
  Multiple dependencies (scalability, consistency, fault-tolerance).
  Requires deep expertise and iterative refinement.
</reasoning>
<recommended_approach>
  1. Generate 3+ architectural hypotheses
  2. Evaluate tradeoffs (CAP theorem, consistency models)
  3. Test against constraints (100k req/s target)
  4. Iteratively refine based on bottlenecks
</recommended_approach>
<suggested_iterations>3-5</suggested_iterations>
</complexity>

Strategy Routing

| Complexity Score | Level | Strategy | Iterations |

|-----------------|-------|----------|------------|

| < 0.3 | SIMPLE | direct_execution | 1 |

| 0.3 - 0.7 | MEDIUM | multi_approach_synthesis | 2-3 |

| > 0.7 | COMPLEX | autonomous_evolution | 3-5 |

Strategy Details

direct_execution (Simple tasks)

multi_approach_synthesis (Medium tasks)

autonomous_evolution (Complex tasks)

How It Works

  1. Tokenize the task description
  2. Count words and normalize (log scale)
  3. Detect ambiguous terms: "implement", "create", "design", "system", "handle"
  4. Identify dependencies: "if", "when", "based on", "depending", "multiple"
  5. Score domain specificity: Technical keywords, domain-specific terms
  6. Aggregate weighted scores (0.0-1.0)
  7. Route to optimal strategy

Examples

Example 1: Simple Task

$ /analyze-complexity "Write function to calculate factorial"
<complexity score="0.12" level="SIMPLE">
<factors>
  <word_count>0.05</word_count>
  <ambiguity>0.02</ambiguity>
  <dependencies>0.00</dependencies>
  <domain_specificity>0.05</domain_specificity>
</factors>
<strategy>direct_execution</strategy>
<reasoning>
  Short task, single operation, well-defined algorithm.
  No ambiguity, no dependencies, basic domain.
</reasoning>
<recommended_approach>
  1. Implement recursive or iterative factorial
  2. Add input validation
  3. Done in single pass
</recommended_approach>
<suggested_iterations>1</suggested_iterations>
</complexity>

Example 2: Medium Task

$ /analyze-complexity "Create a priority queue class with efficient insert and extract-min operations"
<complexity score="0.52" level="MEDIUM">
<factors>
  <word_count>0.12</word_count>
  <ambiguity>0.10</ambiguity>
  <dependencies>0.15</dependencies>
  <domain_specificity>0.15</domain_specificity>
</factors>
<strategy>multi_approach_synthesis</strategy>
<reasoning>
  Data structure implementation with performance requirements.
  Multiple valid approaches (heap, balanced tree, sorted list).
  Requires evaluation of tradeoffs.
</reasoning>
<recommended_approach>
  1. Consider heap vs balanced tree approaches
  2. Evaluate time complexity tradeoffs
  3. Implement optimal choice with tests
</recommended_approach>
<suggested_iterations>2-3</suggested_iterations>
</complexity>

Example 3: Complex Task

$ /analyze-complexity "Design a distributed cache system with consistency guarantees, fault tolerance, and horizontal scaling to 1M QPS"
<complexity score="0.85" level="COMPLEX">
<factors>
  <word_count>0.18</word_count>
  <ambiguity>0.15</ambiguity>
  <dependencies>0.22</dependencies>
  <domain_specificity>0.30</domain_specificity>
</factors>
<strategy>autonomous_evolution</strategy>
<reasoning>
  Distributed systems domain with multiple competing concerns.
  Must balance consistency vs availability (CAP theorem).
  Requires architectural decisions across multiple layers.
  Performance target creates hard constraint.
</reasoning>
<recommended_approach>
  1. Generate 3+ architectural approaches
  2. Analyze consistency models (eventual, strong, causal)
  3. Design fault tolerance mechanisms
  4. Test scaling assumptions against 1M QPS target
  5. Iterate on bottlenecks
</recommended_approach>
<suggested_iterations>4-5</suggested_iterations>
</complexity>

When to Use

Use when:

Don't use when:

Integration

Chain with other skills:

# Analyze then iterate
$ /analyze-complexity "task" && /meta-prompt-iterate "task"

# Batch analyze multiple tasks
$ for task in tasks.txt; do /analyze-complexity "$task"; done

# Route based on result
complexity=$(/analyze-complexity "task" | grep score | cut -d'"' -f2)
if [ $(echo "$complexity > 0.7" | bc) -eq 1 ]; then
  /meta-prompt-iterate "task" --max-iterations 5
fi

Implementation

Uses ComplexityAnalyzer from the meta-prompting engine:

from meta_prompting_engine.complexity import ComplexityAnalyzer

analyzer = ComplexityAnalyzer()
result = analyzer.analyze("your task here")

print(f"Score: {result.overall}")
print(f"Strategy: {result.strategy}")
print(f"Factors: {result.factors}")

Source

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.