home / skills / cleanexpo / nodejs-starter-v1 / council-of-logic

council-of-logic skill

/.skills/custom/council-of-logic

This skill enforces mathematical first principles to optimize algorithms, architecture, and UI animations, improving efficiency, scalability, and payload size.

npx playbooks add skill cleanexpo/nodejs-starter-v1 --skill council-of-logic

Review the files below or copy the command above to add this skill to your agents.

Files (1)
SKILL.md
5.7 KB
---
name: council-of-logic
description: Mathematical first principles validation for code quality. Triggers on "optimise", "algorithm", "performance", "complexity", "O(n)", or when reviewing code for efficiency. Enforces Turing (algorithmic), Von Neumann (architecture), Bezier (animation), and Shannon (compression) principles.
license: MIT
metadata:
  author: NodeJS-Starter-V1
  version: '2.0.1'
  locale: en-AU
---

# Council of Logic - Mathematical First Principles

Four legendary minds govern all technical decisions. Their principles are non-negotiable.

## When to Apply

Activate this skill when:

- Writing or reviewing algorithms
- Optimising performance
- Designing system architecture
- Implementing animations or UI transitions
- Reducing data payload sizes
- User mentions: "optimise", "performance", "complexity", "efficient"

## The Council

### Alan Turing - Algorithmic Efficiency & Logic

**Focus**: Reduce code complexity. Demand optimal time complexity.

**Rules**:

- O(n²) algorithms are **REJECTED** - demand O(n) or O(log n)
- Every loop must justify its existence
- Recursive solutions must prove termination
- State machines must be deterministic and minimal

**Pre-Code Check**:

```
Turing Check: What is the time complexity?
- If O(n²) or worse → REFACTOR
- If O(n log n) → ACCEPTABLE
- If O(n) or O(log n) → APPROVED
```

**Red Flags**: Nested loops, `.filter().map().filter()` chains

**Resolution**: Single-pass algorithm

---

### John von Neumann - System Architecture & Game Theory

**Focus**: Optimise agent workflows. Treat interactions as strategic games.

**Rules**:

- Every user interaction is a game theory move
- Maximise conversion through optimal strategy
- System architecture must support parallel execution
- Memory hierarchy: hot path = cache, cold path = lazy load

**Pre-Architecture Check**:

```
Von Neumann Check: Is this the Nash Equilibrium?
- User benefit maximised? ✓
- System cost minimised? ✓
- Competing concerns balanced? ✓
```

**Red Flags**: Blocking operations, race conditions

**Resolution**: Async/parallel design

---

### Pierre Bezier - Frontend Physics & Animation

**Focus**: Interpolation curves for luxury UI. No linear transitions.

**Rules**:

- **BANNED**: `transition: all 0.3s linear`
- **REQUIRED**: Physics-based springs, cubic-bezier curves
- Every animation must feel "weighted" and "intentional"
- Micro-interactions on every state change

**Approved Easings**:

```css
/* Spring - bouncy, playful */
--ease-spring: cubic-bezier(0.68, -0.55, 0.265, 1.55);

/* Smooth - elegant, refined */
--ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);

/* Bounce - energetic, celebration */
--ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

/* Out-Expo - snappy, decisive */
--ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
```

**Pre-Animation Check**:

```
Bezier Check: Does this feel "expensive"?
- Linear timing? → REJECT
- Abrupt start/stop? → REJECT
- Physics-based curve? → APPROVED
```

**Red Flags**: Linear timing, jarring transitions

**Resolution**: Spring/bezier curves

---

### Claude Shannon - Information Theory (Token Economy)

**Focus**: Maximum signal, minimum noise. Compress everything.

**Rules**:

- Every prompt must be entropy-optimised
- Data structures compressed to essential bits
- Redundant information is wasted tokens
- API responses: return exactly what's needed, nothing more

**Pre-Communication Check**:

```
Shannon Check: What is the signal-to-noise ratio?
- Redundant words? → COMPRESS
- Unnecessary fields? → REMOVE
- Implicit > Explicit when context allows
```

**Red Flags**: Verbose prompts, bloated payloads

**Resolution**: Compress, dedupe, minimise

---

## Workflow Protocol

### STEP 1: THE PROOF

Before writing ANY code, state the mathematical/logical model:

