Inferensys

Prompt

Security Posture Scorecard Generation Prompt for Repositories

A practical prompt playbook for generating quantitative security health scores from repository analysis, including metric breakdowns, trend tracking, and benchmark comparison.
Research scientist tracking AI experiments on laptop, experiment results visible, casual lab environment.
PROMPT PLAYBOOK

When to Use This Prompt

Understand the job-to-be-done, required inputs, and boundaries for generating a quantitative security posture scorecard from repository scan data.

This prompt is for security program managers and DevSecOps engineers who need to convert raw, structured findings from multiple security scanners into a single, repeatable security posture scorecard. The job-to-be-done is quantitative trend tracking and benchmark comparison, not initial vulnerability discovery. You should use this prompt when you already have completed outputs from secret scans, dependency audits, vulnerability remediation trackers, and configuration compliance checks. The prompt synthesizes these discrete reports into a weighted scorecard with metric breakdowns, severity distributions, and a calculated overall posture score. It is designed to be run on a regular cadence—such as weekly or per-release—so you can plot score trends over time and compare repositories against internal risk thresholds.

The ideal input is a structured JSON object containing four arrays: secret_scan_findings, dependency_vulnerabilities, remediation_metrics, and config_compliance_results. Each array should contain objects with at minimum a severity field (using a consistent scale like CRITICAL, HIGH, MEDIUM, LOW), a status field (e.g., open, in_progress, resolved), and a discovered_date or last_updated timestamp. The prompt does not perform scanning itself and will produce unreliable results if fed unstructured log output or raw tool stdout. You must pre-process scanner output into the expected schema before invoking this prompt. If your input data is incomplete—for example, you have dependency scan results but no secret scan data—you should either omit that section and accept a reduced scorecard or explicitly mark the missing category as `

status": "unavailable"` to avoid the model hallucinating metrics."

Do not use this prompt for real-time incident response or as a substitute for a SIEM. It is a periodic assessment tool, not an operational alerting system. It also should not be used to make automated gating decisions—such as blocking a production deployment—without human review of the underlying findings. The scorecard is a decision-support artifact, not a source of truth. After generating the scorecard, your next step should be to store the output in a versioned data store (e.g., a database table with a generated_at timestamp) to enable trend analysis. Avoid the temptation to tweak the prompt to inflate scores; instead, calibrate the weighting parameters in the [CONSTRAINTS] section to match your organization's actual risk appetite.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Security Posture Scorecard Generation Prompt works, where it fails, and the operational prerequisites for production use.

01

Good Fit: Quantitative Program Reviews

Use when: security program managers need a repeatable, data-driven health score across multiple repositories for quarterly reviews or board reporting. Guardrail: Lock down the scoring rubric and metric weights in the prompt template so scores remain comparable across runs and repos.

02

Bad Fit: Real-Time Incident Response

Avoid when: you need a live security assessment during an active incident or immediately after a zero-day disclosure. The scorecard is a point-in-time snapshot, not a streaming detection system. Guardrail: Route real-time threats to your SIEM or on-call playbook; use this prompt for post-incident trend analysis only.

03

Required Inputs: Structured Scan Data

Risk: Garbage in, garbage out. The prompt cannot generate a meaningful scorecard from an empty or unstructured repo. Guardrail: Require pre-processed inputs—secret scan results, dependency manifests with CVE data, SAST findings, and config drift reports—before invoking the scorecard prompt.

04

Operational Risk: Benchmark Drift

Risk: Scores look better over time not because security improved, but because the baseline or rubric became stale. Guardrail: Version your scoring methodology alongside the prompt. Schedule quarterly rubric reviews to adjust weights based on the evolving threat landscape and team maturity.

05

Operational Risk: Over-Reliance on a Single Number

Risk: Executives or auditors treat the aggregate score as ground truth, ignoring the underlying metric breakdowns and uncertainty. Guardrail: The output schema must always include per-category subscores, data freshness timestamps, and a confidence indicator. Never expose a single score without its decomposition.

06

Bad Fit: Unscanned or Air-Gapped Repositories

Avoid when: the target repository has never been scanned for secrets, dependencies, or vulnerabilities. The prompt will hallucinate a low-confidence score or produce a misleading "clean" result. Guardrail: Implement a pre-flight check that aborts scorecard generation if required scan artifacts are missing or older than your defined staleness threshold.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A reusable prompt template for generating a quantitative security posture scorecard from repository analysis, ready to be adapted with your specific inputs and evaluation criteria.

