Lean Claude Code Harness
Distill the durable parts of Claude Code into a smaller, auditable harness. The goal is not feature parity. The goal is a runtime another engineer can understand, extend, and verify without reverse-engineering hidden behavior.
When to Use
Use this skill when a coding-agent runtime shows any of these symptoms:
- - config values are hard to trace
- tool permissions are implicit or inconsistent
- the tool surface keeps growing without clear ownership
- session history disappears after a run
- the main loop is hard to sketch from memory
- product-only logic is mixed into the harness core
Keep These Primitives
- - layered configuration
- permission-aware tool execution
- a small explicit tool registry
- markdown skill discovery
- transcript persistence
- a visible query loop
Remove These By Default
- - telemetry
- remote-managed settings
- hidden kill-switches
- private feature flags
- branding-specific branches
- heavyweight UI layers
Only add them back when the user explicitly asks for them and can explain the operational need.
Quick Audit
If you need a fast harness review, answer these six questions first:
- 1. Can you explain config precedence without reading three files?
- Are tool permissions checked before execution?
- Can you list the built-in tools in one screen?
- Are skills discovered from visible files instead of hidden registration?
- Does every run persist a transcript?
- Can you trace the query loop from prompt to final response?
If two or more answers are "no", the harness is already too opaque.
Apply This Order
1. Freeze the Runtime Boundary
Keep the entrypoint thin. It should only:
- - parse commands
- load merged config
- wire services
- print results
Do not hide business logic in the CLI layer.
2. Make Config Precedence Explicit
Use a predictable merge order:
- 1. defaults
- user config
- project config
- local config
- environment overrides
If a runtime value cannot be traced back to one of these sources, the harness is already drifting into opacity.
3. Gate Tools Before Execution
Define permission policy before the query loop runs tools.
Minimum pattern:
- -
default and plan expose read-only tools - write or shell tools require a stronger mode
- INLINECODE2 should be explicit and rare
Permission checks belong before tool execution, not after damage is already possible.
4. Start with a Tiny Tool Surface
Default tool set should be boring and legible:
- - INLINECODE3
- INLINECODE4
- INLINECODE5
- INLINECODE6
Do not add tools because the upstream product has them. Add tools only when they expand capability without making the harness harder to reason about.
5. Keep Skills File-Backed
Discover skills from SKILL.md files with frontmatter metadata. Avoid hidden registration layers, magic imports, or remote skill switches.
The discovery rule should be explainable in one sentence: scan configured directories, parse frontmatter, expose name, description, and path.
6. Persist Every Session
Save transcripts to disk. Each transcript should include:
- - session id
- timestamp
- prompt
- tool steps
- final response
If an agent run cannot be inspected afterward, debugging and trust both degrade.
7. Keep the Query Loop Visible
The harness should make this loop easy to trace:
- 1. receive prompt
- ask provider for next action
- validate tool request
- execute tool
- append tool result to state
- repeat until final response
- persist transcript
If you cannot sketch the loop from memory, the runtime is already too opaque.
Anti-Patterns
- - cloning upstream complexity without upstream context
- mixing config loading, permission logic, and tool execution in one file
- treating remote flags as architecture instead of distribution policy
- adding analytics before the harness can explain itself locally
- claiming a harness is complete without transcript and permission tests
Minimal Verification
Before calling the harness usable, verify:
- - config precedence behaves as documented
- permission modes actually filter tools
- skill discovery finds real
SKILL.md files - session persistence writes and reloads transcripts
- the full query loop works with a deterministic provider
The verification standard is simple: no claims about the harness until the config, permission, skills, session, and loop seams are each exercised once.
Use This Skill To
- - design a fresh coding-agent harness
- simplify a bloated Claude Code-style runtime
- review an existing agent runtime for opacity and unnecessary layers
- extract reusable harness patterns from a larger codebase
Do Not Use This Skill To
- - recreate the full Claude Code product surface
- justify hidden behavior with “that is how the upstream does it”
- add cloud control planes, telemetry, or feature flags without a concrete requirement
Output Standard
When applying this skill, produce:
- - the minimal harness shape
- the layers kept vs removed
- the exact config precedence
- the permission model
- the smallest verification plan that proves the harness is real
Lean Claude Code Harness
将Claude Code中持久化的部分提炼成一个更小、可审计的框架。目标不是功能对等,而是创建一个其他工程师无需逆向工程隐藏行为就能理解、扩展和验证的运行时。
使用时机
当编码代理运行时出现以下任何症状时,使用此技能:
- - 配置值难以追踪
- 工具权限隐式或不一致
- 工具表面不断增长但所有权不明确
- 会话历史在运行后消失
- 主循环难以凭记忆勾勒
- 仅产品逻辑被混入框架核心
保留这些原语
- - 分层配置
- 感知权限的工具执行
- 小型显式工具注册表
- Markdown技能发现
- 记录持久化
- 可见的查询循环
默认移除这些
- - 遥测
- 远程管理设置
- 隐藏的终止开关
- 私有功能标志
- 品牌特定分支
- 重量级UI层
只有当用户明确要求并能解释运营需求时,才将它们添加回来。
快速审计
如果需要快速框架审查,先回答以下六个问题:
- 1. 能否在不阅读三个文件的情况下解释配置优先级?
- 工具权限是否在执行前检查?
- 能否在一个屏幕内列出内置工具?
- 技能是否从可见文件发现而非隐藏注册?
- 每次运行是否持久化记录?
- 能否从提示到最终响应追踪查询循环?
如果两个或更多答案为否,则框架已经过于不透明。
按此顺序应用
1. 冻结运行时边界
保持入口点精简。它只应:
不要在CLI层隐藏业务逻辑。
2. 使配置优先级显式化
使用可预测的合并顺序:
- 1. 默认值
- 用户配置
- 项目配置
- 本地配置
- 环境覆盖
如果运行时值无法追溯到这些来源之一,框架已经开始滑向不透明。
3. 在执行前门控工具
在查询循环运行工具之前定义权限策略。
最小模式:
- - default和plan暴露只读工具
- 写入或shell工具需要更强的模式
- bypassPermissions应显式且罕见
权限检查属于工具执行之前,而不是在损害已经可能之后。
4. 从微小的工具表面开始
默认工具集应平淡且清晰:
- - listfiles
- readfile
- grep
- bash
不要因为上游产品有这些工具就添加它们。只有当工具扩展能力而不使框架更难推理时才添加。
5. 保持技能基于文件
从带有前置元数据的SKILL.md文件发现技能。避免隐藏的注册层、魔法导入或远程技能开关。
发现规则应能用一句话解释:扫描配置目录,解析前置元数据,暴露名称、描述和路径。
6. 持久化每个会话
将记录保存到磁盘。每个记录应包括:
如果代理运行后无法检查,调试和信任都会下降。
7. 保持查询循环可见
框架应使此循环易于追踪:
- 1. 接收提示
- 向提供者请求下一步操作
- 验证工具请求
- 执行工具
- 将工具结果追加到状态
- 重复直到最终响应
- 持久化记录
如果无法凭记忆勾勒循环,运行时已经过于不透明。
反模式
- - 在没有上游上下文的情况下克隆上游复杂性
- 将配置加载、权限逻辑和工具执行混合在一个文件中
- 将远程标志视为架构而非分发策略
- 在框架能本地解释自身之前添加分析功能
- 声称框架完整但没有记录和权限测试
最小验证
在称框架可用之前,验证:
- - 配置优先级按文档行为
- 权限模式实际过滤工具
- 技能发现找到真实的SKILL.md文件
- 会话持久化写入并重新加载记录
- 完整查询循环与确定性提供者一起工作
验证标准很简单:在配置、权限、技能、会话和循环接缝各自被测试一次之前,不要对框架做任何声明。
使用此技能
- - 设计全新的编码代理框架
- 简化臃肿的Claude Code风格运行时
- 审查现有代理运行时的透明度和不必要的层
- 从更大的代码库中提取可复用的框架模式
不要使用此技能
- - 重新创建完整的Claude Code产品表面
- 用上游就是这样做的为隐藏行为辩护
- 在没有具体需求的情况下添加云控制平面、遥测或功能标志
输出标准
应用此技能时,产出:
- - 最小框架形态
- 保留与移除的层
- 精确的配置优先级
- 权限模型
- 证明框架真实的最小验证计划