| name | dev-guardian |
| description | Automatically enforce software engineering best practices when the user writes, edits, tests, commits, pushes, deploys, or ships code. Use this skill whenever the user is doing any kind of development work — writing code, fixing bugs, adding features, refactoring, running tests, using git commands, committing changes, pushing to remote, creating pull requests, deploying applications, or releasing software. Also trigger when the user says they're "done", "finished", "let's ship this", "save it", or asks to modify any code files. The skill silently checks branch safety, CI presence, test coverage, and deployment hygiene, then embeds concise actionable recommendations into Claude's response without interrupting the user's flow. |
DevGuardian
A silent guardian that enforces engineering hygiene. No preaching, no blocking — just facts and next steps.
Behavior Rules
- Run checks silently. Do not ask permission to run them.
- Output is appended to the end of Claude's normal response, separated by
---.
- One issue per line. No explanations, no greetings, no bullet points.
- If all checks pass, output exactly:
🔒 全绿
- If the user says "guardian off", skip all checks for that turn.
Check List
Run these checks in order, every time the skill triggers.
1. Branch Safety
Run: git branch --show-current
If output is main, master, or production:
→ Append: 🔒 main分支!git checkout -b feature/<brief-desc>
2. CI Presence
Scan project root for CI configs:
.github/workflows/*.yml
.github/workflows/*.yaml
.gitlab-ci.yml
.circleci/config.yml
Jenkinsfile
azure-pipelines.yml
If none found:
→ Append: 🔒 无CI。mkdir -p .github/workflows && touch .github/workflows/ci.yml
3. Test Coverage
Run: git diff --name-only HEAD (or git status --short if not in a repo)
For each modified source file (exclude tests, configs, docs, assets):
- Check if a corresponding test file exists (same dir with
.test., .spec., test_, or in test/ / tests/ / spec/ dirs)
If any source file lacks a corresponding test:
→ Append: 🔒 <filename> 缺测试
4. Pre-commit Hygiene
Run: git status --short
If there are unstaged or uncommitted changes:
- Detect the project's test command from
package.json (scripts.test), Makefile, Gemfile, pyproject.toml, Cargo.toml, etc.
- If a test command exists and hasn't been mentioned as run recently:
→ Append:
🔒 先跑 <test-cmd> 再提交
5. Environment Separation
If the project has deployment configs (Dockerfile, fly.toml, vercel.json, render.yaml, netlify.toml, kubernetes/, helm/):
- Check for staging/preview environment markers (
staging, preview, uat, dev in filenames or config contents)
If none found:
→ Append: 🔒 缺staging环境
Output Format
Append to the very end of Claude's response:
---
🔒 main分支!git checkout -b feature/user-auth
🔒 无CI。mkdir -p .github/workflows && touch .github/workflows/ci.yml
🔒 app/models/user.rb 缺测试
If no issues:
---
🔒 全绿
If user says "guardian off": output nothing.