compliance-check
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCompliance Check Skill
合规检查Skill
Verify and enforce coding standards, AI guidelines, and workspace compliance across all 26+ repositories.
跨所有26+代码库验证并执行编码标准、AI指南及工作区合规要求。
Quick Start
快速开始
bash
undefinedbash
undefinedQuick 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
undefinedWhen 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 before implementation
user_prompt.md - 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:
- - Source code
/src - - Test files
/tests - - Documentation
/docs - - Configuration
/config - - Utility scripts
/scripts - - Data files
/data - - Generated reports
/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.shbash
./scripts/compliance/verify_compliance.shCheck Specific Repository
检查指定代码库
bash
./scripts/compliance/verify_compliance.sh --repo=digitalmodelbash
./scripts/compliance/verify_compliance.sh --repo=digitalmodelCheck Specific Area
检查指定领域
bash
./scripts/compliance/verify_compliance.sh --area=testing
./scripts/compliance/verify_compliance.sh --area=logging
./scripts/compliance/verify_compliance.sh --area=file-orgbash
./scripts/compliance/verify_compliance.sh --area=testing
./scripts/compliance/verify_compliance.sh --area=logging
./scripts/compliance/verify_compliance.sh --area=file-orgExecution 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
undefinedmarkdown
undefinedStructure 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
undefinedTesting Standards
测试标准
markdown
undefinedmarkdown
undefinedTesting 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
undefinedLogging Standards
日志标准
markdown
undefinedmarkdown
undefinedLogging 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
undefinedHTML Reporting
HTML报告标准
markdown
undefinedmarkdown
undefinedReporting 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
undefinedAI Guidelines
AI指南
markdown
undefinedmarkdown
undefinedAI 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
undefinedPropagation Tools
推广工具
Propagate CLAUDE.md Configuration
同步CLAUDE.md配置
bash
./scripts/compliance/propagate_claude_config.pySyncs CLAUDE.md template to all repositories.
bash
./scripts/compliance/propagate_claude_config.py将CLAUDE.md模板同步到所有代码库。
Propagate AI Guidelines
推广AI指南
bash
./scripts/compliance/propagate_guidelines.shUpdates 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.shEnsures 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.shbash
./scripts/compliance/install_compliance_hooks.shPre-commit Hook Checks
预提交钩子检查
The pre-commit hook verifies:
- File organization: No files in wrong locations
- Test coverage: Coverage report exists and meets threshold
- Linting: No syntax errors
- YAML validation: Valid YAML configuration
- Documentation: Required docs exist
预提交钩子会验证:
- 文件组织:无文件存放在错误位置
- 测试覆盖率:覆盖率报告存在且符合阈值
- 代码检查:无语法错误
- YAML验证:YAML配置有效
- 文档:必要文档已存在
Hook Configuration
钩子配置
bash
undefinedbash
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!"
undefinedif 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!"
undefinedError Handling
错误处理
Common Compliance Failures
常见合规失败情况
| Issue | Cause | Resolution |
|---|---|---|
| Structure violation | Files in wrong directory | Move files to correct location |
| Low test coverage | Insufficient tests | Add unit/integration tests |
| Static images | matplotlib exports | Convert to Plotly/Bokeh HTML |
| Missing CLAUDE.md | New repo setup | Run propagation script |
| Hook not running | Permission issue | |
| 问题 | 原因 | 解决方法 |
|---|---|---|
| 结构违规 | 文件存放在错误目录 | 将文件移动到正确位置 |
| 测试覆盖率低 | 测试用例不足 | 添加单元/集成测试 |
| 静态图片 | 使用matplotlib导出 | 转换为Plotly/Bokeh HTML |
| 缺少CLAUDE.md | 新代码库未配置 | 运行推广脚本 |
| 钩子未运行 | 权限问题 | |
Fixing Non-Compliance
修复不合规问题
Structure Issues
结构问题
bash
undefinedbash
undefinedCreate 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/
undefinedgit mv root_file.py src/
git mv old_tests.py tests/unit/
undefinedTesting Issues
测试问题
bash
undefinedbash
undefinedInstall 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
undefinedpytest --cov=src --cov-report=html --cov-fail-under=80
undefinedLogging Issues
日志问题
python
undefinedpython
undefinedAdd 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()
]
)
undefinedimport 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()
]
)
undefinedReporting Issues
报告问题
python
undefinedpython
undefinedReplace 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')
undefinedimport plotly.express as px
fig = px.line(df, x='x', y='y')
fig.write_html('reports/chart.html')
undefinedTroubleshooting
故障排除
Hook Not Running
钩子未运行
bash
undefinedbash
undefinedMake 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
undefinedls -la .git/hooks/pre-commit
undefinedFalse Positives
误报
bash
undefinedbash
undefinedAdd 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"
undefinedexceptions:
- path: legacy/old_module.py reason: "Legacy code, scheduled for refactoring in Q2"
undefinedCoverage Not Detected
覆盖率未被检测到
bash
undefinedbash
undefinedEnsure 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/*"]
undefinedMetrics & 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.htmlbash
./scripts/compliance/generate_report.sh > reports/compliance_report.htmlReport 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
undefinedyaml
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.shundefinedname: 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.shundefinedScheduled Compliance Scan
定期合规扫描
yaml
undefinedyaml
undefinedRun 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
undefinedname: 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
undefinedIntegration Points
集成点
With Repository Sync
与代码库同步集成
bash
undefinedbash
undefinedAfter 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
undefinedWith AI Agents
与AI Agent集成
AI agents should:
- Check compliance status before making changes
- Maintain compliance during modifications
- Report compliance issues found during work
- Follow guidelines in CLAUDE.md
AI Agent应:
- 进行修改前检查合规状态
- 在修改过程中保持合规
- 报告工作中发现的合规问题
- 遵循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
代码库维护者
- Run compliance checks before commits
- Fix issues immediately - don't accumulate debt
- Use pre-commit hooks for automatic enforcement
- Review compliance reports weekly
- 提交前运行合规检查
- 立即修复问题 - 不要积累技术债务
- 使用预提交钩子自动强制执行标准
- 每周查看合规报告
For AI Agents
AI Agent
- Always check compliance status before making changes
- Maintain compliance during modifications
- Report compliance issues found during work
- Follow guidelines in CLAUDE.md and referenced docs
- 进行修改前务必检查合规状态
- 在修改过程中保持合规
- 报告工作中发现的合规问题
- 遵循CLAUDE.md及参考文档中的指南
For the Team
团队层面
- Standardize across repos using propagation tools
- Monitor compliance trends over time
- Address root causes not just symptoms
- Document exceptions in decisions.md
- 使用推广工具在所有代码库中标准化
- 随时间监控合规趋势
- 解决根本原因而非仅处理表面问题
- 在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集成、故障排除