Loading...
Loading...
Generate custom lint rules from architectural patterns. ESLint local plugins (JS/TS) or ast-grep YAML rules (Python/Go/Rust/any). Invoke when: codifying an import boundary, enforcing API conventions, blocking deprecated patterns, or any "always/never" constraint.
npx skill4agent add phrazzld/claude-config guardrailfast-feedback.pyimport { db } from './db'/tune-repo| Criterion | ESLint | ast-grep |
|---|---|---|
| Language | JS/TS only | Any (Python, Go, Rust, etc.) |
| Fixable | Yes (auto-fix) | Yes (rewrite) |
| Testing | RuleTester built-in | YAML snapshot tests |
| Config | Flat config plugin | sgconfig.yml |
| Speed | Fast | Very fast |
--enginereferences/eslint-rule-anatomy.mdreferences/ast-grep-rule-anatomy.mdtemplates/eslint-rule.jstemplates/eslint-rule-test.jstemplates/ast-grep-rule.yml# Run RuleTester
node guardrails/rules/<rule-name>.test.js
# Or if project uses a test runner:
npx vitest run guardrails/rules/<rule-name>.test.jssg scan --config guardrails/sgconfig.yml --test# ESLint: run rule on entire project, expect 0 or known violations
npx eslint --no-warn-ignored --rule 'guardrails/<rule-name>: error' .
# ast-grep: scan project
sg scan --config guardrails/sgconfig.ymlguardrails/guardrails/
README.md # Catalog of all custom rules
index.js # ESLint local plugin barrel (JS/TS projects)
sgconfig.yml # ast-grep config (if non-JS rules exist)
rules/
<rule-name>.js # ESLint rule implementation
<rule-name>.test.js # ESLint RuleTester
<rule-name>.yml # ast-grep rule// guardrails/index.js
import noDirectDbImport from "./rules/no-direct-db-import.js";
export default {
rules: {
"no-direct-db-import": noDirectDbImport,
},
};// eslint.config.js — add to existing config
import guardrails from "./guardrails/index.js";
export default [
// ... existing config
{
plugins: { guardrails },
rules: {
"guardrails/no-direct-db-import": "error",
},
},
];# guardrails/sgconfig.yml
ruleDirs:
- rulesguardrails/README.md## <rule-name>
**Engine:** ESLint | ast-grep
**Pattern:** <what it enforces>
**Rationale:** <why — link ADR if exists>
**Auto-fix:** yes | no
**Exceptions:** <files/patterns excluded>GUARDRAIL CREATED:
- Rule: guardrails/rules/<name>.<ext>
- Test: guardrails/rules/<name>.test.<ext>
- Engine: ESLint | ast-grep
- Violations found: N (in current codebase)
- Auto-fixable: yes | no
- Config updated: eslint.config.js | guardrails/sgconfig.yml| Consumed by | How |
|---|---|
| Runs |
| Routes "lint rule" target here |
| Routes "lint rule" target here |
| Discovers patterns, recommends |
| Audits |
| CI (GitHub Actions) | Standard |