pg_exporter: Instructions file for GitHub Copilot

.github/copilot-instructions.md

pg_exporter copilot-instructions.md is an instructions file for GitHub Copilot from nbari/pg_exporter. It costs 1,924 tokens per session, scanned A, original, BSD-3-Clause.

Project instructions for pg_exporter, a Rust program that reads PostgreSQL database statistics and makes them available to Prometheus monitoring. They describe the project's tools, tests, and safety requirements.

In plain words
What is it for?
Use them when editing pg_exporter, checking Rust formatting and linting, running tests, or writing PostgreSQL queries and result handling.
Why use it?
They give a coding agent the project context and rules needed to make safer changes without database-reading crashes or type errors.

Instructions file for GitHub Copilot

Written for GitHub Copilot: a Copilot instructions file.

This is nbari/pg_exporter's own configuration. It tells GitHub Copilot how to work on pg_exporter itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything pg_exporter configures →

Needs its repository: it runs a file that does not travel with it, so clone the repository first. The line is ./scripts/setup-local-test-db.sh.

Reuse

Borrowing it

Nothing to install: this file belongs to nbari/pg_exporter. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/nbari/pg_exporter/main/.github/copilot-instructions.md
Clone the repo
git clone --depth 1 https://github.com/nbari/pg_exporter

Made for: GitHub Copilot.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pg_exporter copilot-instructions.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/nbari/pg_exporter/copilot-instructions/github.svg)](https://agentmods.dev/instructions/nbari/pg_exporter/copilot-instructions)
Your own site
<a href="https://agentmods.dev/instructions/nbari/pg_exporter/copilot-instructions"><img src="https://agentmods.dev/badge/instructions/nbari/pg_exporter/copilot-instructions/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pg_exporter copilot-instructions.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/nbari/pg_exporter/copilot-instructions"><img src="https://agentmods.dev/badge/instructions/nbari/pg_exporter/copilot-instructions.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 1,924 This file is loaded in full into every session.
When invoked 1,924 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.01924 $0.01924
Opus 5.5 $0.00770 $0.00770
Sonnet 5.5 $0.00385 $0.00385
Haiku 4.5 $0.00192 $0.00192

Measured 2mo ago against content hash 1e06b0ae31b4, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

pg_exporter copilot-instructions.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/copilot-instructions.md · 286 lines

How it starts

The opening of the file, as written. The whole thing — 286 lines — stays where its author put it; the contents beside it link to each section on GitHub.

GitHub Copilot Instructions for pg_exporter

Project Overview

This is a PostgreSQL metrics exporter written in Rust. It collects metrics from PostgreSQL and exposes them in Prometheus format. Safety and reliability are paramount - all code must handle edge cases gracefully without panics.

Language & Tooling

  • Language: Rust (latest stable)
  • Formatting: cargo fmt --all -- --check
  • Linting: cargo clippy --all-targets --all-features -- -D warnings
  • Testing: just test (runs clippy, fmt, and all tests)
  • Build Tool: just command runner (see .justfile)

Critical Safety Rules

1. Always Use try_get() Instead of get()

NEVER use row.get() - it panics on NULL or type mismatches.

// ❌ WRONG - Will panic on NULL
let value: i64 = row.get("column");

// ✅ CORRECT - Safe handling
let value: i64 = row.try_get("column").unwrap_or(0);

2. Always Cast SQL Numeric Columns

PostgreSQL NUMERIC type doesn't directly map to Rust types. Always use explicit casts.

// ❌ WRONG - Type mismatch
SELECT total_time FROM pg_stat_statements

// ✅ CORRECT - Explicit cast
SELECT total_time::double precision FROM pg_stat_statements
SELECT calls::bigint FROM pg_stat_statements

3. Always Check Denominator Before Division

Prevent division by zero in both SQL and Rust.

// ❌ WRONG - Division by zero
let ratio = hits / (hits + misses);

// ✅ CORRECT - Safe division
let total = hits + misses;
let ratio = if total > 0 { hits as f64 / total as f64 } else { 0.0 };

SQL version:

-- ✅ CORRECT
CASE WHEN (shared_blks_hit + shared_blks_read) > 0
     THEN shared_blks_hit::double precision / (shared_blks_hit + shared_blks_read)
     ELSE 0.0
END as cache_hit_ratio

4. Always Check Extension Availability

Handle missing extensions gracefully with fetch_optional().

// ✅ CORRECT - Check extension exists
let result = sqlx::query("SELECT * FROM pg_stat_statements LIMIT 1")
    .fetch_optional(&pool)
    .await?;

if result.is_none() {
    warn!("pg_stat_statements extension not available");
    return Ok(());
}

Read the full file on GitHub · 286 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 286 lines · 1,924 tokens per session scan A 1e06b0ae31b4

Subscribe to this mod's changes

pg_exporter copilot-instructions.md is an instructions file published in the GitHub repository nbari/pg_exporter (52 stars, last pushed 13d ago), licensed BSD-3-Clause. It adds 1,924 tokens to every session, about $0.0077 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

pg_exporter copilot-instructions.md compared with instructions from other repositories

pg_exporter copilot-instructions.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
pg_exporter copilot-instructions.mdnbari/pg_exporterInstructions file5213d agoBSD-3-ClauseA1,924GitHub Copilot
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149ktodayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file274k2d agoMITA4,313Codex, OpenCode