一键导入
code-review-and-audit
Systematic code review and audit practices including automated checks, security audits, compliance verification, and review checklists.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Systematic code review and audit practices including automated checks, security audits, compliance verification, and review checklists.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Build production-ready AI agents with Microsoft Foundry and Agent Framework. Covers agent architecture, model selection, orchestration, tracing, and evaluation.
Design robust REST APIs with proper versioning, pagination, error handling, rate limiting, and OpenAPI documentation.
Structure projects for maintainability and scalability with clean architecture, separation of concerns, and consistent project layouts.
Manage application configuration with environment variables, Azure Key Vault, feature flags, and environment-specific settings.
Fundamental coding principles for production development including SOLID, DRY, KISS, and common design patterns with C# examples.
Efficient database operations with PostgreSQL, Entity Framework Core, migrations, indexing strategies, transactions, and connection pooling.
| name | code-review-and-audit |
| description | Systematic code review and audit practices including automated checks, security audits, compliance verification, and review checklists. |
Purpose: Systematic validation of implementations against production guardrails.
Focus: Self-review automation, manual review checklists, security audits, compliance verification.
Run these before requesting human review or deploying.
# Run all automated checks
./scripts/pre-review-check.sh
# Or manually:
dotnet format --verify-no-changes
dotnet build --no-incremental
dotnet test --collect:"XPlat Code Coverage"
dotnet list package --vulnerable --include-transitive
# scripts/Pre-Review-Check.ps1
Write-Host "=== Pre-Review Automated Checks ===" -ForegroundColor Cyan
# 1. Format Check
Write-Host "`n[1/6] Checking code formatting..." -ForegroundColor Yellow
dotnet format --verify-no-changes
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Format issues found. Run 'dotnet format'" -ForegroundColor Red
exit 1
}
# 2. Build
Write-Host "`n[2/6] Building solution..." -ForegroundColor Yellow
dotnet build --no-incremental
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Build failed" -ForegroundColor Red
exit 1
}
# 3. Tests
Write-Host "`n[3/6] Running tests..." -ForegroundColor Yellow
dotnet test --no-build --verbosity minimal --collect:"XPlat Code Coverage"
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Tests failed" -ForegroundColor Red
exit 1
}
# 4. Coverage Check (requires ReportGenerator)
Write-Host "`n[4/6] Checking code coverage..." -ForegroundColor Yellow
$coverageFile = Get-ChildItem -Path "TestResults" -Filter "coverage.cobertura.xml" -Recurse | Select-Object -First 1
if ($coverageFile) {
$xml = [xml](Get-Content $coverageFile.FullName)
$coverage = [math]::Round([decimal]$xml.coverage.'line-rate' * 100, 2)
Write-Host "Coverage: $coverage%" -ForegroundColor Cyan
if ($coverage -lt 80) {
Write-Host "⚠️ Coverage below 80% threshold" -ForegroundColor Yellow
}
}
# 5. Security Vulnerabilities
Write-Host "`n[5/6] Checking for vulnerable packages..." -ForegroundColor Yellow
dotnet list package --vulnerable --include-transitive
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Vulnerable packages found" -ForegroundColor Red
exit 1
}
# 6. Static Analysis (if SonarScanner installed)
if (Get-Command "dotnet-sonarscanner" -ErrorAction SilentlyContinue) {
Write-Host "`n[6/6] Running SonarQube analysis..." -ForegroundColor Yellow
dotnet sonarscanner begin /k:"project-key"
dotnet build
dotnet sonarscanner end
}
Write-Host "`n✅ All automated checks passed!" -ForegroundColor Green
Exception)# 1. Dependency Vulnerabilities
dotnet list package --vulnerable --include-transitive
# 2. .NET Security Analyzers
dotnet add package Microsoft.CodeAnalysis.NetAnalyzers
dotnet build /p:EnableNETAnalyzers=true /p:AnalysisLevel=latest
# 3. SonarQube (if configured)
dotnet sonarscanner begin /k:"project-key" /d:sonar.host.url="http://localhost:9000"
dotnet build
dotnet sonarscanner end
# 4. OWASP ZAP (for running APIs)
docker run -t owasp/zap2docker-stable zap-baseline.py -t https://api.myapp.com
# 5. GitHub Advanced Security (in CI/CD)
# Automatic in GitHub Actions with code scanning enabled
# Search for security anti-patterns
grep -r "AllowAnyOrigin" . --include=*.cs
grep -r "SELECT.*\+.*WHERE" . --include=*.cs # SQL concatenation
grep -r "password.*=.*\"" . --include=*.cs # Hardcoded passwords
grep -r "api[_-]?key.*=.*\"" . --include=*.cs # Hardcoded API keys
grep -r "\.Wait()" . --include=*.cs # Blocking async calls
PowerShell Security Scan:
# Find security issues
Write-Host "Scanning for security anti-patterns..." -ForegroundColor Yellow
$patterns = @{
"Hardcoded Secrets" = 'password|apikey|secret|connectionstring.*=.*"[^"]+"'
"SQL Injection Risk" = 'SELECT.*\+|ExecuteSqlRaw.*\+'
"CORS Issues" = 'AllowAnyOrigin|AllowAnyHeader|AllowAnyMethod'
"Blocking Async" = '\.Wait\(\)|\.Result[^a-zA-Z]'
}
foreach ($pattern in $patterns.GetEnumerator()) {
Write-Host "`nChecking: $($pattern.Key)" -ForegroundColor Cyan
Get-ChildItem -Recurse -Include *.cs | Select-String -Pattern $pattern.Value
}
Development
Testing & Quality
Security
Operations
| Tool | Purpose | Command |
|---|---|---|
| Roslyn Analyzers | .NET code analysis | dotnet build /p:AnalysisLevel=latest |
| SonarQube | Code quality, security | dotnet sonarscanner begin/end |
| StyleCop | C# style rules | dotnet add package StyleCop.Analyzers |
| Security Code Scan | Security vulnerabilities | dotnet add package SecurityCodeScan.VS2019 |
# Generate coverage report
dotnet test --collect:"XPlat Code Coverage"
# Install ReportGenerator
dotnet tool install -g dotnet-reportgenerator-globaltool
# Generate HTML report
reportgenerator \
-reports:"**/coverage.cobertura.xml" \
-targetdir:"coveragereport" \
-reporttypes:Html
# Open report
start coveragereport/index.html # Windows
open coveragereport/index.html # macOS
GitHub Actions (.github/workflows/review.yml):
name: Code Review Checks
on: [pull_request]
jobs:
review:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Restore dependencies
run: dotnet restore
- name: Format check
run: dotnet format --verify-no-changes
- name: Build
run: dotnet build --no-restore
- name: Test with coverage
run: dotnet test --no-build --collect:"XPlat Code Coverage"
- name: Security scan
run: dotnet list package --vulnerable --include-transitive
- name: Upload coverage
uses: codecov/codecov-action@v3
# Run automated checks
./scripts/pre-review-check.sh
# Review own changes
git diff main...HEAD
# Check file changes
git diff --name-only main...HEAD
# Review commit messages
git log main..HEAD --oneline
# Create PR with template
gh pr create --title "feat(auth): Add OAuth integration" \
--body "$(cat .github/PULL_REQUEST_TEMPLATE.md)"
# Make changes
git add .
git commit -m "fix: Address review feedback"
# Update PR
git push origin feature-branch
# Re-run checks
./scripts/pre-review-check.sh
Pre-Review Command:
dotnet format --verify-no-changes && \
dotnet build && \
dotnet test --collect:"XPlat Code Coverage" && \
dotnet list package --vulnerable --include-transitive
Security Scan:
grep -rn "password.*=.*\"" . --include=*.cs
dotnet list package --vulnerable
Coverage Check:
dotnet test --collect:"XPlat Code Coverage"
reportgenerator -reports:"**/coverage.cobertura.xml" -targetdir:"coverage"
See Also: AGENTS.md • 02-testing.md • 04-security.md • 16-remote-git-operations.md
Last Updated: January 13, 2026