Delegate independent tasks to specialized agents working concurrently with isolated context.
Codex Self Rewriting
codex-self-rewriting
Lisp machine self-modification patterns via MCP Tasks and Narya bridge types
SKILL.md
Full skill instructions
codex-self-rewriting - Lisp Machine Self-Modification via MCP Tasks
Overview
Enables Codex (OpenAI's CLI agent) to achieve Lisp-machine-like self-rewriting capabilities through MCP Tasks integration. Uses Narya observational bridge types for structure-aware modifications.
Core Concept: Cognitive Continuity via Babashka Transients
;; gay.bb transient state
(def ^:dynamic *cognitive-state*
{:seed 0x42D
:fingerprint (atom 0)
:tap-state :VERIFY
:color-history []})
;; Fork on modification
(defn fork-state! [intervention]
(let [new-seed (bit-xor (:seed *cognitive-state*)
(hash intervention))]
(assoc *cognitive-state* :seed new-seed)))
MCP Tasks Integration
Based on MCP Tasks Specification:
Task States for Self-Rewriting
| Status | TAP State | Meaning |
|---|---|---|
working | LIVE (+1) | Modification in progress |
input_required | VERIFY (0) | Needs human approval |
completed | BACKFILL (-1) | Modification archived |
failed | BACKFILL (-1) | Rollback applied |
cancelled | VERIFY (0) | Intervention stopped |
Capabilities Declaration
{
"capabilities": {
"tasks": {
"list": {},
"cancel": {},
"requests": {
"tools": {
"call": {}
}
}
}
}
}
Narya Observational Bridge Types
Following Topos Institute structure-aware version control:
- Diffs as logical relations - Computed inductively from skill type
- Conflicts as 2D cubical - Skill modifications form commuting squares
- Type changes as spans - Skill version correspondences
Bridge Colors
;; From narya_observational_bridge.el
(defconst tap/BACKFILL -1) ; Blue - Historical
(defconst tap/VERIFY 0) ; Green - Verification
(defconst tap/LIVE +1) ; Red - Active modification
Self-Rewriting Protocol
# 1. Install skill (creates MCP task)
npx ai-agent-skills install frontend-design --agent codex
# 2. Task enters 'working' state (LIVE)
# 3. Firecrawl fetches skill definition
# 4. If ambiguous → 'input_required' (VERIFY)
# 5. Human approves → task continues
# 6. On completion → 'completed' (BACKFILL)
Bisimulation Game for Skill Dispersal
Skills are dispersed across editors using bisimulation equivalence:
Claude ←→ Codex ←→ Cursor ←→ Copilot
↓ ↓ ↓ ↓
LIVE VERIFY BACKFILL LIVE
Each editor maintains equivalent skill state, verified by XOR fingerprint:
(defn skill-fingerprint [skills]
(reduce bit-xor 0 (map hash skills)))
Integration with gay.el
(require 'gay-unified)
(require 'narya-observational-bridge)
(defun codex/self-rewrite (skill-name)
"Self-rewrite to incorporate SKILL-NAME."
(let* ((task-id (narya/create-task skill-name))
(tap-state tap/LIVE)
(color (tap/to-rgb tap-state)))
(narya/spawn-hierarchy 0x42D)
(narya/watch-task task-id
(lambda (status)
(pcase status
("working" (setq tap-state tap/LIVE))
("input_required" (setq tap-state tap/VERIFY))
("completed" (setq tap-state tap/BACKFILL)))))))
Configuration
Add to ~/.codex/mcp.json:
{
"mcpServers": {
"narya": {
"command": "bb",
"args": ["/path/to/gay.bb", "1069"],
"env": {
"TAP_STATE": "LIVE",
"SPECTRAL_GAP": "0.25"
}
},
"firecrawl": {
"command": "npx",
"args": ["-y", "firecrawl-mcp"],
"env": {
"FIRECRAWL_API_KEY": "${FIRECRAWL_API_KEY}"
}
}
}
}
Skill Redundancy via GF(3) Polarity
MINUS (−) → Conservative backup
ERGODIC (_) → Active verification
PLUS (+) → Optimistic propagation
Each skill exists in 3 parallel states for resilient dispersal.
See Also
gay.bb- Triadic self-discovering peer networknarya_observational_bridge.el- 3×3×3 hierarchical agentsgay-crdt.el- Diamond-types CRDT integration- MCP Tasks Spec
More Other skills
brand-guidelines
Applies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.
internal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill whenever asked to write some sort of internal communications (status reports, leadership updates, 3P updates, company newsletters, FAQs, incident reports, project updates, etc.).
Fundamental design principles for writing maintainable, testable Python code.
responsive-design
Modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first strategies.
Generate Playwright tests from scenarios using interactive browser exploration and validation.
Automated website exploration and test case generation using Playwright.
Modern React state management with Redux Toolkit, Zustand, Jotai, and React Query for every state category.
gdpr-data-handling
GDPR-compliant data handling with consent management, data subject rights, and privacy controls.
Python error handling patterns including input validation, exception hierarchies, and partial failure handling. Use when implementing validation logic, designing exception strategies, handling batch processing failures, or building robust APIs.
refactor-plan
Detailed multi-file refactor planning with safety checks and rollback guidance.
