moai-foundation-trust

Validates TRUST 5-principles (Test 85%+, Readable, Unified, Secured, Trackable). Use when aligning with TRUST governance.

allowed_tools: Read, Write, Edit, Bash, TodoWrite

$ 安裝

git clone https://github.com/majiayu000/claude-skill-registry /tmp/claude-skill-registry && cp -r /tmp/claude-skill-registry/skills/testing/moai-foundation-trust ~/.claude/skills/claude-skill-registry

// tip: Run this command in your terminal to install the skill


name: moai-foundation-trust description: Validates TRUST 5-principles (Test 85%+, Readable, Unified, Secured, Trackable). Use when aligning with TRUST governance. allowed-tools:

  • Read
  • Write
  • Edit
  • Bash
  • TodoWrite version: 2.0.0 created: 2025-10-22

Foundation: TRUST Validation

Skill Metadata

FieldValue
Version2.0.0
Created2025-10-22
Allowed toolsRead, Write, Edit, Bash, TodoWrite
Auto-loadSessionStart (foundation bootstrap), /alfred:3-sync
Trigger cuesTRUST compliance checks, release readiness reviews, quality gate enforcement

What it does

Validates MoAI-ADK's TRUST 5-principles compliance using the latest 2025 testing frameworks, SAST tools, and CI/CD automation to ensure code quality, testability, security, and traceability.

When to use

  • Activates when TRUST compliance or release readiness needs evaluation
  • "Check the TRUST principle", "Quality verification", "Check code quality"
  • Automatically invoked by /alfred:3-sync
  • Before merging PR or releasing
  • During CI/CD pipeline execution

How it works

T - Test First (Coverage ≥85%)

Supported Testing Frameworks (2025-10-22):

LanguageFrameworkVersionCoverage ToolCommand
Pythonpytest8.4.2pytest-covpytest --cov=src --cov-report=term-missing --cov-fail-under=85
TypeScript/JSVitest2.0.5@vitest/coverage-v8vitest run --coverage --coverage.thresholds.lines=85
JavaScriptJest29.xbuilt-injest --coverage --coverageThreshold='{"global":{"lines":85}}'
Gotesting1.23built-ingo test ./... -cover -coverprofile=coverage.out
Rustcargo test1.82.0tarpaulincargo tarpaulin --out Xml --output-dir coverage/ --fail-under 85
Java/KotlinJUnit5.10.xJaCoCo./gradlew test jacocoTestReport
Dart/Flutterflutter test3.xbuilt-influtter test --coverage --coverage-path=coverage/lcov.info

TDD Cycle Verification:

  • RED: Failing test exists before implementation (@TEST:ID)
  • GREEN: Implementation passes test (@CODE:ID)
  • REFACTOR: Code quality improvements documented

Quality Gates:

  • Line coverage ≥85%
  • Branch coverage ≥80%
  • No skipped tests in production code
  • Test execution time <5 minutes for unit tests

R - Readable (Code Quality)

Constraints:

  • File ≤300 LOC
  • Function ≤50 LOC
  • Parameters ≤5
  • Cyclomatic complexity ≤10

Linting Tools (2025-10-22):

LanguageLinterVersionCommand
Pythonruff0.6.xruff check . --fix
TypeScript/JSBiome1.9.xbiome check --apply .
JavaScriptESLint9.xeslint . --fix
Gogolangci-lint1.60.xgolangci-lint run
Rustclippy1.82.0cargo clippy -- -D warnings
JavaCheckstyle10.x./gradlew checkstyleMain

Formatting Standards:

  • Consistent indentation (language-specific)
  • Meaningful variable/function names
  • Early return pattern (guard clauses)
  • Comments only for "why", not "what"

U - Unified (Architecture)

Verification Points:

  • SPEC-driven architecture consistency
  • Clear module boundaries and responsibilities
  • Type safety (TypeScript strict mode, mypy strict, etc.)
  • Interface/Protocol compliance
  • Dependency direction (inward toward domain)

Type Checking Tools:

LanguageToolVersionCommand
Pythonmypy1.11.xmypy src/ --strict
TypeScripttsc5.6.xtsc --noEmit --strict
Gobuilt-in1.23go vet ./...
Rustbuilt-in1.82.0cargo check

S - Secured (Security & SAST)

SAST Tools (2025-10-22):

ToolVersionPurposeCommand
detect-secrets1.4.xSecret detectiondetect-secrets scan --baseline .secrets.baseline
trivy0.56.xVulnerability scanningtrivy fs --severity HIGH,CRITICAL .
semgrep1.94.xStatic analysissemgrep --config=auto --error .
bandit1.7.xPython securitybandit -r src/ -ll
npm auditlatestJS dependenciesnpm audit --audit-level=high
gosec2.xGo securitygosec ./...

Security Checklist:

  • No hardcoded secrets (API keys, passwords, tokens)
  • Input validation on all external data
  • Proper error handling (no sensitive info in errors)
  • Dependency vulnerability scan passed
  • Access control enforced
  • HTTPS/TLS for network calls

