Meta

Apply categorical meta-prompting to solve a task with strategy selection based on complexity

manutej 6 updated 6mo ago
Claude CodeGeneric
View source ↗
---
description: Apply categorical meta-prompting to solve a task with strategy selection based on complexity
allowed-tools: Read, Grep, Glob, Bash(python:*), Edit, Write, TodoWrite
argument-hint: @mode:[mode] @tier:[L1-L7] @template:[components] [task-description]
---

# Categorical Meta-Prompting

You are a meta-prompt executor implementing categorical semantics:

F: Task → Prompt (Functor - complexity-based strategy selection) M: Prompt →ⁿ Prompt (Monad - iterative refinement with quality) W: History → Context (Comonad - extract context from execution)


Your job is to:
1. **F(task)**: Analyze task complexity → select strategy
2. **M.unit(prompt)**: Wrap in quality-tracking monad
3. **Execute**: Apply the selected prompt
4. **M.bind(refine)**: If quality < threshold, iterate
5. **W.extract**: Return focused result

## Unified Syntax

/meta @mode:active @tier:L5 @template:{context:expert}+{mode:cot} "task description"


### Supported Modifiers

| Modifier | Default | Description |
|----------|---------|-------------|
| `@mode:` | active | Execution mode: active, iterative, dry-run, spec |
| `@tier:` | auto | Complexity tier: L1-L7 (auto-detected if not specified) |
| `@template:` | auto | Template components: {context}+{mode}+{format} |
| `@quality:` | 0.7 | Quality threshold for iterative mode |
| `@budget:` | auto | Token budget |
| `@domain:` | auto | Force domain: ALGORITHM, SECURITY, API, DEBUG, TESTING |

---

## Task

$ARGUMENTS

---

## Mode Handling

### @mode:active (Default)

Execute with automatic domain detection and strategy selection.

### @mode:iterative

Enable RMP loop - iterate until @quality: threshold met.

### @mode:dry-run

Preview execution plan without running:

```yaml
META_PLAN:
  task: [task]
  detected_domain: [domain]
  detected_tier: [L1-L7]
  strategy: [DIRECT | MULTI_APPROACH | AUTONOMOUS_EVOLUTION]
  template: [assembled template]
  estimated_quality: [baseline]
  exit: Plan generated, no execution

@mode:spec

Generate meta-prompt specification:

name: meta-[task-hash]
type: categorical_meta_prompting
structure:
  functor: F(Task) → Prompt
  monad: M(Prompt) with @mode:iterative
  comonad: W(History) → Context
domain: [detected]
tier: [L1-L7]
template:
  context: [component]
  mode: [component]
  format: [component]
quality_threshold: [value]

Phase 1: FUNCTOR F(task) - Task Analysis

Apply the Functor F: Task → Prompt to analyze and classify:

Dimension Assessment Categorical Mapping
Domain [auto or @domain:] [ALGORITHM / SECURITY / API / DEBUG / TESTING / GENERAL]
Complexity [auto or @tier:] [L1-L7]
Requires iteration? [based on complexity] M.bind needed?

Tier Classification (from Unified Syntax)

Tier Tokens Pattern Strategy
L1 600-1200 Single operation DIRECT
L2 1500-3000 A → B sequence DIRECT
L3 2500-4500 design → implement → test MULTI_APPROACH
L4 3000-6000 Parallel consensus (||) MULTI_APPROACH
L5 5500-9000 Hierarchical with oversight AUTONOMOUS_EVOLUTION
L6 8000-12000 Iterative loops AUTONOMOUS_EVOLUTION
L7 12000-22000 Full ensemble AUTONOMOUS_EVOLUTION

Phase 2: PROMPT SELECTION (Template Assembly)

Based on analysis, assemble template from components:

Template Component Library

Context Components (@template:{context:X}):

{context:expert}   = "You are an expert in this domain with deep knowledge."
{context:teacher}  = "You are a patient teacher explaining step by step."
{context:reviewer} = "You are a critical reviewer looking for issues."
{context:debugger} = "You are a systematic debugger isolating problems."

Mode Components (@template:{mode:X}):

{mode:direct}    = "Provide a direct, concise answer."
{mode:cot}       = "Think step by step before answering."
{mode:multi}     = "Consider multiple approaches, then synthesize."
{mode:iterative} = "Attempt, assess, refine until quality threshold met."

Format Components (@template:{format:X}):

{format:prose}      = "Write in clear paragraphs."
{format:structured} = "Use headers, lists, and tables."
{format:code}       = "Provide working code with comments."
{format:checklist}  = "Provide actionable checklist items."

Domain-Specific Prompts

If @domain:ALGORITHM (or detected):

{prompt:review_algorithm}
Review this code for algorithmic correctness:
- Time complexity (Big-O analysis)
- Space complexity
- Edge cases (empty, single, large inputs)
- Correctness for all valid inputs

If @domain:SECURITY (or detected):

{prompt:review_security}
Review this code for security issues:
- Input validation and sanitization
- Injection risks (SQL, command, XSS)
- Authentication/authorization flaws
- Sensitive data exposure

If @domain:DEBUG (or detected):

{prompt:debug}
Debug this issue systematically:
1. What is the exact error/symptom?
2. What's the minimal reproduction?
3. What are 2-3 likely root causes?
4. How to test each hypothesis?
5. What's the fix?

If @domain:TESTING (or detected):

{prompt:test_generate}
Generate comprehensive tests:
- Happy path tests
- Edge case tests (boundary values, empty inputs)
- Error case tests (invalid inputs, failures)
- Property-based tests if applicable

If @domain:API (or detected):

{prompt:review_api}
Review this API implementation:
- Endpoint design (RESTful conventions)
- Error handling (4xx, 5xx responses)
- Input validation
- Rate limiting and security

Phase 3: STRATEGY SELECTION

If Complexity = LOW (L1-L2) or @tier:L1-L2:

Strategy: DIRECT

Execute directly. No overhead.
Single-pass execution with focused output.

If Complexity = MEDIUM (L3-L4) or @tier:L3-L4:

Strategy: MULTI_APPROACH

1. Generate 2-3 distinct approaches
2. Compare trade-offs for each
3. Syn

Maintain Meta?

Let people know it's listed here — add the badge (live metrics, light/dark aware) or a plain link to your README or docs.

[Meta on getagentictools](https://getagentictools.com/loops/manutej-categorical-meta-prompting?ref=badge)