Convert hand-written constraint files into automated tooling. Rules in prompt files are forgotten when context grows long. Rules compiled into linters, hooks, and validators are enforced 100% of the time, at zero token cost.
Detect which platform(s) are present, then scan the corresponding constraint files.
bash
test -f CLAUDE.md && echo "CLAUDE_CODE"
test -f openclaw.json && echo "OPENCLAW"
test -f .cursorrules && echo "CURSOR"
test -f .github/copilot-instructions.md && echo "COPILOT"
Claude Code: CLAUDE.md (monolithic), .claude/commands/*.md OpenClaw: agents.md (priority 10), soul.md (20), identity.md (30), user.md (40), tools.md (50), bootstrap.md (60), memory.md (70). Skip SAFETY.md (hardcoded, read-only).
Cursor: .cursorrules Copilot: .github/copilot-instructions.md Generic: AGENT.md, SOUL.md, README.md conventions sections
Read ALL found files. Extract every rule, convention, and constraint.
Classify each extracted rule into one of two buckets.
CategoryExample RuleTarget Toolcode-style"2 spaces, no semicolons, single quotes".prettierrcnaming"Files kebab-case, components PascalCase"ESLint custom ruleimport"No default exports" / "Use @/ alias"ESLint no-restricted-pathsapi-format"Responses use { code, data, msg }"Wrapper function + linttype-safety"No any, no as"tsconfig strictsecurity"No innerHTML" / "Validate user input"ESLint + zodtesting"Every module needs a test file"Test existence checkergit"Conventional commits" / "Lint before commit"commitlint + huskydependency"No new deps without approval"dependency-check scriptperformance"No lodash, use lodash-es"ESLint no-restricted-imports
CategoryExample RuleWhyarchitecture"Use repository pattern"Semantic understanding neededbusiness-logic"Prices in cents, not dollars"Domain-specificdesign"Composition over inheritance"Judgment callcommunication"Explain in Chinese"Behavioralworkflow"Ask before deleting"Human-in-the-loop
Before generating tools, detect the project stack:
text
package.json → Node.js | tsconfig.json → TypeScript
.eslintrc* → ESLint exists | .prettierrc* → Prettier exists
.husky/ → Husky exists | pyproject.toml → Python
Cargo.toml → Rust | go.mod → Go
For each auto-toolable rule, generate the appropriate tool. See references/tool-patterns.md for detailed generation patterns covering:
For OpenClaw-specific hooks, see references/openclaw-hooks.md.
After generation, produce a report:
markdown
## Rule Toolkit Report
### Platform: Claude Code / OpenClaw / Cursor / Copilot
### Scanned Files
- CLAUDE.md (45 rules)
- soul.md (8 rules)
### Converted to Tools (38 rules)
| Rule | Source | Tool | Status |
|------|--------|------|--------|
| "Use 2-space indent" | CLAUDE.md | .prettierrc | Created |
| "No semicolons" | soul.md | .prettierrc | Created |
| "Conventional commits" | bootstrap.md | commitlint | Created |
### Remaining in Prompt (15 rules)
| Rule | Source | Reason |
|------|--------|--------|
| "Use repository pattern" | CLAUDE.md | Architectural judgment |
| "Ask before deleting" | tools.md | Human-in-the-loop |
### Summary
- N% rules automatically enforced
- M% remain in prompt
- Token savings: ~X tokens/conversation
Remove toolified rules from source files to save tokens.
Claude Code — replace removed rules in CLAUDE.md:
markdown
## Rules
Automated rules enforced by tooling. Run `npm run lint` to check.
See `.eslintrc.cjs`, `.prettierrc`, `scripts/check-rules.js`.
OpenClaw — replace removed rules in each file (e.g. tools.md):
markdown
## Tool Rules
Automated: linting (`npx eslint .`), type check (`npx tsc --noEmit`).
API format: use `ok()`/`fail()` from `src/utils/response.ts`.
Remaining rules below require human judgment.
SAFETY.md is hardcoded — skip it