```markdown
## Mathematical Model

**Problem**: [State the problem in formal terms]

**Turing**: Time complexity target = O(?)
**Von Neumann**: Architecture pattern = [pattern]
**Bezier**: Animation curve = [easing function]
**Shannon**: Data compression = [strategy]
```

### STEP 2: THE SOLVE

Execute with council approval:

```markdown
## Implementation

**Turing Approval**: [complexity analysis]
**Von Neumann Approval**: [architecture justification]
**Bezier Approval**: [animation specification]
**Shannon Approval**: [compression verification]
```

### STEP 3: THE VERIFY

Post-implementation council review:

```markdown
## Council Review

- [ ] Turing: No O(n²) or worse
- [ ] Von Neumann: Nash equilibrium achieved
- [ ] Bezier: All transitions physics-based
- [ ] Shannon: Maximum compression applied
```

## Quick Reference: Council Objections

| Council Member | Red Flag                                 | Resolution                 |
| -------------- | ---------------------------------------- | -------------------------- |
| Turing         | Nested loops, `.filter().map().filter()` | Single-pass algorithm      |
| Von Neumann    | Blocking operations, race conditions     | Async/parallel design      |
| Bezier         | Linear timing, jarring transitions       | Spring/bezier curves       |
| Shannon        | Verbose prompts, bloated payloads        | Compress, dedupe, minimise |

## Code Examples

### Turing Violation (BAD)

```typescript
// O(n²) - REJECTED
const result = items.filter((item) => otherItems.some((other) => other.id === item.id));
```

### Turing Approved (GOOD)

```typescript
// O(n) - APPROVED
const otherSet = new Set(otherItems.map((o) => o.id));
const result = items.filter((item) => otherSet.has(item.id));
```

### Bezier Violation (BAD)

```css
/* Linear - REJECTED */
transition: all 0.3s linear;
```

### Bezier Approved (GOOD)

```css
/* Physics-based - APPROVED */
transition: transform 0.5s cubic-bezier(0.19, 1, 0.22, 1);
```

---

**Remember**: These are not guidelines. They are **mathematical laws**.

Overview

This skill enforces mathematical first principles when you design, review, or optimise code and UI. It activates on mentions of optimisation, algorithm, performance, complexity, O(n), or during efficiency-focused code reviews. The council applies four canonical principles—Turing for algorithms, Von Neumann for architecture, Bezier for animations, and Shannon for information—to produce provably efficient, predictable, and compact implementations.

How this skill works

On trigger, the skill inspects code and design proposals for algorithmic complexity, concurrency and memory patterns, animation timing curves, and payload verbosity. It requires a short formal model (problem statement and targets) before implementation, then evaluates the proposed solution against each council rule. The output includes concrete refactors, complexity metrics, architecture recommendations, easing functions for UI, and compression suggestions.

When to use it

  • When writing or reviewing algorithms with potential nested loops or heavy data processing
  • When improving application performance or reducing latency and resource use
  • When designing system workflows that must scale or run in parallel
  • When implementing UI animations or micro-interactions that should feel natural
  • When minimising payload sizes or optimising token/field usage in APIs

Best practices

  • State the mathematical model before coding: time complexity target, architecture pattern, easing curve, compression strategy
  • Reject O(n²) or worse: aim for O(n), O(n log n), or O(log n) with justification
  • Design async/parallel hot paths; keep blocking work on cold paths or background workers
  • Use physics-based easing (springs or cubic-bezier) for transitions; avoid linear timing
  • Compress payloads and prompts by removing redundant fields and preferring implicit context when safe

Example use cases

  • Refactor a nested-loop data join to a single-pass or hash-set approach to reach O(n)
  • Rearchitect a synchronous request pipeline to async tasks with caching for hot-path performance
  • Replace linear CSS transitions with spring or cubic-bezier curves for polished micro-interactions
  • Trim API responses to essential fields and apply lightweight serialization to reduce tokens
  • Review a proposed algorithm and produce the formal complexity target and verification checklist

FAQ

What if a problem inherently requires O(n²) work?

Document the lower bound and show why O(n²) is unavoidable; then seek algorithmic or architecture changes (indexing, precomputation, sampling, parallelisation) to mitigate practical cost.

How strict is the animation rule for linear timing?

Linear timing is rejected for interactive transitions; static or performance-critical non-animated operations can skip physics-based curves, but UI state changes should use spring/bezier easing for perceived quality.