用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/diegosouzapw/awesome-omni-skill --skill api-validate命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | api-validate |
| description | API contract validation and breaking change detection |
| disable-model-invocation | false |
I'll analyze your API contracts for breaking changes, compatibility issues, and schema validation.
Arguments: $ARGUMENTS - API spec paths, comparison targets, or validation focus
Target Reduction: 50% (3,000-5,000 → 1,000-2,500 tokens)
This skill uses aggressive optimization through checksum-based caching, schema diffing, and early exit patterns to minimize token usage while providing comprehensive API contract validation.
OpenAPI Schema Caching (60% reduction)
/api-test-generate, /api-docs-generateSESSION-STATE + CHECKSUM-VALIDATIONBreaking Change Detection with Pattern Matching (70% reduction)
TEMPLATE-RULES + PROGRESSIVE-DISCLOSUREContract Diff Comparison (80% reduction)
DIFF-ONLY + INCREMENTALEndpoint Version Comparison (50% reduction)
BATCH-OPERATIONS + EARLY-EXITGit Diff for Changed API Specs Only (90% reduction)
git diff to identify changed API spec filesGIT-DIFF-DEFAULT + EARLY-EXITTemplate-Based Validation Rules (75% reduction)
TEMPLATE-BASED + RULE-ENGINE| Mode | Scenario | Token Usage | Primary Optimization |
|---|---|---|---|
| Status Check | No changes detected | 200-500 | Git diff + Early exit (95% savings) |
| Baseline Validation | Compare against baseline | 1,000-2,000 | Schema diff + Caching (60% savings) |
| Create Baseline | Initial contract capture | 1,500-2,500 | Schema extraction + Caching (40% savings) |
| Version Compare | Compare specific versions | 2,000-3,000 | Endpoint comparison + Progressive disclosure (50% savings) |
| Full Analysis | Comprehensive validation | 2,000-2,500 | All patterns combined (50% savings) |
Session Files (Project Root):
api-validate/
├── baseline.json # Contract baseline with checksums
├── state.json # Validation state and metadata
├── plan.md # Validation plan and findings
└── endpoints.json # Cached endpoint schemas
Shared Cache (Claude Code Cache):
.claude/cache/api/
├── contracts.json # Shared contract cache
├── schemas/ # Parsed OpenAPI schemas
│ ├── {checksum}.json # Schema by file checksum
│ └── metadata.json # Schema metadata
└── validation-rules.json # Breaking change templates
Cache Strategy:
/api-test-generate, /api-docs-generate, /api-mockBest Case (No Changes):
Typical Case (Minor Changes):
Worst Case (Major API Redesign):
Early Exit Patterns:
# 1. Git diff check (saves 95% if no changes)
if ! git diff --name-only HEAD~1 | grep -E '\.(openapi|swagger)\.(json|yaml|yml)$'; then
echo "No API spec changes detected"
exit 0
fi
# 2. Checksum validation (saves 90% if specs unchanged)
CURRENT_CHECKSUM=$(find . -name "*.openapi.*" -o -name "swagger.*" | xargs md5sum | md5sum)
if [ "$CURRENT_CHECKSUM" = "$CACHED_CHECKSUM" ]; then
echo "API contracts unchanged since last validation"
exit 0
fi
# 3. Baseline comparison (saves 80% if no breaking changes)
if [ "$BREAKING_CHANGES" = "0" ]; then
echo "No breaking changes detected"
echo "Run with --verbose for full analysis"
exit 0
fi
Schema Diff Strategy:
# Compare schemas at JSON path level, not full files
jq --slurp '
.[0] as $baseline | .[1] as $current |
{
removed_endpoints: ($baseline.paths | keys) - ($current.paths | keys),
added_endpoints: ($current.paths | keys) - ($baseline.paths | keys),
changed_endpoints: [
($baseline.paths | keys | .[] | select(
$baseline.paths[.] != $current.paths[.]
))
]
}
' baseline.json current.json
Breaking Change Templates:
# Template-based breaking change detection
BREAKING_PATTERNS=(
"removed.*endpoint"
"removed.*field.*required"
"changed.*type"
"added.*required.*field"
"changed.*auth"
"removed.*version"
)
for pattern in "${BREAKING_PATTERNS[@]}"; do
if grep -q "$pattern" diff.json; then
echo "Breaking change detected: $pattern"
fi
done
For Maximum Token Efficiency:
Regular Baseline Updates:
# Create baseline after stable releases
claude "api-validate baseline"
Status Checks (Cheapest):
# Quick validation (200-500 tokens)
claude "api-validate status"
Incremental Validation:
# Compare against last baseline (1,000-2,000 tokens)
claude "api-validate"
Version Comparison (When Needed):
# Compare specific versions (2,000-3,000 tokens)
claude "api-validate compare v2.0 v3.0"
Cost Comparison:
| Frequency | Unoptimized | Optimized | Savings |
|---|---|---|---|
| Per PR validation | 4,000 tokens | 1,500 tokens | 62% |
| Daily status check | 3,000 tokens | 400 tokens | 87% |
| Release validation | 5,000 tokens | 2,500 tokens | 50% |
| Weekly Total | 24,000 tokens | 8,400 tokens | 65% |
This skill's optimizations complement:
/api-test-generate - Shares contract cache and schemas/api-docs-generate - Shares OpenAPI parsing results/api-mock - Shares endpoint schemas and validation rules/migration-generate - Uses breaking change detection patterns/schema-validate - Shares template-based validation approachI'll maintain API validation continuity across sessions:
Session Files (in current project directory):
api-validate/plan.md - Validation plan and findingsapi-validate/state.json - Session state and baseline contractsapi-validate/baseline.json - API contract baseline for comparisonIMPORTANT: Session files are stored in an api-validate folder in your current project root
Auto-Detection:
resume, baseline, compare, statusFor complex API ecosystems, I'll use extended thinking to identify subtle breaking changes:
When analyzing API contracts: - Backward compatibility implications of field removals - Type changes that break existing clients - Required field additions that need migration strategies - URL structure changes affecting routing - Authentication changes requiring client updates - Rate limiting changes affecting performance assumptionsOptimization: Check for Existing Baseline
# Check for existing baseline (95% savings if baseline exists and no changes)
BASELINE_FILE="api-validate/baseline.json"
if [ -f "$BASELINE_FILE" ]; then
echo "✓ Found existing API baseline"
# Quick checksum comparison with current API specs
CURRENT_CHECKSUM=$(find . -name "*.openapi.*" -o -name "swagger.*" -o -name "api-spec.*" | \
xargs md5sum 2>/dev/null | md5sum | cut -d' ' -f1)
BASELINE_CHECKSUM=$(jq -r '.checksum' "$BASELINE_FILE" 2>/dev/null)
if [ "$CURRENT_CHECKSUM" = "$BASELINE_CHECKSUM" ]; then
echo "✓ No API changes detected since last validation"
echo "API contract is stable"
exit 0 # Early exit, saves 95% tokens
fi
echo "Changes detected, analyzing differences..."
else
echo "No baseline found, creating initial baseline..."
fi
Optimization: Grep-Based API Spec Discovery
# Use Grep to find API specs efficiently (100 tokens vs 3,000+)
API_SPECS=$(Grep pattern="openapi|swagger|paths:|/api/" \
glob="**/*.{json,yaml,yml,ts,js}" \
output_mode="files_with_matches" \
head_limit=20)
if [ -z "$API_SPECS" ]; then
echo "No API specifications found"
echo "Looking for: OpenAPI, Swagger, API route definitions"
exit 0 # Early exit
fi
echo "Found API specifications:"
echo "$API_SPECS"
I'll analyze your API for:
Breaking Changes (Critical):
Non-Breaking Changes (Review):
Progressive Disclosure:
API VALIDATION RESULTS
Breaking Changes (3): REQUIRE IMMEDIATE ATTENTION
1. Removed field 'user.email' from GET /api/users (affects all clients)
2. Changed type of 'id' from string to number in POST /api/orders (incompatible)
3. Removed endpoint DELETE /api/legacy (used by mobile app v1.x)
Non-Breaking Changes (5): Review recommended
- Added optional field 'user.avatar' to GET /api/users
- Added new endpoint POST /api/webhooks
- Deprecated 'user.username' (still functional, removed in v3.0)
No Changes (12 endpoints): Stable
Run with --verbose for full contract comparison
I'll perform detailed contract comparison:
Comparison Strategy:
Save Baseline:
# Save current contract as baseline
mkdir -p api-validate .claude/cache/api
cat > api-validate/baseline.json <<EOF
{
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"checksum": "$CURRENT_CHECKSUM",
"endpoints": $(echo "$API_SPECS" | wc -l),
"version": "detected_version",
"contracts": {}
}
EOF
cat > .claude/cache/api/contracts.json <<EOF
{
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"last_validation": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"baseline_checksum": "$CURRENT_CHECKSUM"
}
EOF
echo "✓ Baseline saved for future comparisons"
I'll identify and categorize all breaking changes:
Impact Assessment:
Based on validation findings:
Critical Actions:
Best Practices:
This ensures your API changes are safe and won't break existing integrations.