Skip to content

PranavNagrecha/AwesomeSalesforceSkills / skills/admin/analytics-kpi-definition

analytics-kpi-definition

Verified

Use this skill to define, document, and validate KPI metrics for CRM Analytics — covering metric formula design, dimension selection, target-dataset modeling, benchmark setting, and the KPI register that must exist before any dashboard or lens is built. Trigger keywords: KPI definition CRM Analytics, analytics metric design, analytics target attainment, CRM Analytics measures vs dimensions, analytics benchmark. NOT for laying out the dashboard or lens itself — use admin/analytics-dashboard-design. NOT for scoping data sources, audiences, and drill-down paths — use admin/analytics-requirements-gathering.

scripts/check_analytics_kpi_definition.py

View on GitHub
#!/usr/bin/env python3
"""Checker script for Analytics Kpi Definition skill.

Checks org metadata or configuration relevant to Analytics Kpi Definition.
Uses stdlib only — no pip dependencies.

Usage:
    python3 check_analytics_kpi_definition.py [--help]
    python3 check_analytics_kpi_definition.py --manifest-dir path/to/metadata
"""

from __future__ import annotations

import argparse
import sys
from pathlib import Path


def parse_args() -> argparse.Namespace:
    parser = argparse.ArgumentParser(
        description="Check Analytics Kpi Definition configuration and metadata for common issues.",
    )
    parser.add_argument(
        "--manifest-dir",
        default=".",
        help="Root directory of the Salesforce metadata (default: current directory).",
    )
    return parser.parse_args()


def check_kpi_register_document(file_path: Path) -> list[str]:
    """Check a KPI register markdown document for completeness."""
    issues: list[str] = []

    if not file_path.exists():
        return issues

    content = file_path.read_text(encoding="utf-8")
    lower = content.lower()

    # Check for measure/dimension type confirmation
    if "measure" not in lower or "dimension" not in lower:
        issues.append(
            f"{file_path.name}: KPI register should confirm field types (Measure vs Dimension) "
            "for each field used in formulas. CRM Analytics enforces this distinction at runtime."
        )

    # Check for target model documentation
    if "target" not in lower:
        issues.append(
            f"{file_path.name}: KPI register does not mention target values or target attainment model. "
            "If stakeholders need actual-vs-target comparison, document the targets dataset schema."
        )

    # Check for stakeholder sign-off indicator
    if "sign-off" not in lower and "approved" not in lower and "sign off" not in lower:
        issues.append(
            f"{file_path.name}: KPI register should record stakeholder sign-off before development. "
            "Add an approval/sign-off section to prevent mid-build formula disputes."
        )

    # Check for SAQL formula sketches
    if "saql" not in lower and "foreach" not in lower and "cogroup" not in lower:
        issues.append(
            f"{file_path.name}: KPI register should include SAQL formula sketches. "
            "Formula sketches validate that the metric can be expressed in SAQL before build starts."
        )

    return issues


def check_analytics_kpi_definition(manifest_dir: Path) -> list[str]:
    """Check a metadata or documentation directory for KPI definition completeness."""
    issues: list[str] = []

    if not manifest_dir.exists():
        issues.append(f"Directory not found: {manifest_dir}")
        return issues

    # Look for KPI register files
    kpi_files = (
        list(manifest_dir.rglob("kpi-register*"))
        + list(manifest_dir.rglob("*kpi*register*"))
        + list(manifest_dir.rglob("*analytics*kpi*"))
    )
    for kf in kpi_files:
        if kf.suffix in (".md", ".txt", ".csv"):
            issues.extend(check_kpi_register_document(kf))

    return issues


def main() -> int:
    args = parse_args()
    manifest_dir = Path(args.manifest_dir)
    issues = check_analytics_kpi_definition(manifest_dir)

    if not issues:
        print("No issues found.")
        return 0

    for issue in issues:
        print(f"WARN: {issue}", file=sys.stderr)

    return 1 if issues else 0


if __name__ == "__main__":
    sys.exit(main())
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall