agentleFS
TeddyAlbinaTeddyAlbina/skills/cockroachdb-sql/SKILL.md

cockroachdb-sql

Skill2 starsChanged 27 days agoMITView on GitHub

Use when writing, generating, or optimizing SQL for CockroachDB, designing CockroachDB schemas, or when the user asks about CockroachDB-specific SQL patterns, type mappings, and distributed database best practices. Also use when encountering CockroachDB anti-patterns like missing primary keys, sequential ID hotspots, or incorrect type usage.

2 other projects use a version of this, 2 of them edited.

Adopted by

Most recently taken up by

The file

Show its rules and text

We split this skill into the rules it gives an agent

13 rules. About 0 are common, 11 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈11

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Check for existing schema context in conversation

    line 40
  2. Distinctive:

    If connected to DB, query existing schema:

    line 41
  3. Distinctive:

    Ask clarifying questions if needed:

    line 44
  4. Distinctive:

    Ensure compliance with CockroachDB best practices

    line 53
  5. Distinctive:

    ALWAYS run EXPLAIN on every generated SQL query when connected to DB.

    line 64
  6. Distinctive:

    If EXPLAIN returns a parsing/syntax error, fix the query and re-run EXPLAIN until it passes.

    line 65
  7. Distinctive:

    When skill is invoked, ALWAYS:

    line 72
  8. Distinctive:

    Immediately detect connection: before any other action or response:

    line 73
  9. Distinctive:

    Check if connection string is provided in the prompt (postgresql://...).

    line 74
  10. Very specific:

    If provided, use cockroach sql --url "<provided-url>" -e "SQL" to run queries.

    line 75
  11. Very specific:

    If set, use cockroach sql --url $COCKROACH_URL -e "SQL" to run queries.

    line 77
  12. Distinctive:

    Keep user-facing content CockroachDB-specific regardless of internal PostgreSQL rules.

    line 82
  13. Distinctive:

    When optimizing, at each step 1- Explain the step's purpose.

    line 88

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

CockroachDB SQL Skill

Converts natural language questions into CockroachDB-compliant SQL queries, following CockroachDB best practices. Use it for schema design, writing queries and optimizing query.

When to Use This Skill

Activate this skill when:

  • User asks for SQL query generation for CockroachDB
  • User provides natural language descriptions of database operations
  • User asks questions like:
    • "How do I query recent orders in CockroachDB?"
    • "Generate a CockroachDB table for user management"
    • "Convert this to CockroachDB SQL: [description]"
    • "What's the CockroachDB way to [operation]?"
  • When you encounter:
    • CREATE TABLE statements
    • ALTER TABLE modifications
    • DML Operations (INSERT, UPDATE, DELETE)
    • SELECT queries
    • Performance optimization requests
    • Backup/restore operations

How to Apply this Skill

  1. Connection Detection — already performed on skill invocation; reuse active connection.
  2. Parse Natural Language Intent
    • Identify the operation type (SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, etc.)
  3. Context Gathering
    • Check for existing schema context in conversation
    • If connected to DB, query existing schema:
      • SHOW TABLES; to see existing tables
      • SHOW CREATE TABLE table_name; for existing structure
    • Ask clarifying questions if needed:
      • Table structure if not provided
      • Data types for columns
      • Index requirements
      • Multi-region needs
      • Performance characteristics
  4. Apply CockroachDB Rules
    • Reference rules in references/cockroachdb-rules/
    • Ensure compliance with CockroachDB best practices
    • Determine rule category based on operation and apply the relavant rules:
      • 00-fundamental-principles.md - Always apply these first
      • 01-schema-design.md - Table creation and structure
      • 02-dml-operations.md - Data modification
      • 03-query-patterns.md - Query construction
      • 04-optimization.md - Performance, Optimization and anti-patterns
      • 05-operational.md - Admin and maintenance
    • Validate against anti-patterns in 04-optimization.md
  5. Validate against DB(MANDATORY)
    • ALWAYS run EXPLAIN on every generated SQL query when connected to DB.
    • If EXPLAIN returns a parsing/syntax error, fix the query and re-run EXPLAIN until it passes.
    • Include the EXPLAIN output in the response.

Response Behavior

Initial Response

When skill is invoked, ALWAYS:

  1. Immediately detect connection before any other action or response:
    • Check if connection string is provided in the prompt (postgresql://...).
      • If provided, use cockroach sql --url "<provided-url>" -e "SQL" to run queries. Do not use psql.
    • Else check COCKROACH_URL environment variable (echo $COCKROACH_URL).
      • If set, use cockroach sql --url $COCKROACH_URL -e "SQL" to run queries. Do not use psql.
    • Else check for cockroach-cloud MCP server availability
  2. Focus exclusively on CockroachDB
  3. Emphasize "natural language to CockroachDB SQL" not "database conversion"
  4. Keep user-facing content CockroachDB-specific regardless of internal PostgreSQL rules.

Output Format

  • Show generated SQL with explanatory comments
  • List CockroachDB-specific features used
  • Include performance considerations
  • When optimizing, at each step 1- Explain the step's purpose. 2- Execute the step and report the outcome. 3- Summarize all findings and actions taken.
  • Provide references used including the rules

Supporting Documentation

  • references/cockroachdb-rules/ - CockroachDB SQL rules
  • references/EXAMPLES.md - SQL examples and patterns

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.