theseus-protocol
Structured refactoring protocol that enforces scope and prevents behavioral drift.
Install
mkdir -p .claude/skills/theseus-protocol && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/11972" && unzip -o skill.zip -d .claude/skills/theseus-protocol && rm skill.zipInstalls to .claude/skills/theseus-protocol
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Thoughtbox-first Theseus workflow for behavior-preserving refactors. Use this when structure changes but behavior must stay fixed and scope drift needs hard boundaries.Key capabilities
- →Initialize a refactoring protocol with a declared scope
- →Request a visa to expand the refactoring scope
- →Record checkpoints with diff hashes and atomic narratives
- →Record the outcome of validation for the refactor
- →Retrieve the current status of the protocol
- →Complete the protocol and capture structural yield
How it works
The skill manages behavior-preserving refactors through a Thoughtbox-owned protocol, controlling scope, visa state, audit state, and terminal status via explicit operations.
Inputs & outputs
When to use theseus-protocol
- →Refactoring code structure
- →Enforcing refactoring boundaries
- →Audit state transitions
About this skill
Theseus Protocol
Theseus is a Thoughtbox-owned refactoring protocol.
The server-side Theseus implementation behind tb.theseus(...) owns scope,
visa state, audit state, and terminal status.
Claude Code hooks only ask Thoughtbox whether a write should be blocked.
Do not use .theseus/ files or scripts/theseus.sh as authoritative state.
Do not rely on implicit git reset --hard recovery in the active workflow.
Do not use legacy direct handles like thoughtbox_gateway or thoughtbox_theseus
as the interaction surface when Code Mode is available.
API Surface
The current public Thoughtbox MCP surface is Code Mode:
- Discovery:
thoughtbox_search - Execution:
thoughtbox_execute - Theseus operations:
tb.theseus({ ... })
Each thoughtbox_execute call should contain at most one state-mutating
Theseus operation. Read-only confirmation calls such as
tb.theseus({ operation: "status" }) are safe to use for state checks.
Runtime Contract
- Protocol entry is explicit-only in v1.
- If you need schema or example confirmation, call
thoughtbox_searchbefore executing. - Use
thoughtbox_executeand calltb.theseus({ operation: ... })for every protocol transition. - Hooks consult Thoughtbox before mutating file operations.
- Hooks do not spawn agents or mutate protocol state.
- Helper agents may audit or gather evidence, but only the coordinator calls
tb.theseus.
Commands
init
Required inputs:
- Declared scope
- Optional refactor description
Call:
async () => {
return await tb.theseus({
operation: "init",
scope: ["src/module-a.ts", "src/module-b/"],
description: "<refactor goal>",
});
}
After init, test files are write-locked and out-of-scope writes require a visa.
visa
Required inputs:
- Out-of-scope file path
- Justification
Call:
async () => {
return await tb.theseus({
operation: "visa",
filePath: "src/dependency.ts",
justification: "<why the scope must expand>",
antiPatternAcknowledged: true,
});
}
This is the only supported way to expand scope in the active workflow.
checkpoint
Required inputs:
- Diff hash or equivalent checkpoint identity
- Atomic narrative
- Cassandra verdict
Call:
async () => {
return await tb.theseus({
operation: "checkpoint",
diffHash: "<diff hash>",
commitMessage: "<atomic narrative>",
approved: true,
feedback: "<optional audit rationale>",
});
}
Before checkpoint, you may optionally run a reviewer or judge agent to produce the Cassandra-style audit. That agent returns only a verdict and rationale. The coordinator records the outcome with tb.theseus.
outcome
Required inputs:
- Whether validation passed
- Optional details
Call:
async () => {
return await tb.theseus({
operation: "outcome",
testsPassed: false,
details: "<what failed>",
});
}
The protocol records whether the refactor remains in a valid state. Recovery requirements are described by protocol state, not hidden local git resets.
status
Call:
async () => {
return await tb.theseus({
operation: "status",
});
}
Use the returned state as the only source of truth for scope, visas, and audit history.
complete
Call:
async () => {
return await tb.theseus({
operation: "complete",
terminalState: "complete",
summary: "<what structural yield was achieved>",
});
}
Completion should yield protocol closure plus reusable knowledge about successes, audit failures, or scope exhaustion.
Invariants
- Scope is explicit and server-owned.
- Test files are never modified during the refactor.
- Out-of-scope writes require a visa.
- Checkpoints are explicit and auditable.
- Audit evidence may come from helper agents, but state transitions belong to the coordinator.
- Knowledge capture includes failures, not just successful refactors.
Subagent Use
Use subagents only at explicit checkpoint phases.
Good uses:
- Cassandra-style audit before
checkpoint - Independent diff review for premature abstraction
- Focused evidence gathering around a requested visa
Bad uses:
- Hook-triggered subagents
- Letting a helper agent call
tb.theseus - Treating git rollback behavior as the protocol itself
References
- Public MCP surface:
thoughtbox_search,thoughtbox_execute - Theseus SDK call:
tb.theseus({ operation: ... }) - Durable context and thought trace: Thoughtbox session, thought, and knowledge operations through Code Mode
- Protocol implementation:
src/protocol/theseus-tool.ts - Enforcement design reference:
references/theseus-gate.md
When not to use it
- →When behavior does not need to stay fixed during structural changes
- →When scope drift does not need hard boundaries
- →When not using Thoughtbox for refactoring management
Limitations
- →Protocol entry is explicit-only in v1
- →Test files are never modified during the refactor
- →Out-of-scope writes require a visa
How it compares
This skill enforces a structured, auditable refactoring process with explicit scope management and checkpoints, unlike ad-hoc refactoring.
Compared to similar skills
theseus-protocol side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| theseus-protocol (this skill) | 0 | 2mo | Review | Advanced |
| software-architecture | 333 | 6mo | No flags | Intermediate |
| solid-principles | 57 | 9mo | No flags | Intermediate |
| python-design-patterns | 19 | 2mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
You might also like
software-architecture
davila7
Guide for quality focused software architecture. This skill should be used when users want to write code, design architecture, analyze code, in any case that relates to software development.
solid-principles
SmidigStorm
Enforce SOLID principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) in object-oriented design. Use when writing or reviewing classes and modules.
python-design-patterns
wshobson
Python design patterns including KISS, Separation of Concerns, Single Responsibility, and composition over inheritance. Use when making architecture decisions, refactoring code structure, or evaluating when abstractions are appropriate.
modular-code
parcadei
Modular Code Organization
laravel-architecture
HoangNguyen0403
Core architectural standards for scalable Laravel applications.
design-patterns
TencentBlueKing
BK-CI 项目设计模式实践指南,涵盖工厂模式、策略模式、观察者模式、装饰器模式、模板方法等在项目中的实际应用。当用户学习设计模式、重构代码、设计可扩展架构或理解项目设计时使用。