This prompt template is designed to be the core instruction set you send to a model. It expects structured inputs about a repository's security state and produces a quantitative scorecard. The template uses square-bracket placeholders like [REPOSITORY_NAME] and [SECRET_SCAN_RESULTS] that you must replace with real data from your security scanning pipeline before execution. Do not send the placeholders to the model; they are for your pre-processing logic.

code
You are a security program analyst generating a quantitative security posture scorecard for a software repository. Your output must be a single, valid JSON object conforming to the provided schema. Do not include any text outside the JSON object.

## Repository Context
- Repository Name: [REPOSITORY_NAME]
- Primary Language: [PRIMARY_LANGUAGE]
- Team Owner: [TEAM_OWNER]
- Assessment Date: [ASSESSMENT_DATE]

## Security Scan Inputs
### Secret Hygiene
[SECRET_SCAN_RESULTS]

### Dependency Freshness
[DEPENDENCY_SCAN_RESULTS]

### Vulnerability Remediation Velocity
[VULNERABILITY_REMEDIATION_DATA]

### Configuration Compliance
[CONFIGURATION_COMPLIANCE_DATA]

## Scoring Rubric
Score each category on a 0.0 to 10.0 scale, where 10.0 represents the best possible posture. Use the following guidelines:
- **Secret Hygiene**: Deduct points for each active, high-confidence secret finding. A single active high-confidence secret should cap the score at 5.0.
- **Dependency Freshness**: Score based on the percentage of dependencies with known critical or high CVEs that are older than [CRITICAL_VULNERABILITY_AGE_THRESHOLD_DAYS] days.
- **Vulnerability Remediation Velocity**: Score based on the average time-to-remediate for critical and high vulnerabilities over the last [REMEDIATION_LOOKBACK_DAYS] days, compared to a target SLA of [REMEDIATION_SLA_DAYS] days.
- **Configuration Compliance**: Score based on the percentage of configuration checks passing against the [COMPLIANCE_POLICY_NAME] policy.

## Output Schema
{
  "repository": "string",
  "assessment_date": "string (YYYY-MM-DD)",
  "overall_score": "number (0.0-10.0, weighted average of categories)",
  "score_breakdown": {
    "secret_hygiene": {
      "score": "number (0.0-10.0)",
      "finding_count": "integer",
      "top_risk": "string (brief description of the most critical finding)"
    },
    "dependency_freshness": {
      "score": "number (0.0-10.0)",
      "outdated_critical_packages": "integer",
      "oldest_cve_days": "integer"
    },
    "remediation_velocity": {
      "score": "number (0.0-10.0)",
      "average_remediation_days": "number",
      "sla_compliance_percentage": "number (0-100)"
    },
    "configuration_compliance": {
      "score": "number (0.0-10.0)",
      "passing_checks": "integer",
      "total_checks": "integer"
    }
  },
  "trend_comparison": {
    "previous_score": "number or null",
    "score_delta": "number or null",
    "key_changes": ["string (brief description of major changes)"]
  },
  "critical_actions": ["string (list of the top 3-5 most urgent remediation actions)"]
}

## Constraints
- If any scan input is missing or empty, set the corresponding category score to null and note "No data available" in the `top_risk` or relevant field.
- The `overall_score` must be a weighted average: Secret Hygiene (30%), Dependency Freshness (25%), Remediation Velocity (25%), Configuration Compliance (20%). If a category score is null, redistribute its weight proportionally among the other categories.
- For `trend_comparison`, use the provided [PREVIOUS_SCORECARD_JSON] to calculate deltas. If not provided, set `previous_score` and `score_delta` to null.
- `critical_actions` must be concrete, actionable, and ordered by risk reduction impact.

To adapt this template, start by mapping your existing security tool outputs to the four input sections. The [SECRET_SCAN_RESULTS] placeholder, for example, should be replaced with a structured summary of findings from tools like trufflehog or gitleaks, not raw logs. The scoring rubric is a starting point; you should calibrate the thresholds like [CRITICAL_VULNERABILITY_AGE_THRESHOLD_DAYS] to match your organization's risk appetite. The most critical adaptation is the Output Schema—ensure it aligns with your dashboarding or data warehouse schema to enable trend tracking over time.

