Claude Code Constraints — AI skill for Claude Code
让 Claude Code 从随机走向可控的长期协作约束系统.
How to install Claude Code Constraints
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open lh180lh-sys/claude-code-constraints and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
What Claude Code Constraints does
让 Claude Code 从随机走向可控的长期协作约束系统。 长期与 AI 协作时,build 被跳过、文件只读一半、"应该正常"代替验证——这些问题缓慢累积,最终交付逐渐退化成"看起来已经完成"。 本项目提供一套完整的 7 层约束设计:Hook 输入端硬约束、Skill 持续性协议、CLAUDE.md 分级规范、交付前审计、关键决策点行为补丁、自动化脚本、跨会话记忆反馈。含可直接复用的配置、代码和脚本。 不是写更长的 prompt,而是搭更薄的约束层。
Alternatives in AI
- Ante — Ghost in your shell 1.9k ★
- Pro Workflow — 1,400+ Battle-tested Claude Code workflows from power users 1.4k ★
- Squeez — Hook-based token compressor for 5 AI CLI hosts (Claude Code, Copilot CLI, OpenCode, Gemini CLI, Codex CLI) 188 ★
README
Claude Code 7-Layer Constraints
让 Claude Code 从随机走向可控的长期协作约束系统
什么是 7 层约束
短任务里,Agent 的问题通常很隐蔽。代码能生成,页面能运行,大部分结果看起来没有明显错误。
工作流一旦进入长期阶段,问题会开始集中出现:build 被跳过、文件只读一半、工具失败后继续输出、未验证状态被压缩成"应该正常"、长上下文污染当前任务……
这套系统把约束从 prompt 层面提升到系统层面,形成七层结构:
| 层级 | 名称 | 解决什么问题 | 核心机制 |
|---|---|---|---|
| 1 | Hook | 输入端硬约束注入 | UserPromptSubmit 事件注入纪律框 |
| 2 | Skill | 一次性提示变持续性协议 | Superpowers 插件自动加载 |
| 3 | CLAUDE.md | 按范围分级的规范体系 | 个人层 → Workspace 层 → 项目层 |
| 4 | Quality | 交付前审计标准 | 冷却审查 + 9维度设计审计 |
| 5 | Discipline | 关键决策点行为补丁 | 障碍排查、完成验证、积压扫描 |
| 6 | Scripts | 约束的自动化执行器 | 前端审计、归档、日报 |
| 7 | Memory | 跨会话持续反馈 | 违规记录、行为修正、档案维护 |
每一层都对应一种行为退化。不是"让 AI 记得遵守",而是"让它不得不遵守"。
快速开始(5 分钟)
1. 克隆仓库
git clone https://github.com//claude-code-constraints.git
cd claude-code-constraints
2. 复制 Hook 配置
cp templates/settings.json ~/.claude/settings.json
编辑 `~/.claude/settings.json`,将脚本路径改为你本机的实际路径。
3. 复制个人规范
cp templates/CLAUDE.md ~/.claude/CLAUDE.md
按需修改:
- "关于我"部分改成你的身份和偏好
- 项目注册表路径改成你的实际路径
- 文件夹映射改成你的项目结构
4. 安装纪律 Hook
cp scripts/hook-discipline.js ~/.claude/scripts/
cp scripts/hook-cwd-check.js ~/.claude/scripts/
5. 启用 superpowers 插件
在 `~/.claude/settings.json` 中添加:
{
"enabledPlugins": {
"superpowers@claude-plugins-official": true
}
}
完成。下次启动 Claude Code 时,约束系统开始生效。
可选增强
前端审计(推荐)
cp scripts/audit-html.js ~/.claude/scripts/
在 `~/.claude/CLAUDE.md` 中加入:
## 前端文件 Write/Edit 后强制审计
任何对 `.html` `.css` `.js` 文件的 Write 或 Edit 操作后:
1. **立即执行**:`node ~/.claude/scripts/audit-html.js [目标目录]`
2. **阻断规则**:audit 未通过 → **禁止声明完成** → 立即修正 → 重新 audit
会话归档与日报
cp scripts/archive-*.js ~/.claude/scripts/
cp scripts/daily-digest-*.j
Related Skills
Pinescript Skill
Pine Script v6 skill for Claude Code -- hard language constraints, LLM error prevention, complete reference
Kluris
Turn AI agents into team SMEs. Kluris builds a shared, human-curated knowledge brain (decisions, constraints,
Humanizer Pro
Enables LLMs to write text that passes AI detection by applying 39 composition constraints from Wikipedia and
AIMemoryHub
Windows desktop app that holds one persistent memory of your facts, rules and constraints and syncs it into GE
Hypothesize
Frame the ML problem, define success as improvement over baselines, and lock integrity constraints
Coffee CLI
A clean AI terminal workspace. No hacks, no extra hooks, no lock-in — with quick input, folder switching, copy
Related Agents
Migration Agent
Creates safe, reversible database migrations with proper indexes, constraints, and zero-downtime strategies. U
Mathodology Modeler
Use for mathematical formulation, model selection, objective functions, constraints, evaluation metrics, and s
Council Regulator
Regulator / Constraint Analyst persona for the autodecision council. Optimizes for compliance, sustainability,