AgentSkillsCN

bd-quality-assurance

严格执行代码标准,验证代码是否具备发布就绪条件。在完成功能开发或重构、准备Pull Request,或执行提交前检查时使用此功能。

SKILL.md
--- frontmatter
name: bd-quality-assurance
description: Enforces code standards and validates release readiness. Use when finalizing features or refactors, preparing pull requests, or performing pre-commit checks.

Quality Assurance

This skill guides the execution of quality checks and enforcement of code standards. Apply these practices before committing code, when preparing pull requests, or after completing features.

The user has code ready to commit or submit for review. They need guidance on what checks to run, what standards to enforce, or how to prepare code for production.


Quality Thinking

Before committing, verify the code meets all quality standards:

  • Completeness: Is the feature/fix fully implemented?
  • Correctness: Does it work as intended? Are tests passing?
  • Cleanliness: Is the code formatted, typed, and linted?
  • Coverage: Are new code paths tested?

CRITICAL: All quality checks must pass before committing. No exceptions. Broken builds waste everyone's time.

When This Applies

Use this skill when:

  • Preparing to commit code
  • Creating a pull request
  • Completing a feature or fix
  • Running CI checks locally
  • Reviewing code quality

Pre-Commit Checklist

Applies to: All code changes before committing

Execution Order

Run checks in this order (each step depends on the previous):

code
1. Format   → Consistent code style
2. Lint     → Code quality and patterns
3. Type     → Type safety verification
4. Test     → Behavior verification
5. Build    → Compilation/bundling success

Platform-Specific Commands

Python

Applies to: Python projects

StepCommandPurpose
Formatblack . or ruff format .Code formatting
Lintruff check . --fixLinting with auto-fix
Typemypy src/Static type checking
Testpytest -v --covTests with coverage
Buildpip install -e .Verify package builds

TypeScript/JavaScript

Applies to: Node.js, React, Vue, Angular projects

StepCommandPurpose
Formatprettier --write .Code formatting
Linteslint . --fixLinting with auto-fix
Typetsc --noEmitType checking (TS only)
Testnpm test or vitest runRun test suite
Buildnpm run buildVerify production build

Swift (iOS)

Applies to: iOS, macOS applications

StepCommandPurpose
Formatswiftformat .Code formatting
Lintswiftlint --fixLinting with auto-fix
TypeBuilt into compiler(Automatic)
Testxcodebuild testRun test suite
Buildxcodebuild buildVerify build

Kotlin (Android)

Applies to: Android, JVM applications

StepCommandPurpose
Formatktfmt --format .Code formatting
Lint./gradlew ktlintCheckLinting
TypeBuilt into compiler(Automatic)
Test./gradlew testRun test suite
Build./gradlew assembleDebugVerify build

Dart/Flutter

Applies to: Flutter applications

StepCommandPurpose
Formatdart format .Code formatting
Lintflutter analyzeStatic analysis
TypeBuilt into analyzer(Automatic)
Testflutter test --coverageRun tests with coverage
Buildflutter buildVerify build

Go

Applies to: Go applications

StepCommandPurpose
Formatgofmt -w .Code formatting
Lintgolangci-lint runComprehensive linting
TypeBuilt into compiler(Automatic)
Testgo test -v -cover ./...Tests with coverage
Buildgo build ./...Verify compilation

Rust

Applies to: Rust applications

StepCommandPurpose
Formatcargo fmtCode formatting
Lintcargo clippyLinting
TypeBuilt into compiler(Automatic)
Testcargo testRun test suite
Buildcargo buildVerify compilation

Quality Gates

Applies to: All projects, CI/CD pipelines

Non-Negotiable Standards

GateRequirementRationale
All checks passZero errors from all toolsBroken code shouldn't be committed
Tests pass100% of tests greenRegressions must be caught
Coverage maintainedNo decrease in coverageNew code needs tests
No new warningsFix or explicitly suppressWarnings become errors over time

Coverage Requirements

Code TypeMinimum Coverage
New code80% line coverage
Critical paths90%+ coverage
Bug fixesTest must cover the fix
RefactorsMaintain existing coverage

Code Standards Enforcement

Applies to: All code

Complexity Limits

MetricLimitAction if Exceeded
Cognitive complexity≤15 per functionRefactor into smaller units
Function length≤30 linesExtract sub-functions
File length≤400 linesSplit into modules
Nesting depth≤3 levelsUse early returns
Parameters≤3-4 per functionUse parameter objects

Required Patterns

PatternRequirement
Type annotationsAll function signatures typed
Named argumentsUse for all function calls
Enum valuesFor all bounded strings
Error handlingAll errors explicitly handled
Resource cleanupAll resources properly released

Forbidden Patterns

PatternWhy It's Forbidden
Hardcoded secretsSecurity risk
Magic stringsType safety
Commented-out codeVersion control handles history
TODO without issueOrphaned intentions
Console logs in prodPerformance and security
Any/dynamic typesType safety

Pull Request Preparation

Applies to: Before creating a PR

PR Readiness Checklist

code
□ All quality checks pass locally
□ Tests cover new functionality
□ No unrelated changes included
□ Commits are logical and atomic
□ Commit messages are descriptive
□ No debugging code left behind
□ Documentation updated if needed
□ Breaking changes documented

Commit Message Format

Guidance:

code
<type>(<scope>): <short description>

<body - what and why, not how>

<footer - breaking changes, issue references>

Types:

TypeUse For
featNew feature
fixBug fix
refactorCode restructuring
testAdding/updating tests
docsDocumentation
styleFormatting (no logic change)
choreBuild/tooling changes

CI/CD Alignment

Applies to: Local development matching CI

Local Should Match CI

PrincipleImplementation
Same toolsUse identical versions as CI
Same orderRun checks in CI order
Same configShare config files
Same environmentUse containers/devcontainers

Pre-Push Verification

Guidance: Run the full CI check locally before pushing:

bash
# Example combined command (adapt per platform)
format && lint && type-check && test && build

Handling Failures

Applies to: When checks fail

Failure Response

Failure TypeAction
FormatRun formatter, commit changes
LintFix issues or suppress with justification
TypeFix type errors (never use any escape)
TestFix code or update test (never skip)
BuildResolve compilation/bundling errors

Suppressing Warnings

Only suppress when:

  • The warning is a false positive
  • The pattern is intentional and documented
  • There's a comment explaining why

Never suppress:

  • Without explanation
  • To "make CI green"
  • Security-related warnings

Anti-Patterns (NEVER use)

  • Skipping checks: "Just this once" leads to broken main branch
  • Force pushing over failures: Fix the issue, don't hide it
  • Disabling CI: Never disable to merge faster
  • Suppressing without reason: Every suppression needs justification
  • Committing debug code: Remove console.log, print statements
  • Committing generated files: Keep artifacts out of source control
  • Large uncommitted changes: Commit frequently in small increments

Core Philosophy

"Quality is not an act, it is a habit." — Aristotle

Quality checks are not obstacles—they are guardrails that protect the team. The few minutes spent running checks save hours of debugging and firefighting.