IMPLEMENTATION TABLE

Prompt Variables

Inputs the Security Posture Scorecard Generation Prompt needs to work reliably. Validate each before sending to prevent hallucinated metrics or missing data in the scorecard.

PlaceholderPurposeExampleValidation Notes

[REPO_ANALYSIS_REPORT]

Structured findings from secret, dependency, SAST, and config scans

{"secrets": [...], "vulnerabilities": [...], "misconfigs": [...]}

Must be valid JSON with required top-level keys. Reject if any scan type is missing or empty array when expected to be populated.

[TIME_RANGE_DAYS]

Analysis window for calculating velocity and trend metrics

90

Must be a positive integer. Clamp to 30-365 range. Reject if null or non-numeric. Used for remediation velocity and fix rate calculations.

[PREVIOUS_SCORECARD]

Prior period scorecard for trend comparison and delta calculation

{"overall_score": 72, "period": "2024-Q3", ...}

Must match output schema of prior run. Null allowed for first run. If provided, validate period ordering to prevent time-travel comparisons.

[BENCHMARK_THRESHOLDS]

Organization-specific or industry benchmark values for each metric category

{"secret_hygiene": 90, "dep_freshness": 80, ...}

Must be a JSON object with numeric thresholds for each metric category. Reject if any threshold is missing or outside 0-100 range.

[REPO_METADATA]

Repository identity, ownership, and criticality classification

{"name": "payments-api", "owner": "platform-team", "criticality": "high"}

Must include name, owner, and criticality fields. Criticality must be one of low, medium, high, critical. Used for risk weighting and escalation rules.

[EXCLUSION_LIST]

Known false positives, accepted risks, or suppressed findings to exclude from scoring

["CVE-2023-0001", "FP-secret-42"]

Array of finding IDs to exclude. Null allowed. Validate each ID exists in [REPO_ANALYSIS_REPORT] to prevent silent exclusion of real findings.

[SCORING_WEIGHTS]

Custom weight overrides for each metric category in the overall score calculation

{"secret_hygiene": 0.30, "dep_freshness": 0.25, ...}

Must sum to 1.0 within 0.01 tolerance. Reject if weights don't sum correctly. Null allowed to use default equal weighting.

PROMPT PLAYBOOK

Implementation Harness Notes

How to wire the Security Posture Scorecard prompt into a repeatable application pipeline with validation, trend tracking, and human review gates.

The Security Posture Scorecard prompt is designed to be called programmatically, not used as a one-off chat interaction. The implementation harness should treat this prompt as a deterministic scoring function: given a structured repository context bundle, it returns a quantitative scorecard. The harness is responsible for assembling that context bundle, calling the model, validating the output schema, storing results for trend analysis, and routing anomalies for human review. This prompt is not a replacement for a SAST scanner or a CVE database—it synthesizes findings from those tools into a program-level score. The harness must therefore integrate with your existing security toolchain (e.g., dependency scanners, secret detectors, static analyzers) to populate the [REPOSITORY_CONTEXT] input with pre-processed findings, not raw source code.

Wire the prompt into a scheduled or event-driven pipeline. A typical trigger is a weekly cron job or a CI/CD pipeline completion event. The harness should: (1) Fetch the latest scan results from your secret scanner, dependency vulnerability database, SAST tool, and configuration auditor. (2) Normalize those results into the structured [REPOSITORY_CONTEXT] JSON block, including finding counts, severity distributions, remediation timelines, and policy compliance flags. (3) Call the model with the prompt template, setting temperature=0 or a very low value to maximize score consistency across runs. (4) Validate the response against the expected [OUTPUT_SCHEMA]—every metric must have a numeric score, a max score, a breakdown array, and a trend direction. If validation fails, retry once with the validation errors appended to the prompt as [CONSTRAINTS] feedback. If the second attempt fails, log the failure and alert the security engineering team; do not silently accept a malformed scorecard.

Store every generated scorecard in a time-series database or structured log store (e.g., a security_scores table with columns for repository, date, metric name, score, max score, and trend). This enables trend tracking and benchmark comparison across repositories and over time. The harness should also compute a composite score from the individual metric scores and flag any metric that drops below a configurable threshold (e.g., secret hygiene score < 70) for immediate review. For high-risk repositories or regulated environments, route scorecards with failing metrics or negative trends to a human security program manager via a ticketing system or review queue before the scorecard is published to dashboards. The prompt itself includes a [RISK_LEVEL] parameter—use this to conditionally enable the human review gate in the harness logic.