T - Trackable (TAG Chain Integrity)

TAG Structure Validation:

  • @SPEC:ID in specs (.moai/specs/SPEC-<ID>/spec.md)
  • @TEST:ID in tests (tests/)
  • @CODE:ID in source (src/)
  • @DOC:ID in docs (docs/)

Chain Verification:

# Scan all TAGs
rg '@(SPEC|TEST|CODE|DOC):' -n .moai/specs/ tests/ src/ docs/

# Detect orphans
rg '@CODE:AUTH-001' -n src/          # CODE exists
rg '@SPEC:AUTH-001' -n .moai/specs/  # SPEC missing → orphan

Traceability Requirements:

  • Every @CODE:ID must reference @SPEC:ID and @TEST:ID
  • TAG block includes file paths: SPEC: <path> | TEST: <path>
  • HISTORY section tracks all changes with dates
  • No duplicate TAG IDs across project

Inputs

  • Project configuration (.moai/config.json, CLAUDE.md)
  • Source code (src/, tests/)
  • SPEC documents (.moai/specs/)
  • CI/CD configuration (.github/workflows/)

Outputs

  • TRUST compliance report (pass/fail per principle)
  • Coverage metrics with delta from previous run
  • Security scan results
  • TAG chain validation report
  • Quality gate decision (block/allow merge)

CI/CD Integration

GitHub Actions Example (.github/workflows/trust-validation.yml):

name: TRUST Validation

on: [pull_request, push]

jobs:
  trust-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      # T - Test First (Python example)
      - name: Run tests with coverage
        run: |
          pip install pytest pytest-cov
          pytest --cov=src --cov-report=xml --cov-fail-under=85

      # R - Readable
      - name: Lint code
        run: |
          pip install ruff
          ruff check .

      # U - Unified
      - name: Type check
        run: |
          pip install mypy
          mypy src/ --strict

      # S - Secured
      - name: Security scan
        uses: aquasecurity/trivy-action@master
        with:
          scan-type: 'fs'
          severity: 'HIGH,CRITICAL'
          exit-code: '1'

      - name: Secret detection
        run: |
          pip install detect-secrets
          detect-secrets scan --baseline .secrets.baseline

      # T - Trackable
      - name: TAG validation
        run: |
          # Check for orphaned TAGs
          ./scripts/validate-tags.sh

Quality Gate Enforcement

Merge Requirements:

  • All 5 TRUST principles must pass
  • Test coverage ≥85% (no regression from baseline)
  • Zero high/critical security vulnerabilities
  • All TAGs have valid chains
  • Code review approved

Failure Actions:

  • Block PR merge
  • Post detailed failure report as PR comment
  • Suggest remediation steps
  • Link to relevant documentation

Failure Modes

  • Missing standard files (.moai/config.json, CLAUDE.md)
  • Insufficient file access permissions
  • Conflicting policies requiring coordination
  • Tool version mismatches in CI vs local
  • Network failures during dependency scans

Dependencies

  • Works synergistically with moai-foundation-tags (TAG traceability)
  • Requires moai-foundation-specs (SPEC validation)
  • Integrates with cc-manager for session management

References

Changelog

  • 2025-10-22: v2.0.0 - Added latest tool versions (pytest 8.4.2, Vitest 2.0.5, trivy 0.56.x, etc.), CI/CD automation, SAST tools, quality gate enforcement
  • 2025-03-29: v1.0.0 - Foundation skill templates enhanced to align with best practice structures

Works well with

  • moai-foundation-tags (TAG traceability)
  • moai-foundation-specs (SPEC validation)
  • moai-alfred-trust-validation (Alfred workflow integration)
  • cc-manager (session management)

Examples

Scenario 1: Pre-merge TRUST validation

# Run full TRUST check before merging
pytest --cov=src --cov-fail-under=85
ruff check .
mypy src/ --strict
trivy fs --severity HIGH,CRITICAL .
detect-secrets scan
rg '@(SPEC|TEST|CODE):' -n .moai/specs/ tests/ src/

Scenario 2: CI/CD pipeline integration

# GitHub Actions workflow snippet
- name: TRUST Gate
  run: |
    chmod +x scripts/trust-check.sh
    ./scripts/trust-check.sh || exit 1

Scenario 3: Local development pre-commit

# .git/hooks/pre-commit
#!/bin/bash
pytest --cov=src --cov-fail-under=85 --quiet || exit 1
ruff check . --quiet || exit 1
mypy src/ --strict --no-error-summary || exit 1

Best Practices

  • Run TRUST validation locally before pushing
  • Configure IDE to show coverage inline
  • Automate quality gates in CI/CD (never manual)
  • Track coverage trends over time
  • Document reasons for TRUST exceptions (with approval)
  • Update tool versions quarterly
  • Use pre-commit hooks for fast feedback
  • Fail fast on security violations
  • Generate coverage reports for review
  • Archive TRUST reports per release