Skip to content

forcedotcom/sf-skills / plugins/builder/salesforce-code-quality/skills/dx-code-analyzer-configure

dx-code-analyzer-configure

Flagged

Set up, configure, and troubleshoot Salesforce Code Analyzer for any project. Handles installation, prerequisite checks, diagnosing broken setups, creating and editing code-analyzer.yml overrides, engine-specific settings, ignore patterns, severity overrides, and CI/CD pipeline setup. TRIGGER when: user says 'set up code analyzer', 'configure code analyzer', 'install code analyzer', 'code analyzer not working', 'fix my setup', 'scan failing', 'check my setup', 'enable/disable engine', 'exclude files', 'change severity', 'set up GitHub Actions', 'set up CI/CD', 'add to pipeline', 'pipeline fail', 'update my workflow', 'quality gate', 'fail on violations', 'scan changed files only', 'add SARIF', 'code-analyzer.yml', 'ESLint config', 'increase SFGE memory', or reports errors running Code Analyzer. DO NOT TRIGGER when: user wants to run a scan (use dx-code-analyzer-run), fix violations, explain rules, create custom rules (use dx-code-analyzer-custom-rule-create), or suppress violations.

scripts/generate-config.sh

View on GitHub
#!/bin/bash
# generate-config.sh
# Generates a code-analyzer.yml with ONLY project-specific overrides.
# Does NOT duplicate built-in defaults — only writes what intentionally differs.
#
# Usage: bash <skill_dir>/scripts/generate-config.sh [--type apex|lwc|fullstack]
#
# If --type is not specified, auto-detects from workspace contents.

set -euo pipefail

CONFIG_FILE="code-analyzer.yml"
PROJECT_TYPE="${1:-auto}"

# Remove --type prefix if present
PROJECT_TYPE="${PROJECT_TYPE#--type=}"
PROJECT_TYPE="${PROJECT_TYPE#--type }"

# Auto-detect project type
if [ "$PROJECT_TYPE" = "auto" ] || [ "$PROJECT_TYPE" = "" ]; then
    HAS_APEX=false
    HAS_LWC=false
    HAS_NODE_MODULES=false

    [ -d "force-app" ] && HAS_APEX=true
    find . -maxdepth 4 -path "*/lwc/*" -name "*.js" 2>/dev/null | head -1 | grep -q . && HAS_LWC=true
    [ -d "node_modules" ] && HAS_NODE_MODULES=true

    if [ "$HAS_APEX" = true ] && [ "$HAS_LWC" = true ]; then
        PROJECT_TYPE="fullstack"
    elif [ "$HAS_LWC" = true ]; then
        PROJECT_TYPE="lwc"
    elif [ "$HAS_APEX" = true ]; then
        PROJECT_TYPE="apex"
    else
        PROJECT_TYPE="minimal"
    fi

    echo "Auto-detected project type: ${PROJECT_TYPE}"

    # Warn if no Salesforce project markers found
    if [ "$PROJECT_TYPE" = "minimal" ] && [ ! -f "sfdx-project.json" ] && [ ! -f "sf-project.json" ]; then
        echo "WARNING: No Salesforce project markers found (no sfdx-project.json, sf-project.json, or force-app/)."
        echo "         Are you running this from your project root?"
        echo "         Generating minimal config — re-run from project root for better detection."
    fi
fi

# Check if config already exists
if [ -f "$CONFIG_FILE" ] || [ -f "code-analyzer.yaml" ]; then
    echo "WARNING: Config file already exists."
    echo "Edit the existing file instead of regenerating."
    exit 1
fi

echo "Generating ${CONFIG_FILE} (overrides only)..."

case "$PROJECT_TYPE" in
    apex)
        cat > "$CONFIG_FILE" << 'YAML'
# Code Analyzer overrides for Apex project
# Only entries that differ from built-in defaults

ignores:
  files:
    - "**/node_modules/**"
    - "**/.sfdx/**"
    - "**/.sf/**"

engines:
  sfge:
    java_max_heap_size: "4g"
YAML
        ;;

    lwc)
        cat > "$CONFIG_FILE" << 'YAML'
# Code Analyzer overrides for LWC project
# Only entries that differ from built-in defaults

ignores:
  files:
    - "**/node_modules/**"
    - "**/.sfdx/**"
    - "**/.sf/**"
    - "**/jest-mocks/**"
    - "**/__tests__/**"

engines:
  eslint:
    auto_discover_eslint_config: true
YAML
        ;;

    fullstack)
        cat > "$CONFIG_FILE" << 'YAML'
# Code Analyzer overrides for full-stack Salesforce project
# Only entries that differ from built-in defaults

ignores:
  files:
    - "**/node_modules/**"
    - "**/.sfdx/**"
    - "**/.sf/**"
    - "**/jest-mocks/**"
    - "**/__tests__/**"

engines:
  sfge:
    java_max_heap_size: "4g"
  eslint:
    auto_discover_eslint_config: true
YAML
        ;;

    minimal)
        cat > "$CONFIG_FILE" << 'YAML'
# Code Analyzer overrides
# Only entries that differ from built-in defaults

ignores:
  files:
    - "**/node_modules/**"
YAML
        ;;

    *)
        echo "ERROR: Unknown project type: ${PROJECT_TYPE}"
        echo "Valid types: apex, lwc, fullstack, minimal"
        exit 1
        ;;
esac

echo ""
echo "Created: ${CONFIG_FILE}"
echo ""
echo "This file contains ONLY overrides — built-in defaults still apply for"
echo "everything not listed here. Add more overrides as needed."
echo ""
echo "Next steps:"
echo "  1. Review: cat ${CONFIG_FILE}"
echo "  2. Validate: sf code-analyzer config --config-file ${CONFIG_FILE}"
echo "  3. Run scan: sf code-analyzer run --output-file results.json --include-fixes"
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release.Stars: 118kUpdated Claude CodeCodexVerifiedInstall