Model choice matters for consistency. Use a model with strong JSON mode and instruction-following capabilities (e.g., GPT-4o, Claude 3.5 Sonnet) for production scorecard generation. Avoid models that are prone to hallucinating metric values or inventing findings not present in the input context. The harness should also log the full prompt, response, and validation result for each run to enable prompt observability and regression testing. Before deploying a new prompt version, run it against a golden dataset of known repository contexts with expected score ranges and verify that scores do not drift beyond an acceptable tolerance (e.g., ±5 points per metric). This prompt is a measurement tool—treat its output with the same rigor you would apply to any quantitative security metric.

IMPLEMENTATION TABLE

Expected Output Contract

Fields, format, and validation rules for the generated security posture scorecard. Use this contract to build a post-processing validator that rejects malformed outputs before they reach dashboards or trend databases.

Field or ElementType or FormatRequiredValidation Rule

overall_score

number (0-100)

Must be a float or integer between 0 and 100 inclusive. Reject if outside range or non-numeric.

score_breakdown

object

Must contain keys matching the requested metric categories. Each value must be a number between 0 and 100. Reject if any category is missing or out of range.

score_breakdown.secret_hygiene

number (0-100)

Must be present. Value must be between 0 and 100. Reject if null or missing.

score_breakdown.dependency_freshness

number (0-100)

Must be present. Value must be between 0 and 100. Reject if null or missing.

score_breakdown.vulnerability_remediation_velocity

number (0-100)

Must be present. Value must be between 0 and 100. Reject if null or missing.

score_breakdown.configuration_compliance

number (0-100)

Must be present. Value must be between 0 and 100. Reject if null or missing.

finding_summary

array of objects

Each object must include severity, category, description, and file_path. Severity must be one of critical, high, medium, low, info. Reject if severity is invalid or required fields are missing.

trend_comparison

object or null

If present, must include previous_score and delta keys. previous_score must be a number between 0 and 100. delta must be a number. If null, omit trend section from downstream consumers.

generated_at

ISO 8601 string

Must parse as a valid UTC datetime. Reject if unparseable or in the future beyond a 5-minute clock skew tolerance.

repository_identifier

string

Must be a non-empty string matching the input repository reference. Reject if empty or whitespace-only.

PRACTICAL GUARDRAILS

Common Failure Modes

Security scorecard generation fails in predictable ways. These are the most common failure modes when generating quantitative security posture scores from repository analysis, with concrete guardrails to catch them before they reach a dashboard.

01

Phantom Metric Inflation

What to watch: The model generates a score for a metric it could not actually measure because the required data was absent from the repository scan. For example, reporting a 'Secret Hygiene Score' of 92 when no secret scan tool output was provided. The model fills gaps with plausible but fabricated numbers. Guardrail: Require the prompt to output a data_coverage field alongside every metric, indicating whether the score is computed, partial, or unavailable. Validate that no computed score exists without corresponding evidence in the input context.

02

Benchmark Drift Between Runs

What to watch: The model applies inconsistent scoring thresholds across different repositories or even across different runs on the same repository. A dependency freshness score of 70 might mean '30 days behind' in one run and '90 days behind' in another because the model improvises the rubric each time. Guardrail: Embed a fixed scoring rubric directly in the prompt with explicit thresholds (e.g., 'Critical: >365 days stale, High: 90-365 days, Medium: 30-90 days, Low: <30 days'). Use structured output to enforce the rubric fields and validate score-to-threshold consistency in post-processing.

03

Remediation Velocity Fabrication

What to watch: The model invents remediation timelines when no historical data is available. It may claim 'average time to patch: 14 days' based on a single recent commit or no evidence at all, because the prompt asks for a velocity metric but the input lacks issue tracker or deployment history. Guardrail: Explicitly require a lookback_window and sample_size for any time-based metric. If the sample size is below a minimum threshold (e.g., fewer than 5 resolved vulnerabilities in the window), instruct the model to output insufficient_data rather than a computed value.

04

Configuration Compliance Overreach

