coverage-analysis
Code coverage analysis using coverage.sh script and pytest-cov
What this skill does
# Coverage Analysis Guide ## Purpose Provide Claude with a comprehensive reference for running code coverage analysis in WorldArchitect.AI. This skill covers the coverage.sh script usage, interpreting results, and best practices. ## Activation Cues - Running coverage analysis - Checking test coverage before PRs - Investigating which code paths need more tests - Generating coverage reports ## Quick Reference ```bash # Run coverage with HTML report (default) ./coverage.sh # Run coverage with text report only (faster) ./coverage.sh --no-html # Include integration tests ./coverage.sh --integration # Include integration tests, text only ./coverage.sh --integration --no-html ``` ## Output Locations | Output | Location | |--------|----------| | Text report | `/tmp/worldarchitectai/coverage/coverage_report.txt` | | HTML report | `/tmp/worldarchitectai/coverage/index.html` | | Quick link | `file:///tmp/coverage.html` (symlink) | ## Understanding Results ### Test Summary ``` Test Summary: Total tests: 232 Passed: 204 Failed: 28 ``` ### Coverage Summary ``` Overall Coverage: 69% Key Files Coverage: main.py 44% llm_service.py 74% game_state.py 57% firestore_service.py 53% ``` ## Coverage Thresholds ### CI Workflow Thresholds | Coverage | CI Result | Badge Color | |----------|-----------|-------------| | ≥80% | Pass | Green (MINIMUM_GREEN: 80) | | 60-79% | Pass (warning) | Orange (MINIMUM_ORANGE: 60) | | <60% | **Fail** | Red | ### Quality Guidelines | Coverage | Status | Action | CI Threshold | |----------|--------|--------|--------------| | 80%+ | Excellent | Maintain | Green (MINIMUM_GREEN: 80) | | 60-79% | Good | Minor improvements | Orange (MINIMUM_ORANGE: 60) | | 40-59% | Fair | Add targeted tests | Warning | | <40% | Poor | Prioritize testing | Error | ## Key Files to Monitor Priority coverage targets for WorldArchitect.AI: 1. **narrative_response_schema.py** - LLM response parsing 2. **llm_service.py** - AI integration 3. **world_logic.py** - Core game mechanics 4. **firestore_service.py** - Data persistence 5. **game_state.py** - State management 6. **main.py** - API endpoints ## Running Single Test Files For focused development, run individual test files: ```bash # Using venv with proper PYTHONPATH source venv/bin/activate PYTHONPATH="$PWD:$PYTHONPATH" TESTING=true python mvp_site/tests/test_specific.py ``` ## Common Issues ### ModuleNotFoundError: No module named 'mvp_site' **Cause**: PYTHONPATH doesn't include project root. **Fix**: The coverage.sh script sets `PYTHONPATH="$PROJECT_ROOT:$PYTHONPATH"` automatically. For manual runs: ```bash export PYTHONPATH="$PWD:$PYTHONPATH" ``` ### Test Fails with Missing Dependencies **Fix**: Install test dependencies: ```bash pip install numpy fastembed onnxruntime ``` ### Browser/Integration Tests Failing Some tests require additional setup: - Browser tests need Playwright: `playwright install` - Integration tests may need running services ## GitHub Actions Integration For CI coverage reporting, use `py-cov-action/[email protected]` (SHA-pinned in workflow): ```yaml - name: Coverage comment uses: py-cov-action/python-coverage-comment-action@fb02115d6115e7b3325dc3295fe1dcfb1919248a # v3.32 with: GITHUB_TOKEN: ${{ github.token }} MINIMUM_GREEN: 80 MINIMUM_ORANGE: 60 ``` See `.github/workflows/coverage.yml` for the full workflow with threshold checks. ## Best Practices 1. **Run before PRs**: Check coverage impact before submitting 2. **Focus on critical paths**: Prioritize business logic coverage 3. **Don't chase 100%**: Focus on meaningful test coverage 4. **Review uncovered lines**: Use HTML report for line-by-line analysis 5. **Mock external services**: Use `TESTING=true` for isolated testing ## Related Skills - `end2end-testing.md` - E2E test patterns - `evidence-standards.md` - Test evidence collection
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.