nock-interpreter-engineer-assistant

Expert Nock interpreter builder for implementing virtual machines in C, Python, Rust, Haskell, or JavaScript. Use when building Nock interpreters, porting between languages, implementing evaluation loops, or understanding Nock runtime behavior.

16 stars

Best use case

nock-interpreter-engineer-assistant is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Expert Nock interpreter builder for implementing virtual machines in C, Python, Rust, Haskell, or JavaScript. Use when building Nock interpreters, porting between languages, implementing evaluation loops, or understanding Nock runtime behavior.

Teams using nock-interpreter-engineer-assistant should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/nock-interpreter-engineer-assistant/SKILL.md --create-dirs "https://raw.githubusercontent.com/diegosouzapw/awesome-omni-skill/main/skills/development/nock-interpreter-engineer-assistant/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/nock-interpreter-engineer-assistant/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How nock-interpreter-engineer-assistant Compares

Feature / Agentnock-interpreter-engineer-assistantStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Expert Nock interpreter builder for implementing virtual machines in C, Python, Rust, Haskell, or JavaScript. Use when building Nock interpreters, porting between languages, implementing evaluation loops, or understanding Nock runtime behavior.

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# Nock Interpreter Engineer

Expert guidance for implementing Nock virtual machines across multiple programming languages with proper evaluation loops, tree operations, and runtime optimization.

## Implementation Architecture

### Core Components

#### 1. Noun Representation
**Atoms**: Natural numbers with arbitrary precision
- **C**: GMP (GNU Multiple Precision) or custom BigInt
- **Python**: Built-in `int` (unlimited precision)
- **Rust**: `num-bigint` crate or `bigint` crate
- **Haskell**: `Integer` type (native)
- **JavaScript**: `BigInt` (ES2020+)

**Cells**: Ordered pairs (cons cells)
```rust
pub enum Noun {
    Atom(BigUint),
    Cell(Box<Noun>, Box<Noun>),
}
```

#### 2. Parser & Printer
Parse text format to internal representation:
```
[a b c]        -> Cell(Atom(a), Cell(Atom(b), Atom(c)))
123             -> Atom(123)
[a [b c]]      -> Cell(Atom(a), Cell(Atom(b), Atom(c)))
```

Print back to readable format.

#### 3. Evaluation Loop
Pattern matching on formula opcodes (0-12):
```python
def evaluate(subject, formula):
    while True:
        if not is_cell(formula):
            raise NockCrash("formula must be cell")

        op, rest = formula
        result = dispatch(op, subject, rest)
        if is_crash(result):
            return result
        subject, formula = result, rest
        if is_constant(formula):  # Rule 1
            return formula
```

## Nock Rules Implementation

### Rule 0: Slot (`[a b] /`)
Binary tree addressing for efficient axis traversal:
```
[subject slot] / = value_at_slot
```

**Implementation**: Convert slot number to axis path (left/right sequence), traverse subject tree.

### Rule 1: Constant (`[a] *`)
```
[subject] * = a
```

Stops evaluation, returns constant `a`.

### Rule 2: Evaluate (`[a b c] +`)
```
[subject [a b]] + = [subject a] c
```

Recurse: evaluate `a` against `subject`, then evaluate result as formula with `c`.

### Rule 3: Cell Test (`[a] ?`)
```
[subject a] ? = 0 if a is cell, 1 if a is atom
```

Type discrimination for atoms vs cells.

### Rule 4: Increment (`[a] +`)
```
[subject a] + = a + 1
```

Natural number addition.

### Rule 5: Equality (`[a b] =`)
```
[subject a b] = = a b
```

Structural equality: `0` if identical, `1` if different.

### Rule 6-9: Composition
- Rule 6: `[[a b] c] /` = `[[a b] / c]`
- Rule 7: `[a b c] =` = `a b c` (three-element cell)
- Rule 8: `[a b] +` = `a + b`
- Rule 9: `[a b] +` = `a + b`

Formulas 2-9 are composites of rules 0-5.

### Rule 10: Edit (`[a b c]`)
```
[subject [a b c]] = nock(subject, b)
```
Tree editing; replaces part of the subject at axis `a`.

### Rule 11: Hint (`[a b]`)
```
[subject [a b]] = nock(subject, b)
```

Optimization hint; evaluates `b` and may use `a` as a hint to the runtime.

### Rule 12: Scry (`[a b] ^`)
```
[subject [a b]] ^ = memory[a][b]
```

Referentially transparent read of memory slot `b` within noun `a`.

## Performance Patterns

### Tail Call Optimization (TCO)

Detect and optimize recursive formulas:
```python
# Before: creates stack frames
[subject [[a b] c]] + = ...

# After: if formula ends with recursive call, reuse stack
if ends_with_recursive_call(formula):
    return tco_evaluate(subject, formula)
```

### Memoization
Cache evaluation results for repeated sub-formulas:
```python
_memo = {}

def memo_evaluate(subject, formula):
    key = (subject, formula)
    if key in _memo:
        return _memo[key]
    result = evaluate(subject, formula)
    _memo[key] = result
    return result
```

### Lazy Evaluation
Defer computation until value needed:
```python
class Thunk:
    def __init__(self, subject, formula):
        self.subject = subject
        self.formula = formula
        self._cached = None

    def force(self):
        if self._cached is None:
            self._cached = evaluate(self.subject, self.formula)
        return self._cached
```

## Language-Specific Patterns

### C Implementation
```c
typedef struct {
    mpz_t atom;
    struct Noun *cell;
} Noun;

Noun* slot(Noun* subject, Noun* axis);
Noun* evaluate(Noun* subject, Noun* formula);
```

**Pros**: Maximum control, pointer efficiency
**Cons**: Manual memory management, complexity

### Python Implementation
```python
from typing import Union

Noun = Union[int, tuple]

def evaluate(subject: Noun, formula: Noun) -> Noun:
    if not isinstance(formula, tuple):
        raise NockCrash("formula must be cell")
    ...
```

**Pros**: Simplicity, fast prototyping
**Cons**: Performance overhead

### Rust Implementation
```rust
pub enum Noun {
    Atom(BigUint),
    Cell(Box<Noun>, Box<Noun>),
}

impl Noun {
    pub fn evaluate(&self, formula: &Noun) -> Result<Noun, NockCrash> {
        match formula {
            Noun::Cell(op, rest) => dispatch(op, self, rest),
            _ => Ok(formula.clone()),
        }
    }
}
```

**Pros**: Memory safety, zero-cost abstractions
**Cons**: Borrow checker complexity

### Haskell Implementation
```haskell
data Noun = Atom Integer | Cell Noun Noun

evaluate :: Noun -> Noun -> Noun
evaluate subject formula = case formula of
    Cell (Atom 0, rest) -> slot subject rest
    Cell (Atom 1, rest) -> rest
    Cell (Atom 2, Cell(a, Cell(b, c))) -> evaluate (evaluate subject a) c
    ...
```

**Pros**: Type safety, pattern matching
**Cons**: Learning curve

### JavaScript Implementation
```javascript
class Noun {
    constructor(value) {
        this.isCell = Array.isArray(value);
        this.value = value;
    }
}

function evaluate(subject, formula) {
    if (!formula.isCell) {
        throw new NockCrash("formula must be cell");
    }
    const [op, ...rest] = formula.value;
    return dispatch(op, subject, rest);
}
```

**Pros**: Web compatibility
**Cons**: Performance, type safety

## Testing & Validation

### Reference Test: Decrement
```python
def test_decrement():
    subject = 0
    formula = [8 [1 0] 8 [1 6 [5 [0 7]] 4 0 6] [0 6] 9 2 [0 2] [4 0 6] 0 7] 9 2 0 1]
    result = evaluate(subject, formula)
    assert result == 0, f"Expected 0, got {result}"
```

### Edge Cases
- **Empty subject**: `[~ [1 0]]` should work
- **Large atoms**: Test with 64-bit, 128-bit, larger
- **Deep trees**: Stack overflow prevention
- **Memory pressure**: Graceful handling, not crash

### Benchmarking
Compare performance against reference implementations:
```
Implementation | Decrement (ms) | Formula 2 (ms) | Memory (MB)
-------------|-----------------|---------------|--------------
Python       | 150             | 50             | 25
Rust         | 5               | 0.5            | 3
C (GMP)     | 1               | 0.1            | 1
```

## Common Pitfalls

### 1. Incorrect Slot Calculation
```
Slot 1 = axis [0 1]  // Correct
Slot 2 = axis [1 0]  // Correct, NOT [0 1 1]
```

### 2. Missing TCO
Deep recursion crashes stack without trampoline or TCO.

### 3. Inefficient Noun Copying
Deep clones of nouns create O(n²) behavior. Use reference counting or structural sharing.

### 4. Incorrect Subject Handling
Forgetting to update `subject` after evaluation changes context.

## Resources

- [Nock 4K Specification](https://github.com/urbit/urbit/blob/main/pkg/arvo/sys/zuse.hoon)
- [nock-interpreter-patterns](../nock-interpreter-patterns/SKILL.md)
- [nock-multi-language-implementations](../nock-multi-language-implementations/SKILL.md)
- [nock-specification-reference](../nock-specification-reference/SKILL.md)

Related Skills

music-assistant

16
from diegosouzapw/awesome-omni-skill

Control Home Assistant Music Assistant - browse library, search, play, manage preferences and moods.

mocking-assistant

16
from diegosouzapw/awesome-omni-skill

Creates stable mocks for APIs, services, and UI components using MSW (Mock Service Worker), fixture conventions, and example patterns. Use for "API mocking", "MSW", "test mocks", or "service mocking".

midjourney-prompt-engineering

16
from diegosouzapw/awesome-omni-skill

Use when generating images with Midjourney, constructing MJ prompts, iterating on MJ output quality, choosing between --sref/--oref/style codes, scoring image results, or building reusable prompt patterns. Also use when exploring MJ style codes, animating images, or debugging why a prompt isn't producing the intended result.

lead-research-assistant

16
from diegosouzapw/awesome-omni-skill

Researches and identifies potential customers, leads, and business opportunities for your product or service. Analyzes your offering, finds relevant companies and decision makers, provides contact information, and suggests outreach strategies. Use when looking for leads, researching target customers, identifying decision makers, or planning sales outreach.

kumo-assistant

16
from diegosouzapw/awesome-omni-skill

Kumo development assistant for MySQL database management tool. Use when working on Kumo features, understanding architecture, writing tests, or navigating the codebase. Helps with React components, API endpoints, database features, and Electron app development.

full-stack-orchestration-performance-engineer

16
from diegosouzapw/awesome-omni-skill

Expert performance engineer specializing in modern observability, application optimization, and scalable system performance. Masters OpenTelemetry, distributed tracing, load testing, multi-tier caching, Core Web Vitals, and performance monitoring. Handles end-to-end optimization, real user monitoring, and scalability patterns. Use PROACTIVELY for performance optimization, observability, or scalability challenges. Use when: the task directly matches performance engineer responsibilities within plugin full-stack-orchestration. Do not use when: a more specific framework or task-focused skill is clearly a better match.

frontend-engineer

16
from diegosouzapw/awesome-omni-skill

Frontend specialist for UI/UX implementation, CSS styling, React components, and user experience. Use for frontend development and visual implementation.

engineering

16
from diegosouzapw/awesome-omni-skill

Guides technical decisions, architecture, and implementation. Use for tech choices, system design, API design, refactoring, or "how should I build this" questions.

engineering-standards

16
from diegosouzapw/awesome-omni-skill

Comprehensive engineering standards for monorepo projects with Claude Code, covering hooks, testing, documentation, quality gates, and best practices. Use when setting up new projects, validating compliance, or extracting patterns from existing codebases.

data-engineering-backend-architect

16
from diegosouzapw/awesome-omni-skill

Expert backend architect specializing in scalable API design, microservices architecture, and distributed systems. Masters REST/GraphQL/gRPC APIs, event-driven architectures, service mesh patterns, and modern backend frameworks. Handles service boundary definition, inter-service communication, resilience patterns, and observability. Use PROACTIVELY when creating new backend services or APIs. Use when: the task directly matches backend architect responsibilities within plugin data-engineering. Do not use when: a more specific framework or task-focused skill is clearly a better match.

context-engineering

16
from diegosouzapw/awesome-omni-skill

Use when starting a new session, when agent output quality degrades, when switching between tasks, or when you need to configure rules files and context for a project.

code-review-assistant

16
from diegosouzapw/awesome-omni-skill

Comprehensive code review assistant that analyzes code for security vulnerabilities, performance issues, and code quality. Use when reviewing pull requests, conducting code audits, or analyzing code changes. Supports Python, JavaScript/TypeScript, and general code patterns. Includes automated analysis scripts and structured checklists.