compliance-check

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Compliance Check Skill

合规检查Skill

Verify and enforce coding standards, AI guidelines, and workspace compliance across all 26+ repositories.
跨所有26+代码库验证并执行编码标准、AI指南及工作区合规要求。

Quick Start

快速开始

bash
undefined
bash
undefined

Quick compliance check

Quick compliance check

./scripts/compliance/verify_compliance.sh
./scripts/compliance/verify_compliance.sh

Check specific repository

Check specific repository

./scripts/compliance/verify_compliance.sh --repo=digitalmodel
./scripts/compliance/verify_compliance.sh --repo=digitalmodel

Propagate standards to all repos

Propagate standards to all repos

./scripts/compliance/propagate_claude_config.py
undefined
./scripts/compliance/propagate_claude_config.py
undefined

When to Use

适用场景

  • Setting up a new repository that needs workspace standards
  • Verifying all repos meet coding and documentation standards
  • Propagating updated guidelines across the workspace
  • Installing pre-commit hooks for enforcement
  • Auditing compliance before releases
  • 搭建需要遵循工作区标准的新代码库
  • 验证所有代码库是否符合编码及文档标准
  • 在工作区内推广更新后的指南
  • 安装用于强制执行标准的预提交钩子
  • 发布前进行合规审计

Prerequisites

前置条件

  • Access to workspace-hub compliance scripts
  • Write access to target repositories
  • Python 3.x for propagation scripts
  • Git for hook installation
  • 有权限访问workspace-hub合规脚本
  • 拥有目标代码库的写入权限
  • 运行推广脚本需要Python 3.x
  • 安装钩子需要Git

Overview

概述

This skill ensures consistent coding standards, AI usage guidelines, and development practices across all workspace-hub repositories. It covers verification, propagation, and enforcement of compliance requirements.
本Skill确保所有workspace-hub代码库遵循统一的编码标准、AI使用指南及开发实践,涵盖合规要求的验证、推广与强制执行。

Compliance Areas

合规领域

1. AI Agent Guidelines

1. AI Agent指南

Ensure AI agents follow required workflows:
  • Read
    user_prompt.md
    before implementation
  • Ask clarifying questions
  • Wait for user approval
  • Follow SPARC methodology
  • Use TDD practices
Reference: AI_AGENT_GUIDELINES.md
确保AI Agent遵循规定工作流程:
  • 实施前阅读
    user_prompt.md
  • 提出澄清问题
  • 等待用户批准
  • 遵循SPARC方法论
  • 采用TDD实践
参考文档: AI_AGENT_GUIDELINES.md

2. Development Workflow

2. 开发工作流

Ensure proper workflow adherence:
  • user_prompt.md -> YAML config -> Pseudocode -> TDD -> Implementation
  • Bash-based execution
  • Interactive engagement
  • Gate-pass reviews
Reference: DEVELOPMENT_WORKFLOW.md
确保遵循正确的工作流:
  • user_prompt.md -> YAML配置 -> 伪代码 -> TDD -> 实现
  • 基于Bash执行
  • 交互式协作
  • 门控评审
参考文档: DEVELOPMENT_WORKFLOW.md

3. File Organization

3. 文件组织结构

Ensure proper directory structure:
  • /src
    - Source code
  • /tests
    - Test files
  • /docs
    - Documentation
  • /config
    - Configuration
  • /scripts
    - Utility scripts
  • /data
    - Data files
  • /reports
    - Generated reports
Reference: FILE_ORGANIZATION_STANDARDS.md
确保目录结构合规:
  • /src
    - 源代码
  • /tests
    - 测试文件
  • /docs
    - 文档
  • /config
    - 配置文件
  • /scripts
    - 实用脚本
  • /data
    - 数据文件
  • /reports
    - 生成的报告
参考文档: FILE_ORGANIZATION_STANDARDS.md

4. Code Quality Standards

4. 代码质量标准

Ensure code meets quality requirements:
  • 80%+ test coverage
  • Proper logging (5 levels)
  • HTML reports with interactive plots
  • No static matplotlib exports
