| name | atomic-blocks |
| description | Composable atomic blocks for categorical meta-prompting. Defines 16 reusable blocks across 4 layers (Assessment, Transformation, Refinement, Composition) that can be composed to build custom workflows. Enables progressive disclosure: simple commands work unchanged, power users can override individual blocks or compose freely. |
| version | 1.0.0 |
Atomic Blocks: Composable Primitives for Categorical Meta-Prompting
This skill defines the atomic building blocks that underlie all categorical meta-prompting commands. These blocks exist implicitly in commands like /meta, /rmp, and /route. Making them explicit enables:
- Mathematical coherence - Laws verifiable at block level
- Testability - Unit test individual blocks
- Performance - Caching + parallelization
- Power user capability - Custom compositions
Categorical Foundation
The framework decomposes into natural atomic morphisms:
F (Functor): τ: A → B (pure transformation)
M (Monad): η: A → M(A) (unit/return)
μ: M(M(A)) → M(A) (join/flatten)
W (Comonad): ε: W(A) → A (extract)
δ: W(A) → W(W(A)) (duplicate)
[0,1]: q: A → [0,1] (quality assessment)
Progressive Disclosure Layers
Layer 1: Simple Surface (90% of users)
Commands work unchanged - all atoms hidden:
/meta "task"
/rmp "task"
/route "task"
Layer 2: Override Layer (9% of users)
Override single blocks via @block: modifier:
/meta @block:assess_domain:SECURITY "review code"
/rmp @block:quality_threshold:0.9 "optimize"
/chain @block:merge_strategy:weighted [...] "task"
Layer 3: Composition Layer (1% of users)
Full atomic control via /compose:
/compose [
assess_difficulty →
select_strategy @bias:quality →
build_template →
apply_transform →
execute_prompt →
assess_quality >=>
evaluate_convergence
] "complex workflow"
Block Taxonomy (16 Blocks, 4 Layers)
Layer 1: Assessment Blocks
These blocks analyze input and classify tasks.
assess_difficulty
name: assess_difficulty
signature: Task → DifficultyScore
category: Assessment
purpose: Evaluate task complexity for tier selection
input:
task: string
output:
score: float
factors:
length: float
complexity: float
ambiguity: float
novelty: float
mapping:
score < 0.3: "easy" → L1-L2
0.3 ≤ score ≤ 0.7: "medium" → L3-L4
score > 0.7: "hard" →
[, ]
{ , , , }
assess_domain
name: assess_domain
signature: Task → Domain
category: Assessment
purpose: Classify task into domain category
input:
task: string
output:
domain: enum[ALGORITHM, SECURITY, API, DEBUG, TESTING, GENERAL]
confidence: float
signals: list[string]
mapping:
patterns:
ALGORITHM: [optimize, complexity, sort, search, tree, graph, O(n)]
SECURITY: [auth, encrypt, hash, OWASP, injection, XSS, CSRF]
API: [endpoint, REST, GraphQL, request, response, route]
[, , , , , ]
[, , , , , , ]
[, , ]
assess_quality
name: assess_quality
signature: Output → QualityVector
category: Assessment
purpose: Multi-dimensional quality evaluation
input:
output: string
context: string
output:
vector:
correctness: float
clarity: float
completeness: float
efficiency: float
aggregate: float
weakest: string
formula: |
aggregate = 0.40×correctness + 0.25×clarity +
0.20×completeness + 0.15×efficiency
laws:
- Normalized: all dimensions ∈ [0, 1]
- Weighted: aggregate
{ , , , }
select_tier
name: select_tier
signature: (DifficultyScore, Domain) → Tier
category: Assessment
purpose: Map assessment to L1-L7 tier
input:
difficulty: DifficultyScore
domain: Domain
output:
tier: enum[L1, L2, L3, L4, L5, L6, L7]
strategy: enum[DIRECT, MULTI_APPROACH, AUTONOMOUS_EVOLUTION]
budget_range: [min, max]
mapping:
L1: {difficulty: [0.0, 0.15], budget: [600, 1200], strategy: DIRECT}
L2: {difficulty: [0.15, 0.30], budget: [1500, 3000], strategy: DIRECT}
L3: {difficulty: [, ], [, ], }
{ [, ], [, ], }
{ [, ], [, ], }
{ [, ], [, ], }
{ [, ], [, ], }
{ , }
{ , , [, ]}
Layer 2: Transformation Blocks
These blocks transform tasks into prompts.
select_strategy
name: select_strategy
signature: Tier → Strategy
category: Transformation
purpose: Choose prompting strategy for tier
input:
tier: Tier
bias: optional[enum[speed, quality, balanced]]
output:
strategy: StrategyConfig
name: string
functor: enum[F_ZS, F_FS, F_CoT, F_ToT, F_Meta]
components: list[string]
estimated_quality: float
mapping:
L1-L2 (DIRECT):
functor: F_ZS (zero-shot)
components: [context, task]
quality: 0.65
L3-L4 (MULTI_APPROACH):
functor: F_CoT (chain-of-thought)
components: [context, reasoning, task, format]
[, , , , , ]
{ , }
[, , , , , ]
build_template
name: build_template
signature: (Context, Strategy) → Template
category: Transformation
purpose: Assemble prompt template from components
input:
context: ContextConfig
role: enum[expert, teacher, reviewer, debugger]
domain: Domain
strategy: StrategyConfig
format: optional[enum[prose, structured, code, checklist]]
output:
template: Template
system: string
instructions: string
task_slot: "{TASK}"
format: string
quality_criteria: string
template_library:
context:
expert: "You are an expert in {domain} with deep knowledge."
{ , }
{ , [, , , ]}
apply_transform
name: apply_transform
signature: (Template, Task) → Prompt
category: Transformation
purpose: Apply template to task (Functor action)
input:
template: Template
task: string
output:
prompt: Prompt
full_text: string
token_estimate: int
sections: list[string]
process:
1. Substitute {TASK} placeholder with actual task
2. Combine all template sections
3. Validate total length within budget
4.
{ , , }
[, , ]
execute_prompt
name: execute_prompt
signature: Prompt → RawOutput
category: Transformation
purpose: Execute prompt and capture output
input:
prompt: Prompt
output:
raw_output: RawOutput
content: string
tokens_used: int
latency_ms: int
metadata: object
process:
1. Send prompt to LLM
2. Capture response
3. Record metrics
4. Return raw output
laws:
- Non-deterministic: same prompt
{ }
Layer 3: Refinement Blocks
These blocks implement the Monad M for iterative refinement.
evaluate_convergence
name: evaluate_convergence
signature: (QualityVector, Threshold, IterationCount) → ConvergenceStatus
category: Refinement
purpose: Check if quality meets threshold (Monad return condition)
input:
quality: QualityVector
threshold: float
iteration: int
max_iterations: int
previous_quality: optional[float]
output:
status: enum[CONTINUE, CONVERGED, MAX_ITERATIONS, PLATEAU, HALT]
reason: string
should_refine: bool
rules:
CONVERGED: quality.aggregate >= threshold
MAX_ITERATIONS: iteration >= max_iterations
{ }
extract_improvement
name: extract_improvement
signature: (Output, QualityVector) → ImprovementDirection
category: Refinement
purpose: Identify improvement direction from gaps
input:
output: string
quality: QualityVector
output:
direction: ImprovementDirection
focus_dimension: string
gap: float
suggestions: list[string]
priority: enum[critical, high, medium, low]
process:
1. Identify weakest dimension in quality vector
2. Analyze output for specific gaps
3. Generate
{ , , , }
apply_refinement
name: apply_refinement
signature: (Output, ImprovementDirection) → RefinedOutput
category: Refinement
purpose: Apply improvement direction (Monad bind)
input:
output: string
direction: ImprovementDirection
output:
refined: RefinedOutput
content: string
changes_made: list[string]
expected_improvement: float
process:
1. Parse improvement direction
2. Generate refinement prompt focusing on weakest dimension
3. Execute refinement
4. Return improved output
{ , []}
[, , ]
aggregate_iterations
name: aggregate_iterations
signature: list[Output] → BestOutput
category: Refinement
purpose: Select best output from iteration history
input:
iterations: list[IterationResult]
each: {output: string, quality: QualityVector, iteration: int}
output:
best: BestOutput
output: string
quality: QualityVector
iteration: int
trajectory: list[float]
selection_criteria:
primary: highest aggregate quality
tiebreaker: most recent iteration
laws:
- Idempotent: aggregate([x]) = x
- Monotonic: aggregate includes
{ , { }, }
{ , { }, }
{ , { }, }
{ }
[, , ]
Layer 4: Composition Blocks
These blocks implement composition operators.
sequence
name: sequence
signature: (Block, Block) → Block
operator: →
category: Composition
purpose: Sequential composition (Kleisli)
semantics: |
sequence(A, B) = λx. B(A(x))
Output of A becomes input to B
quality_rule: |
quality(A → B) ≤ min(quality(A), quality(B))
laws:
- Associativity: (A → B) → C = A → (B → C)
- Identity: id → A = A = A → id
example:
composition: assess_difficulty → select_tier
execution:
1. assess_difficulty("task") → DifficultyScore(0.6)
2. select_tier(0.6)
parallel
name: parallel
signature: list[Block] → Block
operator: ||
category: Composition
purpose: Parallel composition (concurrent execution)
semantics: |
parallel([A, B, C]) = λx. merge(A(x), B(x), C(x))
All blocks execute concurrently on same input
quality_rule: |
quality(A || B || C) = mean(quality(A), quality(B), quality(C))
merge_strategies:
concatenate: Join all outputs with headers
vote: Majority agreement on structured output
weighted: Weighted average by quality scores
first: Return first completed (racing)
laws:
- Commutativity: A || B = B || A (order independent)
{ } { , }
kleisli
name: kleisli
signature: (Block, Block) → Block
operator: >=>
category: Composition
purpose: Quality-gated composition (monadic)
semantics: |
kleisli(A, B) = λx.
result_a = A(x)
if quality(result_a) < threshold:
result_a = refine_until_threshold(result_a)
return B(result_a)
quality_rule: |
quality(A >=> B) improves with each refinement gate
laws:
- Left Identity: return >=> f = f
- Right Identity: f >=> return = f
- Associativity: (f >=> g) >=> h = f >=> (g >=> h)
example:
composition: analyze >=> design >=> implement
execution:
1
tensor
name: tensor
signature: (Block, Block) → Block
operator: ⊗
category: Composition
purpose: Capability combination (quality-degrading)
semantics: |
tensor(A, B) = λx. combine_capabilities(A(x), B(x))
Combines skills/perspectives, quality bounded by weakest
quality_rule: |
quality(A ⊗ B) = min(quality(A), quality(B))
use_cases:
- Combining multiple skills: api-testing ⊗ validation
- Multi-expert analysis: security-expert ⊗ performance-expert
- Cross-domain review: frontend ⊗ backend
laws:
- Associativity: (A ⊗ B) ⊗ C = A ⊗ (B ⊗ C)
- Identity: A ⊗ id = A
{ , }
{ , }
{ , , , }
Composition Error Handling
Error Types
type CompositionError =
| { type: 'TYPE_MISMATCH', expected: BlockType, got: BlockType, position: int }
| { type: 'CIRCULAR_DEPENDENCY', cycle: Block[] }
| { type: 'MISSING_INPUT', block: Block, missing: string }
| { type: 'QUALITY_GATE_FAILED', block: Block, quality: float, threshold: float }
| { type: 'BUDGET_EXCEEDED', used: int, limit: int }
| { type: 'INVALID_OPERATOR', operator: string, context: string }
Validation Rules
validate_composition:
1. Type Compatibility:
- Output type of block A must match input type of block B in A → B
- All blocks in A || B must accept same input type
2. Cycle Detection:
- Build dependency graph
- Check for cycles via DFS
- Report cycle path if found
3. Budget Validation:
- Sum estimated tokens for all blocks
- Compare against @budget: limit
Error Messages
error_templates:
TYPE_MISMATCH: |
Type mismatch at position {position}:
Block '{block_a}' outputs: {output_type}
Block '{block_b}' expects: {input_type}
Suggestion: Insert a transformation block between them,
or use '{suggested_block}' which accepts {output_type}
CIRCULAR_DEPENDENCY: |
Circular dependency detected:
{cycle_path}
Suggestion: Remove the back-edge from '{last}' to '{first}'
QUALITY_GATE_FAILED: |
Quality gate failed at '{block}':
Achieved: {quality}
Required: {threshold}
Suggestion: Use @fallback:return-best to accept partial result,
or increase @max_iterations for more refinement attempts
Block Testing Strategy
Unit Test Template
def test_block_{block_name}():
"""Unit test for {block_name} block"""
input_data = {
}
expected_output = {
}
result = {block_name}(input_data)
assert result.keys() == expected_output.keys()
assert result['primary_field'] in expected_range
result2 = {block_name}(input_data)
assert result == result2
assert 0 <= result['score'] <= 1
Composition Test Template
def test_composition_{block_a}_{block_b}():
"""Test composition: {block_a} → {block_b}"""
input_data = "test task"
intermediate = {block_a}(input_data)
final = {block_b}(intermediate)
assert type(intermediate) == {block_b}.input_type
composed = sequence({block_a}, {block_b})
composed_result = composed(input_data)
assert composed_result == final
Categorical Law Tests
def test_monad_associativity():
"""(f >=> g) >=> h = f >=> (g >=> h)"""
f = assess_quality
g = extract_improvement
h = apply_refinement
input_data = "test output"
fg = kleisli(f, g)
fgh_left = kleisli(fg, h)
result_left = fgh_left(input_data)
gh = kleisli(g, h)
fgh_right = kleisli(f, gh)
result_right = fgh_right(input_data)
assert result_left.quality == result_right.quality
Integration with Existing Commands
/meta Internal Block Flow
/meta "task"
│
├─► assess_difficulty(task) → difficulty
├─► assess_domain(task) → domain
│ │
│ ▼
├─► select_tier(difficulty, domain) → tier
│ │
│ ▼
├─► select_strategy(tier) → strategy
│ │
│ ▼
├─► build_template(context, strategy) → template
│ │
│ ▼
├─► apply_transform(template, task) → prompt
│ │
│ ▼
└─► execute_prompt(prompt) → output
/rmp Internal Block Flow
/rmp @quality:0.85 "task"
│
├─► apply_transform(default_template, task) → prompt
│ │
│ ▼
├─► execute_prompt(prompt) → output
│ │
│ ▼
├─► assess_quality(output) → quality
│ │
│ ▼
├─► evaluate_convergence(quality, 0.85, iteration) → status
│ │
│ ├── CONVERGED → return output
│ │
│ └── CONTINUE ──┐
│ │
│ ┌──────────────┘
│ ▼
├─► extract_improvement(output, quality) → direction
│ │
│ ▼
└─► apply_refinement(output, direction) → refined_output
│
└─► (loop back to assess_quality)
/route Internal Block Flow
/route "task"
│
├─► assess_difficulty(task) → difficulty
│ │
│ ▼
├─► assess_domain(task) → domain
│ │
│ ▼
└─► dispatch(difficulty, domain) → selected_command
│
├── difficulty < 0.3 → /meta (DIRECT)
├── domain == DEBUG → /debug
├── domain == REVIEW → /review
├── 0.3 ≤ diff ≤ 0.7 → /meta @tier:L3-L4
└── difficulty > 0.7 → /rmp or /hekat
Block Override Syntax
Single Block Override
/meta @block:assess_domain:SECURITY "task"
/rmp @block:evaluate_convergence.threshold:0.9 "task"
/chain @block:parallel.merge:weighted [...] "task"
Multiple Block Overrides
/meta @block:assess_domain:API @block:select_strategy.bias:quality "task"
Block Replacement
/meta @block:assess_difficulty:custom_difficulty_v2 "task"
Version
Specification Version: 1.0.0
Compatibility: Extends meta-self v2.3
Foundation: Category Theory (F, M, W, α, E, [0,1]-enriched)
Blocks: 16 (4 Assessment + 4 Transformation + 4 Refinement + 4 Composition)
Created: 2025-12-01