用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/aibot88/sec_skill_store --skill license-check命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | license-check |
| description | License compliance checking and conflict detection |
| disable-model-invocation | true |
I'll analyze your project dependencies for license compliance, detect conflicts, and ensure legal compatibility.
Arguments: $ARGUMENTS - focus area (commercial, gpl, conflicts) or specific packages
Core Principles:
Target: 70% reduction (2,000-3,000 → 600-900 tokens)
1. Bash-Based License Detection Tools (Primary Strategy)
license-checker npm package (external tool, minimal Claude tokens)pip-licenses for Python (external tool output only)cargo-license for Rust (external tool)composer licenses for PHP (native command)jq/grep (no Claude analysis)2. Dependency List Caching (Aggressive Caching)
# Cache key from package file checksums
CACHE_KEY=$(md5sum package.json package-lock.json 2>/dev/null | md5sum | cut -d' ' -f1)
CACHE_FILE=".claude/cache/license-check/licenses-${CACHE_KEY}.json"
if [ -f "$CACHE_FILE" ]; then
# Use cached license data (0 tokens)
LICENSES="$CACHE_FILE"
else
# Generate fresh license scan
license-checker --json --production > "$CACHE_FILE"
fi
.claude/cache/license-check/licenses-{checksum}.json3. Template-Based License Compatibility Rules (No Analysis)
# Hardcoded compatibility matrix (no LLM needed)
declare -A COMPATIBILITY=(
["MIT,GPL-2.0"]="CONFLICT"
["MIT,LGPL-2.1"]="OK"
["Apache-2.0,GPL-2.0"]="CONFLICT"
["GPL-3.0,MIT"]="OK"
# ... comprehensive matrix
)
check_conflict() {
local key="${PROJECT_LICENSE},${DEP_LICENSE}"
echo "${COMPATIBILITY[$key]:-UNKNOWN}"
}
4. Early Exit If All Licenses Compatible (Conditional Execution)
# Quick scan for problematic licenses
if ! grep -qE "GPL-[23]\.0|AGPL|Unlicense|WTFPL" licenses.json; then
echo "✓ All dependencies use permissive licenses (MIT, Apache, BSD, ISC)"
echo "✓ No license conflicts detected"
exit 0 # Skip detailed analysis
fi
# Only continue if issues found
5. Progressive Disclosure (Conflicts → Warnings → Info)
# Show in priority order, exit early
show_conflicts() # Critical issues (GPL conflicts)
[ $? -eq 0 ] || exit 1
show_warnings() # Weak copyleft (LGPL, MPL)
show_info() # License distribution, recommendations
6. Focus Area Flags (Targeted Analysis)
# Parse focus area from $ARGUMENTS
case "$ARGUMENTS" in
*commercial*|*proprietary*)
check_commercial_compatibility # Only check GPL/AGPL
;;
*gpl*)
find_gpl_licenses # Only show GPL packages
;;
*conflicts*)
check_license_conflicts # Only show conflicts
;;
*copyleft*)
find_copyleft_licenses # LGPL + GPL
;;
esac
7. Git Diff for Changed Dependencies Only (Default Behavior)
# Default: only check new/changed dependencies
if [ -z "$ARGUMENTS" ] || [[ "$ARGUMENTS" != *"all"* ]]; then
# Get changed dependencies from git diff
CHANGED_PACKAGES=$(git diff HEAD package.json | grep -E '^\+.*"[^"]+":' | cut -d'"' -f2)
if [ -z "$CHANGED_PACKAGES" ]; then
echo "✓ No dependency changes detected"
echo "✓ License compliance unchanged"
exit 0
fi
# Only check changed packages
license-checker --packages "$CHANGED_PACKAGES"
else
# Full audit if 'all' specified
license-checker --production
fi
Optimized Flow:
Total: 600-900 tokens (optimized) vs. 2,000-3,000 (unoptimized)
Quick check (changed deps only, cache hit):
/license-check
# 400-600 tokens (90% cache hit rate)
Full audit (all deps, no cache):
/license-check all
# 1,200-1,500 tokens (comprehensive scan)
Commercial compatibility check:
/license-check --commercial
# 300-500 tokens (GPL/AGPL only)
Conflicts only:
/license-check --conflicts
# 200-400 tokens (incompatible licenses only)
Find copyleft licenses:
/license-check --copyleft
# 300-500 tokens (GPL + LGPL + MPL)
Generate compliance report:
/license-check --report
# 1,500-2,000 tokens (full documentation)
Caches Shared With:
/dependency-audit - Reuses dependency license data/security-scan - Shares vulnerability + license context/ci-setup - Reuses license compliance rulesCommon Cache Location:
.claude/cache/license-check/
├── licenses-{checksum}.json # License scan results
├── compatibility-matrix.json # Compatibility rules
├── known-conflicts-{checksum}.json # Detected conflicts
└── last-scan-{checksum}.txt # Scan timestamp
Cache Invalidation:
rm -rf .claude/cache/license-check/Best Case (no changes, cache hit):
Typical Case (changed deps, cache hit):
Worst Case (full audit, no cache):
Conflict Case (issues found):
#!/bin/bash
# Detect project licenses and dependency managers
detect_license_info() {
echo "=== License Detection ==="
echo ""
# Check project license
if [ -f "LICENSE" ] || [ -f "LICENSE.md" ] || [ -f "LICENSE.txt" ]; then
echo "✓ Project license file found"
PROJECT_LICENSE=$(head -5 LICENSE* | grep -i -o "MIT\|Apache\|GPL\|BSD\|ISC" | head -1)
if [ -n "$PROJECT_LICENSE" ]; then
echo " Project license: $PROJECT_LICENSE"
fi
else
echo "⚠️ No project license file found"
fi
# Check package.json license field
if [ -f "package.json" ]; then
PKG_LICENSE=$(grep -o '"license"[[:space:]]*:[[:space:]]*"[^"]*"' package.json | cut -d'"' -f4)
if [ -n "$PKG_LICENSE" ]; then
echo " package.json license: $PKG_LICENSE"
fi
fi
echo ""
MANAGERS=()
[ -f ];
MANAGERS+=()
[ -f ] || [ -f ] || [ -f ];
MANAGERS+=()
[ -f ];
MANAGERS+=()
[ -f ];
MANAGERS+=()
[ -f ];
MANAGERS+=()
[ -f ];
MANAGERS+=()
}
detect_license_info
#!/bin/bash
# Comprehensive Node.js license checking
check_npm_licenses() {
echo "=== Node.js License Analysis ==="
echo ""
# Install license-checker if not available
if ! command -v license-checker &> /dev/null; then
echo "Installing license-checker..."
npm install -g license-checker
fi
# Generate license report
echo "Scanning dependencies..."
license-checker --json --production > .licenses.json 2>/dev/null
if [ ! -f ".licenses.json" ]; then
echo "❌ Failed to generate license report"
exit 1
fi
# License categories
PERMISSIVE_LICENSES=("MIT" "Apache-2.0" "BSD-2-Clause" "BSD-3-Clause" "ISC" "0BSD")
WEAK_COPYLEFT=("LGPL-2.1" "LGPL-3.0" "MPL-2.0")
STRONG_COPYLEFT=("GPL-2.0" "GPL-3.0" "AGPL-3.0")
PROBLEMATIC=("CC-BY-NC" "Commons Clause" "Unlicense" "WTFPL")
echo ""
echo "=== License Summary ==="
echo
total_packages=$( .licenses.json | grep -c )
.licenses.json | grep -o | | -c | -rn | count license;
license_name=$( | -d -f4)
}
check_npm_licenses
#!/bin/bash
# Detect license compliance issues
detect_license_issues() {
echo "=== License Compliance Issues ==="
echo ""
ISSUES_FOUND=false
# Check for strong copyleft licenses
echo "Checking for copyleft licenses..."
COPYLEFT_PKGS=$(cat .licenses.json | grep -E "GPL-[23]\.0|AGPL" | grep -o '"[^"]*@[^"]*":')
if [ -n "$COPYLEFT_PKGS" ]; then
echo "❌ STRONG COPYLEFT licenses found (may require source disclosure):"
echo "$COPYLEFT_PKGS" | sed 's/"//g' | sed 's/://g' | sed 's/^/ - /'
echo ""
echo "⚠️ WARNING: GPL/AGPL licenses may require:"
echo " - Source code disclosure"
echo " - Same license for derivative works"
echo " - Patent grants"
echo ""
ISSUES_FOUND=true
else
echo "✓ No strong copyleft licenses detected"
fi
echo ""
# Check for weak copyleft licenses
echo
WEAK_COPYLEFT_PKGS=$( .licenses.json | grep -E | grep -o )
[ -n ];
| sed | sed | sed
CUSTOM_LICENSES=$( .licenses.json | grep -o | grep -v -E | grep -v )
[ -n ];
| sed | sed | -u | sed
ISSUES_FOUND=
UNLICENSED=$( .licenses.json | grep | grep -o )
[ -n ];
| sed | sed | sed
ISSUES_FOUND=
[ = ];
}
detect_license_issues
#!/bin/bash
# Python license checking
check_python_licenses() {
echo "=== Python License Analysis ==="
echo ""
# Install pip-licenses if not available
if ! command -v pip-licenses &> /dev/null; then
echo "Installing pip-licenses..."
pip install pip-licenses
fi
# Generate license report
echo "Scanning Python dependencies..."
pip-licenses --format=json --with-urls > .pip-licenses.json 2>/dev/null
if [ ! -f ".pip-licenses.json" ]; then
echo "❌ Failed to generate license report"
exit 1
fi
echo ""
echo "=== License Summary ==="
echo ""
# Count packages
total_packages=$(cat .pip-licenses.json | grep -c '"Name":')
echo "Total packages: $total_packages"
echo ""
# License breakdown
echo "License breakdown:"
cat .pip-licenses.json | grep -o '"License":"[^"]*"' | sort | uniq -c | sort -rn | count license;
license_name=$( | -d -f4)
GPL_PKGS=$( .pip-licenses.json | grep -B 1 | grep | -d -f4)
[ -n ];
| sed
-f .pip-licenses.json
}
check_python_licenses
#!/bin/bash
# Detect incompatible license combinations
check_license_conflicts() {
echo "=== License Conflict Detection ==="
echo ""
PROJECT_LICENSE="${1:-MIT}" # Default to MIT if not specified
echo "Project license: $PROJECT_LICENSE"
echo ""
# Define compatibility rules
check_compatibility() {
local project_lic="$1"
local dep_lic="$2"
case "$project_lic" in
MIT|Apache-2.0|BSD-*|ISC)
# Permissive licenses are compatible with most licenses
case "$dep_lic" in
*GPL*|*AGPL*)
echo "CONFLICT"
;;
*)
echo "OK"
;;
esac
;;
LGPL-*)
# LGPL can use MIT/Apache but not GPL
case "$dep_lic" in
GPL-*|AGPL-*)
echo "CONFLICT"
;;
*)
;;
;;
GPL-*|AGPL-*)
;;
*)
;;
}
CONFLICTS_FOUND=
[ -f ];
.licenses.json | grep -o | IFS=: package info;
pkg_name=$( | sed )
dep_license=$( | grep -o | -d -f4)
compatibility=$(check_compatibility )
[ = ];
CONFLICTS_FOUND=
[ = ];
}
check_license_conflicts
#!/bin/bash
# Generate comprehensive license compliance report
generate_compliance_report() {
local output="${1:-LICENSE_COMPLIANCE_REPORT.md}"
echo "=== Generating Compliance Report ==="
echo ""
cat > "$output" << EOF
# License Compliance Report
**Generated:** $(date +"%Y-%m-%d %H:%M:%S")
**Project:** $(basename $(pwd))
## Executive Summary
EOF
# Add project license
if [ -f "LICENSE" ]; then
echo "**Project License:** $(head -5 LICENSE | grep -i -o "MIT\|Apache\|GPL\|BSD\|ISC" | head -1)" >> "$output"
fi
echo "" >> "$output"
# Add statistics
if [ -f ".licenses.json" ]; then
total=$(cat .licenses.json | grep -c '"licenses":')
echo "**Total Dependencies:** $total" >> "$output"
echo "" >> "$output"
# License breakdown
echo "## License Distribution" >> ""
>>
>>
>>
.licenses.json | grep -o | | -c | -rn | count license;
license_name=$( | -d -f4)
>>
>>
>> <<
>>
>>
[ -f ];
>>
>>
.licenses.json | python3 -c >> 2>/dev/null
>>
>> <<
}
generate_compliance_report
#!/bin/bash
# Generate THIRD_PARTY_LICENSES file
generate_third_party_licenses() {
local output="${1:-THIRD_PARTY_LICENSES.txt}"
echo "=== Generating Third-Party Licenses ==="
echo ""
cat > "$output" << EOF
THIRD-PARTY SOFTWARE LICENSES
This file contains the licenses for third-party software used in this project.
Generated: $(date +"%Y-%m-%d")
================================================================================
EOF
# Node.js dependencies
if [ -f "package.json" ]; then
echo "Node.js Dependencies" >> "$output"
echo "===================" >> "$output"
echo "" >> "$output"
license-checker --plainVertical >> "$output" 2>/dev/null
echo "" >> "$output"
fi
# Python dependencies
if [ -f "requirements.txt" ]; then
echo "Python Dependencies" >> "$output"
echo "==================" >>
>>
pip-licenses --format=plain-vertical >> 2>/dev/null
>>
}
generate_third_party_licenses
#!/bin/bash
# Add license checking to CI/CD
add_license_check_to_ci() {
echo "=== Adding License Check to CI/CD ==="
echo ""
# GitHub Actions workflow
if [ -d ".github/workflows" ]; then
cat > .github/workflows/license-check.yml << 'EOF'
name: License Compliance Check
on:
pull_request:
branches: [main, master]
push:
branches: [main, master]
schedule:
- cron: '0 0 * * 0' # Weekly on Sunday
jobs:
license-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install dependencies
run: npm ci
- name: Install license-checker
run: npm install -g license-checker
- name: Check licenses
run: |
license-checker --production --failOn "GPL-2.0;GPL-3.0;AGPL-3.0"
- name: Generate license report
if: always()
run: |
license-checker --json --production > licenses.json
- name: Upload license report
if: always()
uses: actions/upload-artifact@v4
with:
name: license-report
path: licenses.json
EOF
echo "✓ GitHub Actions workflow created"
fi
# Pre-commit hook
if [ -d ".git/hooks" ]; then
cat > .git/hooks/pre-commit-license-check << 'EOF'
#!/bin/bash
# Pre-commit license compliance check
echo "Checking license compliance..."
if [ -f ];
license-checker --production --failOn || {
1
}
EOF
+x .git/hooks/pre-commit-license-check
}
add_license_check_to_ci
Full compliance check:
/license-check
/license-check --report
Specific focus:
/license-check --commercial # Check for commercial compatibility
/license-check --gpl # Find GPL licenses
/license-check --conflicts # Detect conflicts
Generate documentation:
/license-check --generate-report
/license-check --third-party-licenses
License Management:
Red Flags:
/dependency-audit - Combined security and license audit/ci-setup - Add license checks to CI pipeline/docs - Generate compliance documentationImportant: I will NEVER:
All license analysis will be thorough, accurate, and well-documented. This is informational only - consult legal counsel for compliance decisions.
Credits: Based on license-checker, pip-licenses, and OSI license compatibility guidelines.