References:
  • TESTING_FRAMEWORK_STANDARDS.md
  • LOGGING_STANDARDS.md
  • HTML_REPORTING_STANDARDS.md
确保代码符合质量要求:
  • 测试覆盖率≥80%
  • 正确的日志记录(5个级别)
  • 带交互式图表的HTML报告
  • 禁止使用静态matplotlib导出
参考文档:
  • TESTING_FRAMEWORK_STANDARDS.md
  • LOGGING_STANDARDS.md
  • HTML_REPORTING_STANDARDS.md

Verification Commands

验证命令

Quick Compliance Check

快速合规检查

bash
./scripts/compliance/verify_compliance.sh
bash
./scripts/compliance/verify_compliance.sh

Check Specific Repository

检查指定代码库

bash
./scripts/compliance/verify_compliance.sh --repo=digitalmodel
bash
./scripts/compliance/verify_compliance.sh --repo=digitalmodel

Check Specific Area

检查指定领域

bash
./scripts/compliance/verify_compliance.sh --area=testing
./scripts/compliance/verify_compliance.sh --area=logging
./scripts/compliance/verify_compliance.sh --area=file-org
bash
./scripts/compliance/verify_compliance.sh --area=testing
./scripts/compliance/verify_compliance.sh --area=logging
./scripts/compliance/verify_compliance.sh --area=file-org

Execution Checklist

执行检查清单

  • Run full compliance scan on all repos
  • Review compliance report for failures
  • Fix critical compliance issues first
  • Propagate standards to non-compliant repos
  • Install git hooks for enforcement
  • Verify CI/CD integration
  • Document any approved exceptions
  • 对所有代码库运行完整合规扫描
  • 查看合规报告中的失败项
  • 优先修复严重合规问题
  • 向不合规的代码库推广标准
  • 安装Git钩子以强制执行标准
  • 验证CI/CD集成
  • 记录所有获批的例外情况

Compliance Verification Checklists

合规验证检查清单

Repository Structure

代码库结构

markdown
undefined
markdown
undefined

Structure Compliance

Structure Compliance

  • /src directory exists and contains source code
  • /tests directory exists with unit and integration tests
  • /docs directory exists with documentation
  • /config directory exists for configurations
  • /scripts directory exists for utilities
  • No files in root (except standard config files)
  • CLAUDE.md exists and follows template
  • .agent-os/ directory properly configured
undefined
  • /src directory exists and contains source code
  • /tests directory exists with unit and integration tests
  • /docs directory exists with documentation
  • /config directory exists for configurations
  • /scripts directory exists for utilities
  • No files in root (except standard config files)
  • CLAUDE.md exists and follows template
  • .agent-os/ directory properly configured
undefined

Testing Standards

测试标准

markdown
undefined
markdown
undefined

Testing Compliance

Testing Compliance

  • pytest configured as test framework
  • Test coverage >= 80%
  • Unit tests in /tests/unit/
  • Integration tests in /tests/integration/
  • No mock data (use real repository data)
  • Performance tests exist
  • Tests run in CI/CD pipeline
undefined
  • pytest configured as test framework
  • Test coverage >= 80%
  • Unit tests in /tests/unit/
  • Integration tests in /tests/integration/
  • No mock data (use real repository data)
  • Performance tests exist
  • Tests run in CI/CD pipeline
undefined

Logging Standards

日志标准

markdown
undefined
markdown
undefined

Logging Compliance

Logging Compliance

  • All 5 log levels supported (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  • Standard log format used
  • Log files in /logs directory
  • Log rotation configured
  • Sensitive data sanitized
  • Structured logging for parsing
undefined
  • All 5 log levels supported (DEBUG, INFO, WARNING, ERROR, CRITICAL)
  • Standard log format used
  • Log files in /logs directory
  • Log rotation configured
  • Sensitive data sanitized
  • Structured logging for parsing
undefined

HTML Reporting

HTML报告标准

markdown
undefined
markdown
undefined

Reporting Compliance

Reporting Compliance

  • HTML reports generated (not static images)
  • Interactive plots (Plotly, Bokeh, Altair)
  • No matplotlib PNG exports
  • CSV data uses relative paths
  • Reports in /reports directory
  • Responsive design
undefined
  • HTML reports generated (not static images)
  • Interactive plots (Plotly, Bokeh, Altair)
  • No matplotlib PNG exports
  • CSV data uses relative paths
  • Reports in /reports directory
  • Responsive design
undefined

AI Guidelines

AI指南

markdown
undefined
markdown
undefined

AI Compliance

AI Compliance

  • CLAUDE.md references AI_AGENT_GUIDELINES.md
  • Interactive engagement enforced
  • Question-asking pattern documented
  • TDD workflow required
  • No assumptions without clarification
undefined
  • CLAUDE.md references AI_AGENT_GUIDELINES.md
  • Interactive engagement enforced
  • Question-asking pattern documented
  • TDD workflow required
  • No assumptions without clarification
undefined

Propagation Tools

推广工具

Propagate CLAUDE.md Configuration

同步CLAUDE.md配置

bash
./scripts/compliance/propagate_claude_config.py
Syncs CLAUDE.md template to all repositories.
bash
./scripts/compliance/propagate_claude_config.py
将CLAUDE.md模板同步到所有代码库。

Propagate AI Guidelines

推广AI指南

bash
./scripts/compliance/propagate_guidelines.sh
Updates AI_AGENT_GUIDELINES.md and AI_USAGE_GUIDELINES.md.
bash
./scripts/compliance/propagate_guidelines.sh
更新AI_AGENT_GUIDELINES.md和AI_USAGE_GUIDELINES.md。

Propagate Interactive Mode

推广交互式模式

bash
./scripts/compliance/propagate_interactive_mode.sh
Ensures interactive engagement rules are in place.
bash
./scripts/compliance/propagate_interactive_mode.sh
确保交互式协作规则生效。

Git Hooks for Enforcement

用于强制执行的Git钩子

Install Compliance Hooks

安装合规钩子

bash
./scripts/compliance/install_compliance_hooks.sh
bash
./scripts/compliance/install_compliance_hooks.sh

Pre-commit Hook Checks

预提交钩子检查

The pre-commit hook verifies:
  1. File organization: No files in wrong locations
  2. Test coverage: Coverage report exists and meets threshold
  3. Linting: No syntax errors
  4. YAML validation: Valid YAML configuration
  5. Documentation: Required docs exist
预提交钩子会验证:
  1. 文件组织:无文件存放在错误位置
  2. 测试覆盖率:覆盖率报告存在且符合阈值
  3. 代码检查:无语法错误
  4. YAML验证:YAML配置有效
  5. 文档:必要文档已存在

Hook Configuration

钩子配置

bash
undefined
bash
undefined

.git/hooks/pre-commit

.git/hooks/pre-commit

#!/bin/bash set -e
echo "Running compliance checks..."
#!/bin/bash set -e
echo "Running compliance checks..."

Check file organization

Check file organization

./scripts/compliance/check_file_org.sh
./scripts/compliance/check_file_org.sh

Check test coverage

Check test coverage

coverage=$(./scripts/compliance/get_coverage.sh) if [ "$coverage" -lt 80 ]; then echo "ERROR: Test coverage $coverage% is below 80%" exit 1 fi
coverage=$(./scripts/compliance/get_coverage.sh) if [ "$coverage" -lt 80 ]; then echo "ERROR: Test coverage $coverage% is below 80%" exit 1 fi

Check for static images in reports

Check for static images in reports

if find reports/ -name ".png" -o -name ".jpg" | grep -q .; then echo "ERROR: Static images found in reports. Use interactive HTML." exit 1 fi
echo "Compliance checks passed!"
undefined
if find reports/ -name ".png" -o -name ".jpg" | grep -q .; then echo "ERROR: Static images found in reports. Use interactive HTML." exit 1 fi
echo "Compliance checks passed!"
undefined

Error Handling

错误处理

Common Compliance Failures

常见合规失败情况

IssueCauseResolution
Structure violationFiles in wrong directoryMove files to correct location
Low test coverageInsufficient testsAdd unit/integration tests
Static imagesmatplotlib exportsConvert to Plotly/Bokeh HTML
Missing CLAUDE.mdNew repo setupRun propagation script
Hook not runningPermission issue
chmod +x .git/hooks/pre-commit
问题原因解决方法
结构违规文件存放在错误目录将文件移动到正确位置
测试覆盖率低测试用例不足添加单元/集成测试
静态图片使用matplotlib导出转换为Plotly/Bokeh HTML
缺少CLAUDE.md新代码库未配置运行推广脚本
钩子未运行权限问题
chmod +x .git/hooks/pre-commit

Fixing Non-Compliance

修复不合规问题

Structure Issues

结构问题

bash
undefined
bash
undefined

Create missing directories

Create missing directories

mkdir -p src tests docs config scripts data reports logs
mkdir -p src tests docs config scripts data reports logs

Move misplaced files

Move misplaced files

git mv root_file.py src/ git mv old_tests.py tests/unit/
undefined
git mv root_file.py src/ git mv old_tests.py tests/unit/
undefined

Testing Issues

测试问题

bash
undefined
bash
undefined

Install pytest and coverage

Install pytest and coverage

pip install pytest pytest-cov
pip install pytest pytest-cov

Run tests with coverage

Run tests with coverage

pytest --cov=src --cov-report=html --cov-fail-under=80
undefined
pytest --cov=src --cov-report=html --cov-fail-under=80
undefined

Logging Issues

日志问题

python
undefined
python
undefined

Add proper logging configuration

Add proper logging configuration

import logging
logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - [%(filename)s:%(lineno)d] - %(message)s', handlers=[ logging.FileHandler('logs/app.log'), logging.StreamHandler() ] )
undefined
import logging
logging.basicConfig( level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - [%(filename)s:%(lineno)d] - %(message)s', handlers=[ logging.FileHandler('logs/app.log'), logging.StreamHandler() ] )
undefined

Reporting Issues

报告问题

python
undefined
python
undefined

Replace matplotlib with Plotly

Replace matplotlib with Plotly

Before (non-compliant):

Before (non-compliant):

import matplotlib.pyplot as plt plt.savefig('reports/chart.png')
import matplotlib.pyplot as plt plt.savefig('reports/chart.png')

After (compliant):

After (compliant):

import plotly.express as px fig = px.line(df, x='x', y='y') fig.write_html('reports/chart.html')
undefined
import plotly.express as px fig = px.line(df, x='x', y='y') fig.write_html('reports/chart.html')
undefined

Troubleshooting

故障排除

Hook Not Running

钩子未运行

bash
undefined
bash
undefined

Make hook executable

Make hook executable

chmod +x .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

Check hook exists

Check hook exists

ls -la .git/hooks/pre-commit
undefined
ls -la .git/hooks/pre-commit
undefined

False Positives

误报

bash
undefined
bash
undefined

Add exceptions to compliance config

Add exceptions to compliance config

config/compliance.yaml

config/compliance.yaml

exceptions:
  • path: legacy/old_module.py reason: "Legacy code, scheduled for refactoring in Q2"
undefined
exceptions:
  • path: legacy/old_module.py reason: "Legacy code, scheduled for refactoring in Q2"
undefined

Coverage Not Detected

覆盖率未被检测到

bash
undefined
bash
undefined

Ensure coverage config exists

Ensure coverage config exists

pyproject.toml or .coveragerc

pyproject.toml or .coveragerc

[tool.coverage.run] source = ["src"] omit = ["tests/", "/migrations/*"]
undefined
[tool.coverage.run] source = ["src"] omit = ["tests/", "/migrations/*"]
undefined

Metrics & Success Criteria

指标与成功标准

  • Compliance Rate: >= 95% of repos fully compliant
  • Propagation Success: 100% of repos have latest standards
  • Hook Coverage: Git hooks installed in all active repos
  • CI Integration: All repos have compliance in CI/CD
  • Exception Rate: < 5% of checks have documented exceptions
  • 合规率:≥95%的代码库完全合规
  • 推广成功率:100%的代码库拥有最新标准
  • 钩子覆盖率:所有活跃代码库均已安装Git钩子
  • CI集成:所有代码库在CI/CD中包含合规检查
  • 例外率:<5%的检查存在已记录的例外情况

Compliance Reports

合规报告

Generate Compliance Report

生成合规报告

bash
./scripts/compliance/generate_report.sh > reports/compliance_report.html
bash
./scripts/compliance/generate_report.sh > reports/compliance_report.html

Report Template

报告模板

html
<!DOCTYPE html>
<html>
<head>
    <title>Compliance Report</title>
    <style>
        .pass { color: green; }
        .fail { color: red; }
        .warn { color: orange; }
    </style>
</head>
<body>
    <h1>Workspace Compliance Report</h1>
    <p>Generated: {{timestamp}}</p>

    <h2>Summary</h2>
    <table>
        <tr><td>Total Repositories</td><td>{{total}}</td></tr>
        <tr><td class="pass">Fully Compliant</td><td>{{compliant}}</td></tr>
        <tr><td class="warn">Partial Compliance</td><td>{{partial}}</td></tr>
        <tr><td class="fail">Non-Compliant</td><td>{{non_compliant}}</td></tr>
    </table>

    <h2>Repository Details</h2>
    {{#each repositories}}
    <h3>{{name}}</h3>
    <ul>
        {{#each checks}}
        <li class="{{status}}">{{check}}: {{message}}</li>
        {{/each}}
    </ul>
    {{/each}}
</body>
</html>
html
<!DOCTYPE html>
<html>
<head>
    <title>Compliance Report</title>
    <style>
        .pass { color: green; }
        .fail { color: red; }
        .warn { color: orange; }
    </style>
</head>
<body>
    <h1>Workspace Compliance Report</h1>
    <p>Generated: {{timestamp}}</p>

    <h2>Summary</h2>
    <table>
        <tr><td>Total Repositories</td><td>{{total}}</td></tr>
        <tr><td class="pass">Fully Compliant</td><td>{{compliant}}</td></tr>
        <tr><td class="warn">Partial Compliance</td><td>{{partial}}</td></tr>
        <tr><td class="fail">Non-Compliant</td><td>{{non_compliant}}</td></tr>
    </table>

    <h2>Repository Details</h2>
    {{#each repositories}}
    <h3>{{name}}</h3>
    <ul>
        {{#each checks}}
        <li class="{{status}}">{{check}}: {{message}}</li>
        {{/each}}
    </ul>
    {{/each}}
</body>
</html>

Automation

自动化

CI/CD Integration

CI/CD集成

yaml
undefined
yaml
undefined

.github/workflows/compliance.yml

.github/workflows/compliance.yml

name: Compliance Check
on: [push, pull_request]
jobs: compliance: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3
  - name: Check File Organization
    run: ./scripts/compliance/check_file_org.sh

  - name: Check Test Coverage
    run: |
      pip install pytest pytest-cov
      pytest --cov=src --cov-fail-under=80

  - name: Check for Static Images
    run: |
      if find reports/ -name "*.png" | grep -q .; then
        echo "Static images found in reports"
        exit 1
      fi

  - name: Validate YAML Configs
    run: ./scripts/compliance/validate_yaml.sh
undefined
name: Compliance Check
on: [push, pull_request]
jobs: compliance: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3
  - name: Check File Organization
    run: ./scripts/compliance/check_file_org.sh

  - name: Check Test Coverage
    run: |
      pip install pytest pytest-cov
      pytest --cov=src --cov-fail-under=80

  - name: Check for Static Images
    run: |
      if find reports/ -name "*.png" | grep -q .; then
        echo "Static images found in reports"
        exit 1
      fi

  - name: Validate YAML Configs
    run: ./scripts/compliance/validate_yaml.sh
undefined

Scheduled Compliance Scan

定期合规扫描

yaml
undefined
yaml
undefined

Run weekly compliance scan

Run weekly compliance scan

name: Weekly Compliance Scan
on: schedule: - cron: '0 9 * * 1' # Monday 9am
jobs: scan: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Full Compliance Scan run: ./scripts/compliance/full_scan.sh - name: Upload Report uses: actions/upload-artifact@v3 with: name: compliance-report path: reports/compliance_report.html
undefined
name: Weekly Compliance Scan
on: schedule: - cron: '0 9 * * 1' # Monday 9am
jobs: scan: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Full Compliance Scan run: ./scripts/compliance/full_scan.sh - name: Upload Report uses: actions/upload-artifact@v3 with: name: compliance-report path: reports/compliance_report.html
undefined

Integration Points

集成点

With Repository Sync

与代码库同步集成

bash
undefined
bash
undefined

After pulling, verify compliance

After pulling, verify compliance

./scripts/repository_sync pull all ./scripts/compliance/verify_compliance.sh
undefined
./scripts/repository_sync pull all ./scripts/compliance/verify_compliance.sh
undefined

With AI Agents

与AI Agent集成

AI agents should:
  1. Check compliance status before making changes
  2. Maintain compliance during modifications
  3. Report compliance issues found during work
  4. Follow guidelines in CLAUDE.md
AI Agent应:
  1. 进行修改前检查合规状态
  2. 在修改过程中保持合规
  3. 报告工作中发现的合规问题
  4. 遵循CLAUDE.md中的指南

Related Skills

相关Skill

  • repo-sync - Repository management
  • sparc-workflow - Development methodology
  • workspace-cli - Unified CLI interface
  • repo-sync - 代码库管理
  • sparc-workflow - 开发方法论
  • workspace-cli - 统一CLI界面

Best Practices

最佳实践

For Repository Maintainers

代码库维护者

  1. Run compliance checks before commits
  2. Fix issues immediately - don't accumulate debt
  3. Use pre-commit hooks for automatic enforcement
  4. Review compliance reports weekly
  1. 提交前运行合规检查
  2. 立即修复问题 - 不要积累技术债务
  3. 使用预提交钩子自动强制执行标准
  4. 每周查看合规报告

For AI Agents

AI Agent

  1. Always check compliance status before making changes
  2. Maintain compliance during modifications
  3. Report compliance issues found during work
  4. Follow guidelines in CLAUDE.md and referenced docs
  1. 进行修改前务必检查合规状态
  2. 在修改过程中保持合规
  3. 报告工作中发现的合规问题
  4. 遵循CLAUDE.md及参考文档中的指南

For the Team

团队层面

  1. Standardize across repos using propagation tools
  2. Monitor compliance trends over time
  3. Address root causes not just symptoms
  4. Document exceptions in decisions.md
  1. 使用推广工具在所有代码库中标准化
  2. 随时间监控合规趋势
  3. 解决根本原因而非仅处理表面问题
  4. 在decisions.md中记录例外情况

References

参考文档

  • AI Agent Guidelines
  • Development Workflow
  • File Organization Standards
  • Testing Standards
  • Logging Standards
  • HTML Reporting Standards

  • AI Agent指南
  • 开发工作流
  • 文件组织标准
  • 测试标准
  • 日志标准
  • HTML报告标准

Version History

版本历史

  • 1.1.0 (2026-01-02): Upgraded to SKILL_TEMPLATE_v2 format - added Quick Start, When to Use, Execution Checklist, Error Handling consolidation, Metrics, Integration Points
  • 1.0.0 (2024-10-15): Initial release with compliance verification, propagation tools, git hooks, CI/CD integration, troubleshooting
  • 1.1.0 (2026-01-02): 升级为SKILL_TEMPLATE_v2格式 - 新增快速开始、适用场景、执行检查清单、错误处理整合、指标、集成点
  • 1.0.0 (2024-10-15): 初始版本,包含合规验证、推广工具、Git钩子、CI/CD集成、故障排除