What to watch: The model flags configuration findings that are outside the scope of the provided scan data. It may report 'IAM policy violations' when only a dependency manifest was provided, extrapolating from file names or comments rather than actual policy evaluation. Guardrail: Constrain the prompt to only score categories where explicit tool output is present in the input context. Add a source_tool field to each finding, and validate post-generation that every finding references a tool whose output was actually provided.

05

Severity Score Inconsistency

What to watch: The model assigns different severity levels to equivalent findings across repositories or even within the same scorecard. A hardcoded JWT secret might be scored as 'Critical' in one section and 'High' in another because the model lacks a consistent severity taxonomy. Guardrail: Include a fixed severity taxonomy in the prompt (e.g., mapping finding types to CVSS-aligned severity bands). Use a post-generation validator that checks all findings against this taxonomy and flags any severity assignment that deviates from the defined mapping.

06

Trend Comparison Without Baseline

What to watch: The model generates trend statements like 'security posture improved 15% from last quarter' when no previous scorecard or historical data was provided. It hallucinates a baseline to satisfy the trend-tracking instruction. Guardrail: Make trend fields conditional in the output schema. If no previous_scorecard or historical data is present in the input, the prompt must output null for all trend and delta fields. Validate that trend values are only present when a baseline input is explicitly supplied.

IMPLEMENTATION TABLE

Evaluation Rubric

How to test output quality before shipping. Run these checks against a golden dataset of known repositories with verified scores.

CriterionPass StandardFailure SignalTest Method

Scorecard Schema Compliance

Output is valid JSON matching the [OUTPUT_SCHEMA] exactly; all required fields present

Missing required fields, extra fields not in schema, or wrong types (e.g., string where number expected)

Schema validation with JSON Schema validator; run against all golden dataset outputs

Metric Calculation Accuracy

Each metric value matches the independently verified ground-truth score within ±2 points

Metric deviates from verified score by more than 2 points; arithmetic errors in composite scores

Compare each metric field against golden dataset expected values; flag any deviation >2

Finding-to-Metric Traceability

Every metric score can be traced to specific findings in the [FINDINGS_INPUT]; no orphan scores

Metric present with no corresponding finding evidence; score appears fabricated or hallucinated

For each metric, verify at least one finding in [FINDINGS_INPUT] supports the score; log orphans

Severity Distribution Consistency

Severity counts (critical, high, medium, low) sum to total findings and match input distribution

Severity counts do not sum correctly; distribution shifted without explanation (e.g., downgrading criticals)

Sum severity buckets and compare to total_findings; cross-check against input finding severities

Trend Direction Correctness

Trend indicators (improving, stable, declining) match the actual delta between current and previous score

Trend shows 'improving' when score decreased; trend contradicts numeric delta

Calculate delta from [PREVIOUS_SCORECARD]; assert trend label matches sign and magnitude of change

Benchmark Comparison Validity

Benchmark percentile and comparison text reference the provided [BENCHMARK_DATA] only

Benchmark claims percentile not present in [BENCHMARK_DATA]; fabricated industry averages

Assert all benchmark values exist in [BENCHMARK_DATA] input; flag any external claims

Remediation Priority Ordering

Top 3 remediation items correspond to highest-severity or highest-impact findings in input

Low-severity finding ranked above critical; remediation list ignores input severity ordering

Extract top 3 remediation items; verify they match the 3 highest-severity open findings from [FINDINGS_INPUT]

Confidence and Caveat Language

Output includes confidence qualifiers for any metric based on incomplete data; no overconfident claims

Absolute language ('guaranteed secure') without caveats; missing confidence field where [DATA_COMPLETENESS] < 100%

Check confidence field presence when data_completeness < 1.0; scan for banned absolute phrases

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base scorecard prompt and a single repository. Remove strict schema enforcement and trend tracking. Focus on getting a reasonable first scorecard with metric breakdowns.

Simplify the prompt by removing benchmark comparison and historical delta requirements:

code
Generate a security posture scorecard for [REPOSITORY_NAME].
Analyze the following areas and assign a 0-100 score for each:
- Secret hygiene
- Dependency freshness
- Vulnerability remediation velocity
- Configuration compliance

Provide a brief justification for each score.

Watch for

  • Scores that don't match the evidence in the justification
  • Missing metric categories when the repo lacks data
  • Overly confident scores on sparse evidence
  • No distinction between "no findings" and "not scanned"
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.