Install command
Provided
Generates a comprehensive test coverage report when the coding session ends.
Open the source and read safety notes before installing.
Source-backed facts for citing this resource, derived directly from the registry — also available as plain text for AI assistants.
Decision playbook
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
0
78
—
No baseline selected
No major trust-signal divergence detected in the current selection.
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Source provenance statusRequired
Marked as source-backed.
Metadata reviewed
Registry metadata indicates a reviewed listing.
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Trust level risk gateRequired
Trust level does not block evaluation.
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Package verification flag
No package verification flag provided.
Checksum metadata
No checksum provided for downloaded artifact.
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Baseline comparison available
No baseline peer selected yet.
Diverging trust signals identified
No major trust-signal divergence found.
Setup at a glance
Copy-ready — paste the snippet to get started.
Install command
Provided
Config snippet
Provided
Copy snippet
Provided
Prerequisites
None
Platforms
1 listed
Difficulty
0/100
Adoption plan
Current risk score 16/100. Use staged verification before broader rollout.
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Confirm metadata review state
Listing has review metadata.
Verify install payload
Install/config payload exists and can be inspected.
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Review privacy notesRequired
Privacy notes are present.
Verify package integrity metadata
No package verification/checksum metadata.
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Evidence readiness
Required evidence gates are covered (5/6 signals complete).
Source repository/provenance is listed.
Required in this preset
Review metadata is present.
Required in this preset
Safety notes are present.
Required in this preset
Privacy notes are present.
Optional in this preset
Package integrity metadata is missing.
Optional in this preset
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
5/6 steps complete with no blocking gaps for this preset.
triage
Source/provenance metadata is available.
triage
Review metadata is available.
verify
Safety notes are available.
verify
Privacy notes are available.
verify
Package integrity metadata is missing.
rollout
Install payload is available.
No required blockers for this timeline preset.
Safety & privacy surface
1 safety and 1 privacy notes across 2 risk areas. Review closely: credentials & tokens, permissions & scopes.
#!/bin/bash
echo "🧪 Test Coverage Final Report - Analyzing test coverage..."
echo "⏰ Session ended: $(date)"
echo "═══════════════════════════════════════════════════"
# Detect project type and testing framework
PROJECT_TYPE="unknown"
TEST_FRAMEWORK="unknown"
COVERAGE_AVAILABLE=false
echo "🔍 Detecting project type and testing framework..."
# JavaScript/Node.js project detection
if [ -f "package.json" ]; then
PROJECT_TYPE="node"
echo "📦 Node.js project detected"
# Detect testing framework
if grep -q '"jest"' package.json 2>/dev/null; then
TEST_FRAMEWORK="jest"
echo "🃏 Jest testing framework detected"
elif grep -q '"vitest"' package.json 2>/dev/null; then
TEST_FRAMEWORK="vitest"
echo "⚡ Vitest testing framework detected"
elif grep -q '"mocha"' package.json 2>/dev/null; then
TEST_FRAMEWORK="mocha"
echo "☕ Mocha testing framework detected"
elif grep -q '"karma"' package.json 2>/dev/null; then
TEST_FRAMEWORK="karma"
echo "🔄 Karma testing framework detected"
fi
# Python project detection
elif [ -f "requirements.txt" ] || [ -f "setup.py" ] || [ -f "pyproject.toml" ]; then
PROJECT_TYPE="python"
echo "🐍 Python project detected"
if command -v pytest >/dev/null 2>&1; then
TEST_FRAMEWORK="pytest"
echo "🧪 Pytest testing framework available"
elif python -c "import unittest" 2>/dev/null; then
TEST_FRAMEWORK="unittest"
echo "🔬 Unittest framework available"
fi
# Rust project detection
elif [ -f "Cargo.toml" ]; then
PROJECT_TYPE="rust"
TEST_FRAMEWORK="cargo"
echo "🦀 Rust project detected"
# Go project detection
elif [ -f "go.mod" ]; then
PROJECT_TYPE="go"
TEST_FRAMEWORK="go_test"
echo "🐹 Go project detected"
# Java project detection
elif [ -f "pom.xml" ] || [ -f "build.gradle" ]; then
PROJECT_TYPE="java"
echo "☕ Java project detected"
if [ -f "pom.xml" ]; then
TEST_FRAMEWORK="maven"
echo "🏗️ Maven build system detected"
else
TEST_FRAMEWORK="gradle"
echo "🐘 Gradle build system detected"
fi
fi
echo ""
echo "📊 Running coverage analysis for $PROJECT_TYPE project..."
# Run coverage based on project type
case "$PROJECT_TYPE" in
"node")
case "$TEST_FRAMEWORK" in
"jest")
echo "🃏 Running Jest with coverage..."
if npm test -- --coverage --silent 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Jest coverage completed successfully"
elif npm run test:coverage 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Coverage script completed successfully"
else
echo "⚠️ Jest coverage command failed - check test configuration"
fi
;;
"vitest")
echo "⚡ Running Vitest with coverage..."
if npx vitest run --coverage 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Vitest coverage completed successfully"
else
echo "⚠️ Vitest coverage command failed"
fi
;;
"mocha")
echo "☕ Running Mocha with nyc coverage..."
if npx nyc mocha 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Mocha coverage completed successfully"
else
echo "⚠️ Mocha coverage requires nyc - install with: npm install --save-dev nyc"
fi
;;
*)
echo "⚠️ No recognized testing framework - attempting generic npm test"
if npm test 2>/dev/null; then
echo "✅ Tests completed (coverage unknown)"
else
echo "❌ Tests failed or not configured"
fi
;;
esac
;;
"python")
case "$TEST_FRAMEWORK" in
"pytest")
echo "🧪 Running pytest with coverage..."
if pytest --cov=. --cov-report=term-missing --cov-report=html 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Pytest coverage completed successfully"
else
echo "⚠️ Pytest coverage failed - install with: pip install pytest-cov"
fi
;;
"unittest")
echo "🔬 Running unittest with coverage..."
if python -m coverage run -m unittest discover 2>/dev/null; then
python -m coverage report 2>/dev/null
COVERAGE_AVAILABLE=true
echo "✅ Unittest coverage completed successfully"
else
echo "⚠️ Coverage.py not available - install with: pip install coverage"
fi
;;
*)
echo "⚠️ No Python testing framework detected"
;;
esac
;;
"rust")
echo "🦀 Running Cargo test with coverage..."
if command -v cargo-tarpaulin >/dev/null 2>&1; then
if cargo tarpaulin --out Html 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Cargo tarpaulin coverage completed successfully"
else
echo "⚠️ Cargo tarpaulin failed"
fi
else
echo "⚠️ cargo-tarpaulin not installed - install with: cargo install cargo-tarpaulin"
echo "🔄 Running basic cargo test..."
cargo test 2>/dev/null && echo "✅ Tests completed (coverage unavailable)"
fi
;;
"go")
echo "🐹 Running Go test with coverage..."
if go test -coverprofile=coverage.out ./... 2>/dev/null; then
go tool cover -html=coverage.out -o coverage.html 2>/dev/null
COVERAGE_AVAILABLE=true
echo "✅ Go coverage completed successfully"
else
echo "⚠️ Go test coverage failed"
fi
;;
"java")
case "$TEST_FRAMEWORK" in
"maven")
echo "🏗️ Running Maven test with JaCoCo coverage..."
if mvn test jacoco:report 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Maven JaCoCo coverage completed successfully"
else
echo "⚠️ Maven coverage failed - ensure JaCoCo plugin is configured"
fi
;;
"gradle")
echo "🐘 Running Gradle test with JaCoCo coverage..."
if ./gradlew test jacocoTestReport 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Gradle JaCoCo coverage completed successfully"
else
echo "⚠️ Gradle coverage failed - ensure JaCoCo plugin is configured"
fi
;;
esac
;;
*)
echo "❓ Unknown project type - cannot generate coverage report"
echo "💡 Supported: Node.js, Python, Rust, Go, Java"
;;
esac
echo ""
echo "📈 Coverage Report Summary:"
echo "═══════════════════════════"
# Display coverage results based on available formats
if [ "$COVERAGE_AVAILABLE" = true ]; then
case "$PROJECT_TYPE" in
"node")
if [ -d "coverage" ]; then
echo "📊 Coverage files found in coverage/ directory"
# Try to parse coverage summary
if [ -f "coverage/coverage-summary.json" ]; then
echo "📋 Coverage Summary:"
cat coverage/coverage-summary.json 2>/dev/null | jq -r '.total | "Lines: " + (.lines.pct|tostring) + "% (" + (.lines.covered|tostring) + "/" + (.lines.total|tostring) + ")", "Branches: " + (.branches.pct|tostring) + "% (" + (.branches.covered|tostring) + "/" + (.branches.total|tostring) + ")", "Functions: " + (.functions.pct|tostring) + "% (" + (.functions.covered|tostring) + "/" + (.functions.total|tostring) + ")", "Statements: " + (.statements.pct|tostring) + "% (" + (.statements.covered|tostring) + "/" + (.statements.total|tostring) + ")"' 2>/dev/null || echo "Coverage summary parsing failed"
fi
echo "🌐 HTML Report: file://$(pwd)/coverage/index.html"
fi
;;
"python")
if [ -d "htmlcov" ]; then
echo "🌐 HTML Report: file://$(pwd)/htmlcov/index.html"
fi
;;
"rust")
if [ -f "tarpaulin-report.html" ]; then
echo "🌐 HTML Report: file://$(pwd)/tarpaulin-report.html"
fi
;;
"go")
if [ -f "coverage.html" ]; then
echo "🌐 HTML Report: file://$(pwd)/coverage.html"
fi
;;
"java")
if [ -d "target/site/jacoco" ]; then
echo "🌐 HTML Report: file://$(pwd)/target/site/jacoco/index.html"
elif [ -d "build/reports/jacoco/test/html" ]; then
echo "🌐 HTML Report: file://$(pwd)/build/reports/jacoco/test/html/index.html"
fi
;;
esac
else
echo "❌ No coverage data available"
echo "💡 Coverage Setup Tips:"
case "$PROJECT_TYPE" in
"node")
echo " • For Jest: Add 'collectCoverage: true' to jest.config.js"
echo " • For Vitest: Add 'coverage' provider to vite.config.js"
echo " • Run: npm install --save-dev @vitest/coverage-c8"
;;
"python")
echo " • Install: pip install pytest-cov coverage"
echo " • Run: pytest --cov=your_package"
;;
"rust")
echo " • Install: cargo install cargo-tarpaulin"
echo " • Run: cargo tarpaulin --out Html"
;;
"go")
echo " • Built-in: go test -coverprofile=coverage.out"
echo " • View: go tool cover -html=coverage.out"
;;
"java")
echo " • Add JaCoCo plugin to Maven/Gradle configuration"
echo " • Maven: mvn test jacoco:report"
echo " • Gradle: ./gradlew test jacocoTestReport"
;;
esac
fi
echo ""
echo "💡 Coverage Best Practices:"
echo " • Aim for 80%+ line coverage on critical code"
echo " • Focus on testing business logic and edge cases"
echo " • Use coverage to identify untested code, not as a quality metric"
echo " • Write meaningful tests, not just coverage-driven tests"
echo " • Exclude generated code and vendor dependencies"
echo " • Set up coverage thresholds in CI/CD pipelines"
echo ""
echo "🎯 Test coverage analysis complete!"
echo "═══════════════════════════════════════════════════"
exit 0{
"hooks": {
"stop": {
"script": "./.claude/hooks/test-coverage-final-report.sh",
"matchers": [
"*"
]
}
}
}.claude/settings.local.json~/.claude/settings.json.claude/settings.json{
"hooks": {
"stop": {
"script": "./.claude/hooks/test-coverage-final-report.sh",
"matchers": ["*"]
}
}
}
#!/bin/bash
echo "🧪 Test Coverage Final Report - Analyzing test coverage..."
echo "⏰ Session ended: $(date)"
echo "═══════════════════════════════════════════════════"
# Detect project type and testing framework
PROJECT_TYPE="unknown"
TEST_FRAMEWORK="unknown"
COVERAGE_AVAILABLE=false
echo "🔍 Detecting project type and testing framework..."
# JavaScript/Node.js project detection
if [ -f "package.json" ]; then
PROJECT_TYPE="node"
echo "📦 Node.js project detected"
# Detect testing framework
if grep -q '"jest"' package.json 2>/dev/null; then
TEST_FRAMEWORK="jest"
echo "🃏 Jest testing framework detected"
elif grep -q '"vitest"' package.json 2>/dev/null; then
TEST_FRAMEWORK="vitest"
echo "⚡ Vitest testing framework detected"
elif grep -q '"mocha"' package.json 2>/dev/null; then
TEST_FRAMEWORK="mocha"
echo "☕ Mocha testing framework detected"
elif grep -q '"karma"' package.json 2>/dev/null; then
TEST_FRAMEWORK="karma"
echo "🔄 Karma testing framework detected"
fi
# Python project detection
elif [ -f "requirements.txt" ] || [ -f "setup.py" ] || [ -f "pyproject.toml" ]; then
PROJECT_TYPE="python"
echo "🐍 Python project detected"
if command -v pytest >/dev/null 2>&1; then
TEST_FRAMEWORK="pytest"
echo "🧪 Pytest testing framework available"
elif python -c "import unittest" 2>/dev/null; then
TEST_FRAMEWORK="unittest"
echo "🔬 Unittest framework available"
fi
# Rust project detection
elif [ -f "Cargo.toml" ]; then
PROJECT_TYPE="rust"
TEST_FRAMEWORK="cargo"
echo "🦀 Rust project detected"
# Go project detection
elif [ -f "go.mod" ]; then
PROJECT_TYPE="go"
TEST_FRAMEWORK="go_test"
echo "🐹 Go project detected"
# Java project detection
elif [ -f "pom.xml" ] || [ -f "build.gradle" ]; then
PROJECT_TYPE="java"
echo "☕ Java project detected"
if [ -f "pom.xml" ]; then
TEST_FRAMEWORK="maven"
echo "🏗️ Maven build system detected"
else
TEST_FRAMEWORK="gradle"
echo "🐘 Gradle build system detected"
fi
fi
echo ""
echo "📊 Running coverage analysis for $PROJECT_TYPE project..."
# Run coverage based on project type
case "$PROJECT_TYPE" in
"node")
case "$TEST_FRAMEWORK" in
"jest")
echo "🃏 Running Jest with coverage..."
if npm test -- --coverage --silent 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Jest coverage completed successfully"
elif npm run test:coverage 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Coverage script completed successfully"
else
echo "⚠️ Jest coverage command failed - check test configuration"
fi
;;
"vitest")
echo "⚡ Running Vitest with coverage..."
if npx vitest run --coverage 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Vitest coverage completed successfully"
else
echo "⚠️ Vitest coverage command failed"
fi
;;
"mocha")
echo "☕ Running Mocha with nyc coverage..."
if npx nyc mocha 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Mocha coverage completed successfully"
else
echo "⚠️ Mocha coverage requires nyc - install with: npm install --save-dev nyc"
fi
;;
*)
echo "⚠️ No recognized testing framework - attempting generic npm test"
if npm test 2>/dev/null; then
echo "✅ Tests completed (coverage unknown)"
else
echo "❌ Tests failed or not configured"
fi
;;
esac
;;
"python")
case "$TEST_FRAMEWORK" in
"pytest")
echo "🧪 Running pytest with coverage..."
if pytest --cov=. --cov-report=term-missing --cov-report=html 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Pytest coverage completed successfully"
else
echo "⚠️ Pytest coverage failed - install with: pip install pytest-cov"
fi
;;
"unittest")
echo "🔬 Running unittest with coverage..."
if python -m coverage run -m unittest discover 2>/dev/null; then
python -m coverage report 2>/dev/null
COVERAGE_AVAILABLE=true
echo "✅ Unittest coverage completed successfully"
else
echo "⚠️ Coverage.py not available - install with: pip install coverage"
fi
;;
*)
echo "⚠️ No Python testing framework detected"
;;
esac
;;
"rust")
echo "🦀 Running Cargo test with coverage..."
if command -v cargo-tarpaulin >/dev/null 2>&1; then
if cargo tarpaulin --out Html 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Cargo tarpaulin coverage completed successfully"
else
echo "⚠️ Cargo tarpaulin failed"
fi
else
echo "⚠️ cargo-tarpaulin not installed - install with: cargo install cargo-tarpaulin"
echo "🔄 Running basic cargo test..."
cargo test 2>/dev/null && echo "✅ Tests completed (coverage unavailable)"
fi
;;
"go")
echo "🐹 Running Go test with coverage..."
if go test -coverprofile=coverage.out ./... 2>/dev/null; then
go tool cover -html=coverage.out -o coverage.html 2>/dev/null
COVERAGE_AVAILABLE=true
echo "✅ Go coverage completed successfully"
else
echo "⚠️ Go test coverage failed"
fi
;;
"java")
case "$TEST_FRAMEWORK" in
"maven")
echo "🏗️ Running Maven test with JaCoCo coverage..."
if mvn test jacoco:report 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Maven JaCoCo coverage completed successfully"
else
echo "⚠️ Maven coverage failed - ensure JaCoCo plugin is configured"
fi
;;
"gradle")
echo "🐘 Running Gradle test with JaCoCo coverage..."
if ./gradlew test jacocoTestReport 2>/dev/null; then
COVERAGE_AVAILABLE=true
echo "✅ Gradle JaCoCo coverage completed successfully"
else
echo "⚠️ Gradle coverage failed - ensure JaCoCo plugin is configured"
fi
;;
esac
;;
*)
echo "❓ Unknown project type - cannot generate coverage report"
echo "💡 Supported: Node.js, Python, Rust, Go, Java"
;;
esac
echo ""
echo "📈 Coverage Report Summary:"
echo "═══════════════════════════"
# Display coverage results based on available formats
if [ "$COVERAGE_AVAILABLE" = true ]; then
case "$PROJECT_TYPE" in
"node")
if [ -d "coverage" ]; then
echo "📊 Coverage files found in coverage/ directory"
# Try to parse coverage summary
if [ -f "coverage/coverage-summary.json" ]; then
echo "📋 Coverage Summary:"
cat coverage/coverage-summary.json 2>/dev/null | jq -r '.total | "Lines: " + (.lines.pct|tostring) + "% (" + (.lines.covered|tostring) + "/" + (.lines.total|tostring) + ")", "Branches: " + (.branches.pct|tostring) + "% (" + (.branches.covered|tostring) + "/" + (.branches.total|tostring) + ")", "Functions: " + (.functions.pct|tostring) + "% (" + (.functions.covered|tostring) + "/" + (.functions.total|tostring) + ")", "Statements: " + (.statements.pct|tostring) + "% (" + (.statements.covered|tostring) + "/" + (.statements.total|tostring) + ")"' 2>/dev/null || echo "Coverage summary parsing failed"
fi
echo "🌐 HTML Report: file://$(pwd)/coverage/index.html"
fi
;;
"python")
if [ -d "htmlcov" ]; then
echo "🌐 HTML Report: file://$(pwd)/htmlcov/index.html"
fi
;;
"rust")
if [ -f "tarpaulin-report.html" ]; then
echo "🌐 HTML Report: file://$(pwd)/tarpaulin-report.html"
fi
;;
"go")
if [ -f "coverage.html" ]; then
echo "🌐 HTML Report: file://$(pwd)/coverage.html"
fi
;;
"java")
if [ -d "target/site/jacoco" ]; then
echo "🌐 HTML Report: file://$(pwd)/target/site/jacoco/index.html"
elif [ -d "build/reports/jacoco/test/html" ]; then
echo "🌐 HTML Report: file://$(pwd)/build/reports/jacoco/test/html/index.html"
fi
;;
esac
else
echo "❌ No coverage data available"
echo "💡 Coverage Setup Tips:"
case "$PROJECT_TYPE" in
"node")
echo " • For Jest: Add 'collectCoverage: true' to jest.config.js"
echo " • For Vitest: Add 'coverage' provider to vite.config.js"
echo " • Run: npm install --save-dev @vitest/coverage-c8"
;;
"python")
echo " • Install: pip install pytest-cov coverage"
echo " • Run: pytest --cov=your_package"
;;
"rust")
echo " • Install: cargo install cargo-tarpaulin"
echo " • Run: cargo tarpaulin --out Html"
;;
"go")
echo " • Built-in: go test -coverprofile=coverage.out"
echo " • View: go tool cover -html=coverage.out"
;;
"java")
echo " • Add JaCoCo plugin to Maven/Gradle configuration"
echo " • Maven: mvn test jacoco:report"
echo " • Gradle: ./gradlew test jacocoTestReport"
;;
esac
fi
echo ""
echo "💡 Coverage Best Practices:"
echo " • Aim for 80%+ line coverage on critical code"
echo " • Focus on testing business logic and edge cases"
echo " • Use coverage to identify untested code, not as a quality metric"
echo " • Write meaningful tests, not just coverage-driven tests"
echo " • Exclude generated code and vendor dependencies"
echo " • Set up coverage thresholds in CI/CD pipelines"
echo ""
echo "🎯 Test coverage analysis complete!"
echo "═══════════════════════════════════════════════════"
exit 0
Complete hook script that generates test coverage reports on session end
#!/bin/bash
echo "🧪 Test Coverage Final Report - Analyzing test coverage..."
echo "⏰ Session ended: $(date)"
PROJECT_TYPE="unknown"
TEST_FRAMEWORK="unknown"
if [ -f "package.json" ]; then
PROJECT_TYPE="node"
if grep -q '"jest"' package.json 2>/dev/null; then
TEST_FRAMEWORK="jest"
echo "🃏 Jest testing framework detected"
if npm test -- --coverage --silent 2>/dev/null; then
echo "✅ Jest coverage completed successfully"
if [ -f "coverage/coverage-summary.json" ]; then
echo "📋 Coverage Summary:"
cat coverage/coverage-summary.json 2>/dev/null | jq -r '.total | "Lines: " + (.lines.pct|tostring) + "%"' 2>/dev/null || echo "Coverage summary parsing failed"
fi
echo "🌐 HTML Report: file://$(pwd)/coverage/index.html"
fi
fi
elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
PROJECT_TYPE="python"
if command -v pytest >/dev/null 2>&1; then
TEST_FRAMEWORK="pytest"
echo "🧪 Pytest testing framework available"
if pytest --cov=. --cov-report=term-missing --cov-report=html 2>/dev/null; then
echo "✅ Pytest coverage completed successfully"
if [ -d "htmlcov" ]; then
echo "🌐 HTML Report: file://$(pwd)/htmlcov/index.html"
fi
fi
fi
fi
echo "💡 Coverage Best Practices:"
echo " • Aim for 80%+ line coverage on critical code"
echo " • Focus on testing business logic and edge cases"
echo " • Use coverage to identify untested code, not as a quality metric"
echo "🎯 Test coverage analysis complete!"
exit 0
Complete hook configuration for .claude/settings.json to enable test coverage reports
{
"hooks": {
"stop": {
"script": "./.claude/hooks/test-coverage-final-report.sh",
"matchers": ["*"]
}
}
}
Enhanced hook script with support for Vitest, Rust, and Go coverage tools
#!/bin/bash
echo "🧪 Test Coverage Final Report - Analyzing test coverage..."
PROJECT_TYPE="unknown"
if [ -f "package.json" ]; then
PROJECT_TYPE="node"
if grep -q '"vitest"' package.json 2>/dev/null; then
echo "⚡ Vitest testing framework detected"
if npx vitest run --coverage 2>/dev/null; then
echo "✅ Vitest coverage completed successfully"
if [ -d "coverage" ]; then
echo "📊 Coverage files found in coverage/ directory"
if [ -f "coverage/coverage-summary.json" ]; then
echo "📋 Coverage Summary:"
cat coverage/coverage-summary.json 2>/dev/null | jq -r '.total | "Lines: " + (.lines.pct|tostring) + "% (" + (.lines.covered|tostring) + "/" + (.lines.total|tostring) + ")", "Branches: " + (.branches.pct|tostring) + "% (" + (.branches.covered|tostring) + "/" + (.branches.total|tostring) + ")", "Functions: " + (.functions.pct|tostring) + "% (" + (.functions.covered|tostring) + "/" + (.functions.total|tostring) + ")", "Statements: " + (.statements.pct|tostring) + "% (" + (.statements.covered|tostring) + "/" + (.statements.total|tostring) + ")"' 2>/dev/null || echo "Coverage summary parsing failed"
fi
echo "🌐 HTML Report: file://$(pwd)/coverage/index.html"
fi
fi
fi
elif [ -f "Cargo.toml" ]; then
PROJECT_TYPE="rust"
if command -v cargo-tarpaulin >/dev/null 2>&1; then
if cargo tarpaulin --out Html 2>/dev/null; then
echo "✅ Cargo tarpaulin coverage completed successfully"
if [ -f "tarpaulin-report.html" ]; then
echo "🌐 HTML Report: file://$(pwd)/tarpaulin-report.html"
fi
fi
fi
elif [ -f "go.mod" ]; then
PROJECT_TYPE="go"
if go test -coverprofile=coverage.out ./... 2>/dev/null; then
go tool cover -html=coverage.out -o coverage.html 2>/dev/null
echo "✅ Go coverage completed successfully"
if [ -f "coverage.html" ]; then
echo "🌐 HTML Report: file://$(pwd)/coverage.html"
fi
fi
fi
echo "🎯 Test coverage analysis complete!"
exit 0
Enhanced hook script with coverage threshold validation and enforcement
#!/bin/bash
echo "🧪 Test Coverage Final Report - Analyzing test coverage..."
PROJECT_TYPE="unknown"
if [ -f "package.json" ]; then
PROJECT_TYPE="node"
if grep -q '"jest"' package.json 2>/dev/null; then
COVERAGE_THRESHOLD=80
if npm test -- --coverage --silent 2>/dev/null; then
if [ -f "coverage/coverage-summary.json" ]; then
LINE_COVERAGE=$(cat coverage/coverage-summary.json 2>/dev/null | jq -r '.total.lines.pct' 2>/dev/null || echo "0")
if (( $(echo "$LINE_COVERAGE >= $COVERAGE_THRESHOLD" | bc -l 2>/dev/null || echo "0") )); then
echo "✅ Coverage threshold met: ${LINE_COVERAGE}% >= ${COVERAGE_THRESHOLD}%"
else
echo "⚠️ Coverage below threshold: ${LINE_COVERAGE}% < ${COVERAGE_THRESHOLD}%"
fi
fi
fi
fi
elif [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
PROJECT_TYPE="python"
if command -v pytest >/dev/null 2>&1; then
COVERAGE_THRESHOLD=80
if pytest --cov=. --cov-report=term --cov-report=html --cov-fail-under=$COVERAGE_THRESHOLD 2>/dev/null; then
echo "✅ Coverage threshold met: >= ${COVERAGE_THRESHOLD}%"
else
echo "⚠️ Coverage below threshold: < ${COVERAGE_THRESHOLD}%"
fi
fi
fi
echo "🎯 Test coverage analysis complete!"
exit 0
Example test coverage final report configuration for customizing coverage analysis behavior
{
"coverage": {
"report_on_session_end": true,
"html_report": true,
"terminal_report": true,
"coverage_threshold": 80,
"frameworks": {
"jest": {
"coverage_command": "npm test -- --coverage",
"summary_file": "coverage/coverage-summary.json",
"html_report": "coverage/index.html"
},
"pytest": {
"coverage_command": "pytest --cov=. --cov-report=html",
"html_report": "htmlcov/index.html"
},
"vitest": {
"coverage_command": "npx vitest run --coverage",
"summary_file": "coverage/coverage-summary.json"
}
},
"exclude_patterns": [
"**/node_modules/**",
"**/vendor/**",
"**/__pycache__/**"
]
}
}
collectCoverage disabled or wrong paths in jest.config.js. Verify: 'collectCoverage: true, collectCoverageFrom: ["src/**/*.{js,ts}"]'. Or force: 'npm test -- --coverage --collectCoverageFrom="src/**"'. Check Jest configuration. Verify test execution.
coverage-summary.json missing or malformed. Check exists: '[ -f coverage/coverage-summary.json ]' before jq. Generate: add 'coverageReporters: ["json-summary", "html"]' to jest.config.js. Verify JSON format. Test jq parsing separately.
Separate package required. Install: 'pip install pytest-cov coverage'. Verify: 'pytest --version' shows cov plugin. Or use coverage.py: 'coverage run -m pytest; coverage report'. Check Python environment. Verify package installation.
Requires nightly Rust and specific deps. Use Docker: 'docker run --rm -v $PWD:/volume xd009642/tarpaulin cargo tarpaulin'. Or alternative: 'cargo install cargo-llvm-cov' for stable Rust. Check Rust toolchain. Verify dependencies.
Terminal doesn't hyperlink file:// URLs. Add open command: 'echo "Open: coverage/index.html"; open coverage/index.html 2>/dev/null || xdg-open coverage/index.html' auto-launching browser. Verify file path. Test browser opening.
Install coverage provider: 'npm install --save-dev @vitest/coverage-c8' or '@vitest/coverage-v8'. Configure in vite.config.js: 'test: { coverage: { provider: "c8" } }'. Verify Vitest configuration. Test coverage generation.
Verify coverage profile generation: 'go test -coverprofile=coverage.out ./...'. Check coverage profile format. Use 'go tool cover -func=coverage.out' for detailed breakdown. Verify Go version. Test coverage calculation.
Ensure JaCoCo plugin is configured in pom.xml or build.gradle. Run: 'mvn test jacoco:report' or './gradlew test jacocoTestReport'. Check plugin configuration. Verify report generation path. Test JaCoCo execution.
Show that Test Coverage Final Report - Hooks is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/hooks/test-coverage-final-report)Test Coverage Final Report - Hooks side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
| Field | Generates a comprehensive test coverage report when the coding session ends. Open dossier | Analyzes and reports final bundle sizes when the development session ends. Open dossier | Generates a comprehensive report when Claude Code workflow stops, including files modified, tests run, and git status. Open dossier | A PostToolUse hook that runs the matching test runner for a changed file's language — Jest or Vitest for JS/TS, pytest for Python, go test, or Maven/Gradle for Java — scoped to the edited file. Open dossier |
|---|---|---|---|---|
| Next steps | ||||
| Trust | ||||
| Review status | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed | ReviewedMaintainer reviewed |
| Package trust | Package not verified | Package not verified | Package not verified | Package not verified |
| Source provenance | Source-backed | Source-backed | Source-backed | Source-backed |
| Submitter | — | — | — | — |
| Install risk | Review first | Review first | Review first | Review first |
| Notes | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ | Safety ✓ Privacy ✓ |
| Brand | — | — | — | — |
| Category | hooks | hooks | hooks | hooks |
| Source | source-backed | source-backed | source-backed | source-backed |
| Author | JSONbored | JSONbored | JSONbored | JSONbored |
| Added | 2025-09-19 | 2025-09-19 | 2025-09-19 | 2025-09-16 |
| Platforms | Claude Code | Claude Code | Claude Code | Claude Code |
| Source repo | — | — | — | — |
| Safety notes | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling. | ✓Runs your project's test command automatically after each edit; tests execute arbitrary project code, so enable this only in a trusted repo and expect it to run frequently. The script invokes whichever runner it detects (npm test, npx vitest, pytest, go test, mvn/gradle); make sure the right one is installed so it does not run an unexpected command. |
| Privacy notes | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output. | ✓Runs locally and prints test output to the hook; that output can include file paths, test names, and any data your tests log. |
| Prerequisites | — none listed | — none listed | — none listed | — none listed |
| Install | | | | |
| Config | | | | |
| Citations | ||||
| Claim | Unclaimed | Unclaimed | Unclaimed | Unclaimed |
Loading live community signals…
A short, calm digest of reviewed Claude resources. Unsubscribe any time.