Skip to main content
skill CX Codex

planetscale-codebase-sqlcommenter-instrumentation — Claude Code skill

Inspects a repo connected to PlanetScale and recommends an SQLCommenter-compatible package for tagging queries. Use it when queries in Insights and Traffic Control need to map back to code paths.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add planetscale/skills --skill planetscale-codebase-sqlcommenter-instrumentation -a claude-code
Open on GitHub

What planetscale-codebase-sqlcommenter-instrumentation does

The skill walks through the repository and identifies the language, framework, ORM, database adapter, migration tool, background jobs, routing, and whether the connection targets Vitess, Postgres, or both. Then it maps the detected stack to a package recommendation.

Rails gets activerecord-sql_commenter from PlanetScale, Laravel gets spatie/laravel-sql-commenter, Prisma projects get the first-party @prisma/sqlcommenter packages. If no maintained package fits, the skill recommends manual tagging at the database client boundary with URL-encoded, low-cardinality values.

It does not edit files or install dependencies without approval. The output lists the detected stack, current tagging state, recommended package, proposed tag schema, files likely to change, validation steps, and risks. The validation plan includes confirming comments survive the ORM, driver, and pooler, and that no secrets or PII leak into tags. For Postgres, Traffic Control must be able to match the intended tags.

What it helps with

  • pick an SQLCommenter package for the detected stack
  • design a tag schema for query attribution
  • spot files that need changes for instrumentation
  • verify tags survive the pooler and reach Insights
  • keep secrets and PII out of query comments

Example prompts for the agent

  • inspect this repo and recommend SQLCommenter instrumentation
  • what tagging package fits this Rails project for PlanetScale
  • check whether query comments survive the pooler on the way to Insights

How to install planetscale-codebase-sqlcommenter-instrumentation

1Skills CLI (Vercel)

npx skills add planetscale/skills --skill planetscale-codebase-sqlcommenter-instrumentation -a claude-code

2Manually: put the files in place

~/.claude/skills/planetscale-codebase-sqlcommenter-instrumentation/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/planetscale-codebase-sqlcommenter-instrumentation/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about planetscale-codebase-sqlcommenter-instrumentation

How do I install planetscale-codebase-sqlcommenter-instrumentation in Claude Code?

Run npx skills add planetscale/skills --skill planetscale-codebase-sqlcommenter-instrumentation -a claude-code. The skill lands in ~/.claude/skills/planetscale-codebase-sqlcommenter-instrumentation/SKILL.md.

What does planetscale-codebase-sqlcommenter-instrumentation do?

It inspects an application repository connected to PlanetScale and recommends the right SQLCommenter-style instrumentation. That lets PlanetScale Insights and Postgres Traffic Control attribute queries to application code paths.

Which tags does the skill recommend?

The baseline policy asks for stable, bounded values, normalized routes, app/service/job attribution, deploy SHA, and source type. Secrets, PII, user IDs, request IDs, raw tenant IDs, and raw URLs stay out.

Source text

SKILL.md · MIT
---
name: planetscale-codebase-sqlcommenter-instrumentation
description: Inspect an application repository connected to PlanetScale and recommend SQLCommenter-compatible query tagging packages and conventions.
---

# Codebase SQLCommenter instrumentation

## Purpose

Inspect the application repository connected to PlanetScale and recommend the correct SQLCommenter-style instrumentation so PlanetScale Insights and Postgres Traffic Control can attribute queries to application code paths. Do not edit files or install dependencies without approval.

## Repository inspection

Identify:

- Language and framework.
- ORM or query builder.
- Database adapter.
- Migration tool.
- Background job system.
- Routing framework.
- Deployment metadata source, such as git SHA or release ID.
- Existing SQL comments, query tags, tracing, OpenTelemetry, or database middleware.
- PlanetScale connection configuration.
- Whether the repository connects to Vitess, Postgres, or both.

## Recommended package mapping

Use the most native maintained option for the detected stack.

### Ruby on Rails / ActiveRecord

Preferred for PlanetScale tag compatibility:

- `activerecord-sql_commenter` from PlanetScale when Rails query comments need SQLCommenter format for PlanetScale Query Insights.

Other options:

- Rails built-in query logs when sufficient and compatible with the target database/Insights behavior.
- `marginalia` for older Rails or when Basecamp-style ActiveRecord query attribution is already in use.
- `sqlcommenter_rails` where the project already uses the OpenTelemetry SQLCommenter ecosystem.

Recommend tags:

- `application`
- `controller`
- `action`
- `job`
- `route`
- `release_sha`

### Laravel / PHP

Preferred:

- `spatie/laravel-sql-commenter` for SQLCommenter-format comments compatible with PlanetScale Query Insights.

Recommend tags:

- `application`
- `route`
- `controller`
- `action`
- `job`
- `queue`
- `release_sha`

### Prisma / TypeScript / JavaScript

Preferred:

- Prisma’s first-party SQL comments packages when Prisma is detected:
  - `@prisma/sqlcommenter`
  - `@prisma/sqlcommenter-query-tags`
  - `@prisma/sqlcommenter-trace-context`

Note: PlanetScale’s Postgres query-tag docs may list Prisma as lacking official SQLCommenter support, but Prisma’s own current docs provide first-party SQLCommenter packages. Prefer current Prisma docs when Prisma is detected.

Recommend tags:

- `application`
- `service`
- `route`
- `operation`
- `feature`
- `release_sha`

### Knex / Sequelize / Express / Node

Use SQLCommenter-compatible middleware or instrumentation from the OpenTelemetry SQLCommenter ecosystem where maintained and compatible.

Recommend tags:

- `application`
- `service`
- `route`
- `controller`
- `action`
- `feature`
- `release_sha`

### Kysely / Drizzle / Bun / custom query builders

If there is no maintained SQLCommenter package, recommend manual tagging at the database client boundary or query builder extension layer.

Requirements:

- Tags must be structured SQL comments.
- Tags must be inserted before the statement terminator.
- Tags must survive ORM, proxy, and pooler behavior.
- Values must be URL encoded and safe for SQL comments.
- Tags must be low-cardinality.

### Django / SQLAlchemy / psycopg2 / Flask / Python

Use SQLCommenter instrumentation from the OpenTelemetry SQLCommenter ecosystem where compatible.

Recommend tags:

- `application`
- `framework`
- `route`
- `view`
- `job`
- `release_sha`

### Java / Hibernate / Spring

Use SQLCommenter-compatible instrumentation for Hibernate/Spring where compatible.

Recommend tags:

- `application`
- `service`
- `controller`
- `action`
- `route`
- `release_sha`

### Go / database/sql / net/http / gorilla/mux

Use SQLCommenter-compatible instrumentation or a database wrapper at the query boundary.

Recommend tags:

- `application`
- `service`
- `handler`
- `route`
- `job`
- `release_sha`

## Standard tag policy

Recommend this baseline across all frameworks:

- Stable, bounded values only.
- Normalize routes before tagging.
- Include app/service/job attribution.
- Include deploy SHA.
- Include source type for agents, scripts, BI, workers, and integrations.
- Do not include secrets, PII, user IDs, request IDs, raw tenant IDs, or raw URLs.

## Validation plan

Before recommending merge:

- Confirm generated SQL comments appear in local/staging query logs.
- Confirm comments survive the ORM, driver, pooler, and PlanetScale connection path.
- Confirm Insights displays tags.
- Confirm tag cardinality is bounded.
- Confirm Traffic Control can match the intended tags for Postgres.
- Confirm no sensitive data is present.

## Output

Return:

- Detected stack.
- Current query tagging state.
- Recommended package or manual instrumentation path.
- Proposed tag schema.
- Files likely to change.
- Validation steps.
- Risks.
- Proposed changes requiring approval.

End with:

“No repository files or dependencies have been changed.”

© planetscale · MIT · planetscale/skills

Similar skills

All skills for Data and databases →

From the same set14

planetscale-postgres-safety-review Reviews PlanetScale Postgres setups across roles, pg_strict, Traffic Control, and backups. It flags database reliability gaps without applying unapproved changes. CX Codex +1 1,800installs planetscale-best-practices-matrix The skill maps database findings to PlanetScale recommendations and tells you what applies to Vitess and what to Postgres. CX Codex +1 1,800installs planetscale-vitess-safety-review Reviews a PlanetScale Vitess database for safe migrations, deploy requests, Insights and webhooks. Produces a report, applies nothing. CX Codex +1 1,700installs planetscale-webhook-automation-recommendations Recommends PlanetScale webhook subscriptions and safe automation patterns for database alerts, anomalies, and deploy requests. CX Codex +1 1,700installs planetscale-customer-report-template Turns inventory and review results into the final PlanetScale best-practices report for a customer database, with recommendations tied to measurements. CX Codex +1 1,700installs planetscale-traffic-control-recommendations This skill drafts a recommendation plan for PlanetScale Postgres Traffic Control budgets and rules, and applies nothing without approval. CX Codex +1 1,700installs planetscale-readonly-inventory Collects read-only inventory data from PlanetScale databases, branches, backups, and Query Insights. It audits infrastructure setup without risking mutations or secret generation. CX Codex +1 1,700installs planetscale-pscale-cli-automation Teaches coding agents to run the PlanetScale CLI non-interactively with JSON output. Useful when automating database tasks and verifying authentication. CX Codex +1 1,700installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor