Programming as Theory Building for Openclaw

A highly disciplined AI coding agent skill based on Peter Naur's philosophy to ensure code edits preserve and rebuild the underlying program theory rather than just producing text.

anamkwon
v1.0.0
Jun 11, 2026
0
578
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install programming-as-theory-building

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install programming-as-theory-building using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Programming as Theory Building?

The Programming as Theory Building skill provides Karpathy-style operating rules for AI coding agents based on Peter Naur's seminal paper. It shifts the agent's focus from mere text production and pattern matching to recovering, extending, and preserving the underlying "program theory"—the mental model of how real-world workflows map into program behavior. By enforcing this approach, the skill prevents context-free patches, speculative abstractions, and code that looks correct structurally but violates domain invariants.

While this skill introduces a small upfront cost that slows down trivial edits, it pays massive dividends for non-trivial development. It ensures that every modification fits naturally into the existing software architecture, reducing technical debt and keeping the codebase genuinely alive and maintainable over time.

Programming as Theory Building Use Cases

  • Refactoring legacy systems: Safely modifying complex code paths by forcing the agent to reconstruct the original program theory before making structural changes.
  • Feature implementation: Adding new capabilities right next to the closest existing domain concepts rather than creating duplicate, siloed code paths.
  • Context-aware bug fixing: Eliminating band-aid patches and special cases by requiring the agent to reproduce and repair violated invariants.
  • Code review automation: Evaluating pull requests against domain logic, identifying speculative flexibility, and catching decoupled documentation.

How Programming as Theory Building Works

  1. Pre-Edit Inspection: Before touching code, the agent answers five critical questions regarding world mapping, current theory, facility similarity, boundaries, and proof.
  2. Theory Reconstruction: The agent reviews callers, callees, tests, and runtime behavior to build a compact, precise understanding of the system logic.
  3. Similarity Assessment: The agent evaluates where the new demand naturally fits based on existing naming conventions, data shapes, and patterns.
  4. Surgical Modification: The agent applies the minimal coherent change necessary, strictly matching local style and touching only required files.
  5. Invariant Verification: The agent runs targeted checks to prove the design story holds, ensuring bugs are thoroughly fixed and refactors preserve behavior.
  6. Structured Reporting: The agent outputs a concise summary detailing the verified theory, changes made, checks executed, and residual risks.

Programming as Theory Building Setup

To integrate this configuration into your development environment, save the specification as a file within your Openclaw Skills repository.

Create a file named programming-as-theory-building.md in your skills directory:

mkdir -p .claw/skills
touch .claw/skills/programming-as-theory-building.md

Populate the file with the raw ruleset to make it automatically discoverable by your AI agent during code generation, modification, and review tasks.

Programming as Theory Building Data Schema & Taxonomy

The skill establishes a strict metadata taxonomy and operational schema to track program health and structure outputs.

Metadata Configuration

Property Value
name programming-as-theory-building
license MIT
type AI Agent Protocol

Response Schema

For non-trivial edits, the agent must output a structured plain-text block matching this format:

  • Theory: Explicit mapping from the real-world rule to the specific program location.
  • Changed: High-level declaration of exactly what lines, files, or structures were modified.
  • Verified: A list of checks, tests, or runtime commands executed to confirm the theory holds.
  • Risk: Any meaningful residual risks or test gaps remaining after execution.

Programming as Theory Building Advanced Features

  • Program Life Signals: Active monitoring thresholds that flag code as high-risk or "dead" when modifications require duplicate concepts or unexplainable design stories.
  • Speculative Flexibility Guardrails: Explicit blocks preventing the agent from introducing unused hooks, single-caller abstractions, or over-broad error handling.
  • Domain Invariant Enforcement: Prioritizes real-world system rules over narrow unit tests, preventing agents from writing code that passes syntax checks but breaks business logic.
  • Surgical Context Locks: Restricts the agent from running automated modernizations or reformatting adjacent code as a side effect of editing target areas.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*