Planetscale Codebase Sqlcommenter Instrumentation
PlanetScaleOfficialPublished by PlanetScale
- Skill
- Research and analysis
- Software development
- MIT
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill inspects an application repository to determine the optimal SQLCommenter-compatible instrumentation strategy. By identifying the language, framework, and database interaction patterns, it provides tailored recommendations for tagging SQL queries. This enables developers to attribute database activity to specific application code paths within PlanetScale Query Insights and Postgres Traffic Control, while adhering to strict data privacy and cardinality standards.
What it does
- Inspects application stacks including languages, ORMs, and database adapters.
- Maps detected stacks to recommended SQLCommenter packages or manual instrumentation patterns.
- Defines a standard tag policy to ensure query attribution remains stable and secure.
- Provides a validation plan to verify that tags appear correctly in query logs and Insights.
- Outlines potential risks and necessary changes for implementation.
- Ensures no automated changes are made to the repository without explicit approval.
When to use it
- When you need to improve visibility into which application code paths are generating specific database queries.
- When setting up PlanetScale Query Insights or Postgres Traffic Control.
- When you need to ensure query tags are properly formatted and safe for production environments.
- When auditing an existing codebase to standardize how database queries are attributed to services or jobs.
Advantages
- Enables granular performance monitoring by linking SQL queries to application logic.
- Provides framework-specific guidance for popular stacks like Rails, Laravel, and Prisma.
- Promotes security by enforcing a policy that excludes PII and secrets from query tags.
- Reduces debugging time by providing clear attribution in database logs.
Usage examples
- “Analyze my Rails application to recommend the best way to tag queries for PlanetScale.”
- The agent will inspect the Gemfile and database configuration, then recommend the appropriate SQLCommenter package and a standard tag schema for your Rails controllers and jobs.
- “How should I tag my Prisma queries in a TypeScript project for PlanetScale Insights?”
- The agent will identify the Prisma setup and recommend the official @prisma/sqlcommenter packages, along with a list of recommended tags like service, route, and release_sha.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/planetscale/planetscale-codebase-sqlcommenter-instrumentation/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip planetscale-codebase-sqlcommenter-instrumentation.zip -d .agents/skills
Documentation by PlanetScale
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_commenterfrom 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.
marginaliafor older Rails or when Basecamp-style ActiveRecord query attribution is already in use.sqlcommenter_railswhere the project already uses the OpenTelemetry SQLCommenter ecosystem.
Recommend tags:
applicationcontrolleractionjobrouterelease_sha
Laravel / PHP
Preferred:
spatie/laravel-sql-commenterfor SQLCommenter-format comments compatible with PlanetScale Query Insights.
Recommend tags:
applicationroutecontrolleractionjobqueuerelease_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:
applicationservicerouteoperationfeaturerelease_sha
Knex / Sequelize / Express / Node
Use SQLCommenter-compatible middleware or instrumentation from the OpenTelemetry SQLCommenter ecosystem where maintained and compatible.
Recommend tags:
applicationserviceroutecontrolleractionfeaturerelease_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:
applicationframeworkrouteviewjobrelease_sha
Java / Hibernate / Spring
Use SQLCommenter-compatible instrumentation for Hibernate/Spring where compatible.
Recommend tags:
applicationservicecontrolleractionrouterelease_sha
Go / database/sql / net/http / gorilla/mux
Use SQLCommenter-compatible instrumentation or a database wrapper at the query boundary.
Recommend tags:
applicationservicehandlerroutejobrelease_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.”
Files
- ATTRIBUTION.mdAdded by AutoGineer926 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md4.9 KiB
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- PlanetScale
- Publisher
- PlanetScale (Official)
- Source
- planetscale/skills · planetscale-codebase-sqlcommenter-instrumentation · commit 999045c
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by PlanetScale.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download planetscale-codebase-sqlcommenter-instrumentation.zip