go-crypto-wallet / database
Cursor rule128 starsChanged 7 months agoMITView on GitHub
sqlc File Rules
We split this sqlc.mdc into the rules it gives an agent
7 rules. About 0 are common, 5 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
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
- Very specific: line 188
Use descriptive names: GetAccountByID, ListPendingTransactions
- Very specific: line 194
Avoid SELECT * in production queries when possible
- Distinctive: line 195
Use pagination for large result sets
- Distinctive: line 199
Never include sensitive data in query comments
- Distinctive: line 200
Use parameterized queries (SQLC handles this)
- Distinctive: line 204
Keep query names consistent across postgres and mysql query files
- Distinctive: line 205
When adding a new query, add it to both dialects
≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule 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.
Files
---
description: sqlc File Rules
alwaysApply: true
[
"tools/sqlc/**/*.sql",
"tools/sqlc/*.yml",
"internal/infrastructure/database/*/sqlcgen/*.go",
]
---
# sqlc File Rules
## Overview
Rules for modifying SQLC-related files in go-crypto-wallet.
The project supports **three database backends**: PostgreSQL (default), MySQL, and SQLite.
## File Categories
| Path | Description | Editable |
| -------------------------------------------------------- | ----------------------------------- | -------------- |
| `tools/sqlc/queries/postgres/*.sql` | SQLC query definitions (PostgreSQL) | Yes |
| `tools/sqlc/queries/mysql/*.sql` | SQLC query definitions (MySQL) | Yes |
| `tools/sqlc/schemas/postgres/*.sql` | SQLC schema files (PostgreSQL) | Auto-generated |
| `tools/sqlc/schemas/mysql/*.sql` | SQLC schema files (MySQL) | Auto-generated |
| `tools/sqlc/schemas/sqlite/*.sql` | SQLC schema files (SQLite) | Auto-generated |
| `tools/sqlc/sqlc_postgres.yml` | SQLC config (PostgreSQL) | Yes |
| `tools/sqlc/sqlc_mysql.yml` | SQLC config (MySQL) | Yes |
| `tools/sqlc/sqlc_sqlite.yml` | SQLC config (SQLite) | Yes |
| `internal/infrastructure/database/postgres/sqlcgen/*.go` | Generated Go code (PostgreSQL) | Auto-generated |
| `internal/infrastructure/database/mysql/sqlcgen/*.go` | Generated Go code (MySQL) | Auto-generated |
| `internal/infrastructure/database/sqlite/sqlcgen/*.go` | Generated Go code (SQLite) | Auto-generated |
| `tools/atlas/migrations/**/*.sql` | Atlas migration files | Auto-generated |
| `docker/*.sql` | Initial data/seed scripts | Yes |
## Verification Commands
### SQLC Validation
| Command | Purpose | Required |
| -------------------- | ----------------------------------------------- | ----------- |
| `make sqlc-compile` | Check syntax and type errors (postgres + mysql) | Yes |
| `make sqlc-vet` | Check for potential issues (postgres + mysql) | Yes |
| `make sqlc-validate` | Compile + vet combined | Recommended |
| `make sqlc-lint` | Alias for sqlc-vet | |
### After Changes
```bash
# 1. Validate queries
make sqlc-validate
# 2. Generate Go code (default: postgres)
make sqlc
# 3. Verify Go build
make check-build
```
## SQLC Query Files
### Locations
- PostgreSQL: `tools/sqlc/queries/postgres/*.sql` (default)
- MySQL: `tools/sqlc/queries/mysql/*.sql`
### Query Syntax
**PostgreSQL** (uses `$1`, `$2`, ... for parameters):
```sql
-- name: GetAccountByID :one
SELECT * FROM account_key
WHERE id = $1;
-- name: ListAccountsByAccountType :many
SELECT * FROM account_key
WHERE account_type = $1
ORDER BY id;
-- name: CreateAccount :execresult
INSERT INTO account_key (
coin_type, account_type, account, full_pubkey_idx
) VALUES ($1, $2, $3, $4);
```
**MySQL** (uses `?` for parameters):
```sql
-- name: GetAccountByID :one
SELECT * FROM account_key
WHERE id = ?;
```
### Query Annotations
| Annotation | Description |
| ------------- | --------------------------------- |
| `:one` | Returns single row |
| `:many` | Returns multiple rows |
| `:exec` | Executes without return |
| `:execresult` | Returns result with affected rows |
| `:execrows` | Returns number of affected rows |
## Auto-Generated Files
**DO NOT EDIT** the following files:
### SQLC Schema Files
- `tools/sqlc/schemas/postgres/*.sql`
- `tools/sqlc/schemas/mysql/*.sql`
- `tools/sqlc/schemas/sqlite/*.sql`
These are extracted from database dumps. Regenerate with:
```bash
# Extract schemas from running database (default: postgres)
make extract-sqlc-schema-all
# For MySQL
make extract-sqlc-schema-all DB_DIALECT=mysql
```
### SQLC Generated Go Code
- `internal/infrastructure/database/postgres/sqlcgen/*.go`
- `internal/infrastructure/database/mysql/sqlcgen/*.go`
- `internal/infrastructure/database/sqlite/sqlcgen/*.go`
Regenerate with:
```bash
# PostgreSQL (default)
make sqlc
# MySQL
make sqlc-mysql
# SQLite
make sqlc-sqlite
# All backends
make sqlc-all
```
### Atlas Migration Files
- `tools/atlas/migrations/**/*.sql`
- `tools/atlas/migrations/*/atlas.sum`
These are generated from HCL schemas. Use HCL files as the source of truth.
## Workflow for Query Changes
```bash
# 1. Edit query files
# tools/sqlc/queries/postgres/*.sql (and/or mysql)
# 2. Validate
make sqlc-validate
# 3. Generate Go code
make sqlc # postgres (default)
make sqlc-mysql # mysql
make sqlc-all # all backends
# 4. Verify build
make check-build
# 5. Run tests
make go-test
```
## Full Regeneration from Running Database
```bash
# Regenerate schemas + Go code from current database
make regenerate-sqlc-from-current-db # postgres (default)
make regenerate-sqlc-from-current-db DB_DIALECT=mysql # mysql
```
## Best Practices
### Query Naming
- Use descriptive names: `GetAccountByID`, `ListPendingTransactions`
- Prefix with action: `Get`, `List`, `Create`, `Update`, `Delete`
### Efficiency
- Use appropriate indexes
- Avoid `SELECT *` in production queries when possible
- Use pagination for large result sets
### Security
- Never include sensitive data in query comments
- Use parameterized queries (SQLC handles this)
### Multi-Dialect Consistency
- Keep query names consistent across postgres and mysql query files
- When adding a new query, add it to both dialects
## Quick Checklist
- [ ] `make sqlc-compile` passes
- [ ] `make sqlc-vet` passes
- [ ] Query names are descriptive
- [ ] Appropriate return type annotation (`:one`, `:many`, etc.)
- [ ] `make sqlc` generates without errors
- [ ] `make check-build` passes
## Related Documentation
- @docs/database/db-management.md - Database management guide
- @tools/sqlc/ - SQLC configuration and files
## Related Skills
- `db-migration` - Database schema workflow
- `go-development` - Go verification after SQLC generation
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 3,978 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository62 other files it gives its agents.
- AGENTS.mdAGENTS.md
- internal/AGENTS.mdAGENTS.md
- pkg/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- internal/CLAUDE.mdCLAUDE.md
- pkg/CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/agent-files.mdcCursor rule
- .cursor/rules/apps/bun.mdcCursor rule
- .cursor/rules/apps/eth-contracts.mdcCursor rule
- .cursor/rules/apps/xrp-server.mdcCursor rule
- .cursor/rules/database/atlas-hcl.mdcCursor rule
- .cursor/rules/documentation-language.mdcCursor rule
- .cursor/rules/general.mdcCursor rule
- .cursor/rules/github-actions.mdcCursor rule
- .cursor/rules/go/conventions.mdcCursor rule
- .cursor/rules/go/di.mdcCursor rule
- .cursor/rules/go/go-path.mdcCursor rule
- .cursor/rules/go/go-test.mdcCursor rule
- .cursor/rules/internal/application-layer.mdcCursor rule
- .cursor/rules/internal/btc-shared.mdcCursor rule
- .cursor/rules/internal/clean-architecture.mdcCursor rule
- .cursor/rules/internal/cli-structure.mdcCursor rule
- .cursor/rules/internal/domain-layer.mdcCursor rule
- .cursor/rules/internal/dto.mdcCursor rule
- .cursor/rules/internal/infrastructure-layer.mdcCursor rule
- .cursor/rules/internal/interface-adapters-layer.mdcCursor rule
- .cursor/rules/internal/internal-interface.mdcCursor rule
- .cursor/rules/internal/mockery.mdcCursor rule
- .cursor/rules/internal/repository.mdcCursor rule
- .cursor/rules/internal/usecase.mdcCursor rule
- .cursor/rules/proto.mdcCursor rule
- .cursor/rules/README.mdCursor rule
- .cursor/rules/security.mdcCursor rule
- .cursor/rules/shell-script.mdcCursor rule
- .cursor/rules/ssot.mdcCursor rule
- .cursor/rules/task-context-loading.mdcCursor rule
- .cursor/rules/typescript.mdcCursor rule
- .cursor/rules/yaml.mdcCursor rule
- llms.txtllms.txt
- bch-developmentSkill
- btc-terminologySkill
- db-migrationSkill
- devopsSkill
- docs-ssotSkill
- docs-updateSkill
- fix-pr-reviewSkill
- github-issue-creationSkill
- git-workflowSkill
- go-developmentSkill
- knowledge-gapSkill
- label-context-mappingSkill
- makefile-updateSkill
- mockerySkill
- openspec-apply-changeSkill
- openspec-archive-changeSkill
- openspec-exploreSkill
- openspec-proposeSkill
- shell-scriptsSkill
- solidity-developmentSkill
- The first 60 shown.
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
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.

