meta-pre-commit-quality-gate
GitHub并行执行ruff、mypy和pytest三项质量检查,对暂存区代码进行综合评估并给出通过或拦截裁决。适用于提交前需全面质量验证的场景,逻辑与CI一致。
Trigger Scenarios
Install
npx skills add opensquilla/opensquilla --skill meta-pre-commit-quality-gate -g -y
SKILL.md
Frontmatter
{
"kind": "meta",
"name": "meta-pre-commit-quality-gate",
"always": false,
"metadata": {
"opensquilla": {
"risk": "high",
"capabilities": [
"subprocess",
"filesystem-read",
"filesystem-write"
]
}
},
"triggers": [
"pre-commit quality gate",
"pre-commit 质量门",
"提交前质量检查"
],
"provenance": {
"origin": "opensquilla-original",
"license": "Apache-2.0"
},
"composition": {
"steps": [
{
"id": "collect_staged",
"kind": "skill_exec",
"with": {
"cwd": "{{ inputs.workspace_dir | default('.') }}",
"mode": "staged_files"
},
"skill": "git-diff"
},
{
"id": "run_ruff",
"kind": "agent",
"with": {
"task": "Run `uv run ruff check <staged .py files>` on the staged Python files\nlisted below. Filter for paths ending in `.py` only.\n\nStaged files:\n---\n{{ outputs.collect_staged | truncate(800) }}\n---\n\nIf the staged list is NO_STAGED_FILES or contains no .py files, treat\nas PASS.\n\nReply with EXACTLY one line, no preamble:\n PASS: ruff clean\n FAIL: <count> findings — <head of first 5 violation lines>\n"
},
"skill": "sub-agent",
"depends_on": [
"collect_staged"
]
},
{
"id": "run_mypy",
"kind": "agent",
"with": {
"task": "Run `uv run mypy --show-error-codes` on the staged Python files that\nlive under `src\/opensquilla\/` (skip files outside that tree because\nthe project's mypy config only covers the package).\n\nStaged files:\n---\n{{ outputs.collect_staged | truncate(800) }}\n---\n\nIf no `src\/opensquilla\/**` files are staged, treat as PASS.\n\nReply with EXACTLY one line, no preamble:\n PASS: mypy clean (or no src files staged)\n FAIL: <count> errors — <head of first 3 errors>\n"
},
"skill": "sub-agent",
"depends_on": [
"collect_staged"
]
},
{
"id": "run_pytest",
"kind": "agent",
"with": {
"task": "Identify pytest files affected by these staged files (any\n`tests\/test_*.py` that imports or references a same-named module).\nRun `uv run pytest -q -x --tb=short` on the affected subset; if you\ncannot localise, run the default-path suite with the same flags.\n\nStaged files:\n---\n{{ outputs.collect_staged | truncate(800) }}\n---\n\nReply with EXACTLY one line, no preamble:\n PASS: <count> tests passed\n FAIL: <first failing test name> — <one-line error>\n"
},
"skill": "sub-agent",
"depends_on": [
"collect_staged"
]
},
{
"id": "arbitrate",
"kind": "agent",
"with": {
"task": "Three quality gates ran over the staged diff:\n - ruff: {{ outputs.run_ruff }}\n - mypy: {{ outputs.run_mypy }}\n - pytest: {{ outputs.run_pytest }}\n\nApply the rule STRICTLY (do NOT soften):\n * If ANY of the three starts with \"FAIL\" → final verdict is BLOCK.\n The BLOCK summary concatenates each failing gate's verbatim text.\n * If ALL three start with \"PASS\" → final verdict is APPROVE.\n\nReply with EXACTLY this structure on the first line, then optionally\nadditional lines:\n BLOCK: <one-line summary; list every gate that failed>\n APPROVE: ruff\/mypy\/pytest all green"
},
"skill": "sub-agent",
"depends_on": [
"run_ruff",
"run_mypy",
"run_pytest"
]
},
{
"id": "persist",
"kind": "tool_call",
"tool": "memory_save",
"tool_args": {
"mode": "append",
"path": "memory\/pre-commit-gates.md",
"content": "=== pre-commit quality gate ===\ninvocation: {{ inputs.user_message | xml_escape | truncate(200) }}\nstaged: {{ outputs.collect_staged | truncate(600) }}\nruff: {{ outputs.run_ruff | truncate(200) }}\nmypy: {{ outputs.run_mypy | truncate(200) }}\npytest: {{ outputs.run_pytest | truncate(200) }}\nverdict: {{ outputs.arbitrate | truncate(400) }}"
},
"depends_on": [
"arbitrate"
],
"tool_allowlist": [
"memory_save"
]
}
]
},
"description": "Run three quality gates (ruff + mypy + pytest) in parallel over the staged diff, then arbitrate a single BLOCK\/APPROVE verdict. Use before committing changes locally when you want a comprehensive pre-commit gate beyond per-file linting — exactly the same gate set CI enforces.",
"meta_priority": 70
}
Pre-Commit Quality Gate (Meta-Skill)
A combinator-style meta-skill that runs three independent quality gates in parallel over the currently-staged diff, then arbitrates a single ship-readiness verdict.
Trigger surface
Fire by saying pre-commit quality gate or one of the localized triggers
listed in the frontmatter. The skill is also designed to be invoked from a git
pre-commit hook via the soft path (meta_invoke), but hook installation is a
separate manual step.
Fallback
If the orchestrator fails (sub-Agent error, timeout, etc.), the
caller should manually run, in order: uv run ruff check src tests,
uv run mypy src/opensquilla --show-error-codes, then
uv run pytest -q. The same three commands are the CI quality gate
in .github/workflows/ci.yml.
Version History
- 7f72a32 Current 2026-07-05 18:41


