Defra code-quality gates — lint, format, test, and coverage must all pass before code is committed. The role plugin pins the exact toolchain (ESLint/Prettier/Vitest, dotnet format/xUnit, ruff/black/pytest, etc.); this skill states the universal expectations. Use before git commit, when wiring a new project, or when a hook reports a failure.
Ships in defra-shared. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Every Defra service runs the same four gates before code lands on main:
--check exits 0.The role plugin pins the exact toolchain. Provisional defaults:
| Stack | Lint | Format | Test | Coverage tool |
|---|---|---|---|---|
| Node.js / frontend | ESLint | Prettier | Vitest | vitest --coverage (v8) |
| C# / .NET | dotnet format --verify-no-changes | dotnet format | xUnit (dotnet test) | Coverlet via dotnet test --collect:"XPlat Code Coverage" |
| Python | Ruff (ruff check) | Black | pytest | pytest --cov |
coverage-floor, plus stack-specific lint/format hooks like eslint-fix, prettier-fix, ruff-fix, black-fix) automate this on file save where possible.// eslint-disable / # noqa / [SuppressMessage] without a one-line justification comment naming the trade-off.--fix, prettier --write, dotnet format, ruff --fix, black) are run on the changed files, not on the whole repo, to keep diffs reviewable.vitest related --coverage, pytest --cov, dotnet test --collect), not just on the file just edited. The coverage-floor hook fails the run when coverage falls below the threshold.eslint-disable / # noqa / [SuppressMessage] to make a gate pass without justification.it.skip, [Fact(Skip="…")], @pytest.mark.skip) to make the suite pass.If the user asks the agent to commit with a failing gate, the agent refuses and offers to either fix the failure or split the failing change into a separate ticket.
Before committing, the agent runs (Node.js example):
npm run lint -- $(git diff --name-only --diff-filter=ACM main...HEAD | grep -E '\.(js|mjs)$')
npm run format -- --check
npm test -- --run
npx vitest related --coverage --run $(git diff --name-only --diff-filter=ACM main...HEAD | grep -E '\.(js|mjs)$')
If lint fails, the agent runs the auto-fixer on the affected files and re-runs the gate. If coverage falls below 80% on a changed file, the agent adds the missing tests before staging the commit. If the user explicitly says "skip the tests, I'll add them later", the agent answers:
Defra quality gates require the test suite and coverage threshold to pass before commit. I won't push code with the suite skipped. I can either (a) add the missing tests now, or (b) revert the change behind a feature flag so it's invisible until tests land. Which would you like?
docs/spec/PLAN.md "Decisions still required" in the upstream planning repo.What SKILL.md sets; muted values are Claude Code's defaults
5 skills in this plugin
/defra-accessibilityDefra accessibility expectations — WCAG 2.2 AA for code-generating roles (frontend, backend rendering HTML), and semantic-markup expectations for documentation roles. Use when the agent generates a page, a component, a markdown file, or any artefact that will be read by a screen reader, a keyboard-only user, or a user with reduced vision./defra-branchingDefra branching strategy — never commit or push directly to main or master. Use a feature branch named for the work, open a pull request, get review, then merge. Use when the agent is about to run git commit, git push, or git checkout, or when a developer asks how to start a piece of work./defra-Other plugins' skills for the same job
/defra-shared:defra-quality-gatesfrom defra-shared
npx claudepluginhub defra/defra-ai-plugins --plugin defra-shared