setup-gates
Skill1 starsChanged 30 days agoMITView on GitHub
给仓库装质量门禁:提交时检查(Husky + lint-staged + Prettier + typecheck + 测试),以及拦截危险 git 命令的 Claude Code hook(push、reset --hard、clean、branch -D)。
- Deletes or force-pushes
- Commits and pushes
In this repository31 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- agentdocs-setupSkill
- agent-docsSkill
- codebase-designSkill
- code-reviewSkill
- commit-msgSkill
- diagnoseSkill
- engramSkill
- handoffSkill
- improve-archSkill
- interviewSkill
- prototypeSkill
- prSkill
- questionnaireSkill
- researchSkill
- review-frontend-productionSkill
- run-ticketSkill
- sync-claude-mdSkill
- sync-readmeSkill
- task-retroSkill
- task-specSkill
- task-ticketsSkill
- tddSkill
- teachSkill
- team-devSkill
- wait-whatSkill
- wayfinderSkill
- which-skillSkill
- wizardSkill
- writing-for-agentsSkill
The file
Files
安装门禁
给仓库装两类门禁,按用户需要各装各的:
- 提交时检查(pre-commit):lint、格式、类型、测试在提交时强制执行;
- 危险 git 拦截(PreToolUse hook):agent 执行危险 git 命令前阻断。
一、提交时检查(Husky + lint-staged + Prettier)
面向 JS/TS 项目。安装:
- Husky pre-commit 钩子
- lint-staged 对暂存文件跑 Prettier
- Prettier 配置(缺才建)
- pre-commit 里的 typecheck 与 test 脚本
步骤
- 探测包管理器:看
package-lock.json(npm)、pnpm-lock.yaml(pnpm)、yarn.lock(yarn)、bun.lockb(bun)。都不明确默认 npm; - 装依赖(devDependencies):
husky lint-staged prettier; - 初始化 Husky:
npx husky init,生成.husky/并在 package.json 加prepare: "husky"; 写
.husky/pre-commit(Husky v9+ 无需 shebang):npx lint-staged npm run typecheck npm run test适配:把
npm换成探测到的包管理器;package.json 没有typecheck或test脚本就删掉对应行并告知用户;写
.lintstagedrc:{ "*": "prettier --ignore-unknown --write" }写
.prettierrc(仅在无既有配置时):{ "useTabs": false, "tabWidth": 2, "printWidth": 80, "singleQuote": false, "trailingComma": "es5", "semi": true, "arrowParens": "always" }- 验证:
.husky/pre-commit存在且可执行;.lintstagedrc存在;prepare脚本正确;跑一次npx lint-staged确认可用; - 提交:暂存全部变更,提交信息
Add pre-commit hooks (husky + lint-staged + prettier)——这次提交会穿过新装的钩子,正好是冒烟测试。
二、危险 git 命令拦截
装一个 PreToolUse hook,在 agent 执行前阻断危险 git 命令。被拦的命令:
git push(含--force的所有变体)git reset --hardgit clean -f/git clean -fdgit branch -Dgit checkout ./git restore .
被拦时,agent 会看到一条"无权使用这些命令"的消息。
步骤
- 问范围:只装本项目(
.claude/settings.json)还是所有项目(~/.claude/settings.json); 复制脚本:把本 skill 的 scripts/block-dangerous-git.sh 复制到:
- 项目:
~/.claude 项目根/.claude/hooks/block-dangerous-git.sh - 全局:
~/.claude/hooks/block-dangerous-git.sh
chmod +x;- 项目:
登记 hook(合并进既有
hooks.PreToolUse数组,不覆盖其他设置):{ "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh" } ] } ] } }全局安装时 command 用
~/.claude/hooks/block-dangerous-git.sh;- 问定制:是否要在拦截清单上增删模式,相应修改复制后的脚本;
验证:
echo '{"tool_input":{"command":"git push origin main"}}' | <脚本路径>应以退出码 2 结束,stderr 打出 BLOCKED 消息。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

