51 lines
2.1 KiB
Markdown
51 lines
2.1 KiB
Markdown
# Global Claude Preferences
|
|
|
|
## SQL Style
|
|
|
|
Always write SQL in this style:
|
|
|
|
- **Keywords UPPERCASE**: SELECT, FROM, WHERE, WITH, GROUP BY, LEFT JOIN, ON, CASE, WHEN, COALESCE, SUM, MAX, etc.
|
|
- **Leading commas**, one column per line, indented under SELECT/GROUP BY
|
|
- **FROM / WHERE / GROUP BY** on their own line, content indented below
|
|
- **LEFT JOIN ... ON** with condition indented on next line
|
|
- **WHERE TRUE** as base condition
|
|
- **CTEs** with `--` comment header; subsequent CTEs start with `,cte_name AS (`
|
|
- `::TYPE` casting over `CAST()`
|
|
- `~` for regex, not LIKE
|
|
- No trailing commas, no unnecessary parentheses
|
|
- Descriptive snake_case aliases
|
|
|
|
Canonical example: `inventory/on_hand/onhand_with_last_mfg.pg.sql` in the SQL repo.
|
|
|
|
## Shell Query Tools
|
|
|
|
PostgreSQL (connection string in `$PG`, defined in `.bashrc_local`):
|
|
- `xnspa` — fzf-select open nvim buffer, run with `$PG`, output to VisiData
|
|
- `xnsp` — same, output to pspg
|
|
- `xns` — same, raw output
|
|
|
|
DuckDB (`/opt/sync/osm_stack.duckdb` snapshot, CLI at `~/.local/bin/duckdb`):
|
|
- `xnd` — fzf-select open nvim buffer, run against DuckDB snapshot, output to VisiData
|
|
- Direct: `duckdb /opt/sync/osm_stack.duckdb < file.du.sql`
|
|
|
|
SQL Server (connection strings `$MS`, `$MSC`, `$MSW` in `.bashrc_local`):
|
|
- `xmspa` — fzf-select open nvim buffer, run with `$MSC`, output to VisiData
|
|
|
|
File extension conventions:
|
|
- `.pg.sql` — PostgreSQL
|
|
- `.ms.sql` — SQL Server
|
|
- `.db2.sql` — IBM DB2
|
|
- `.du.sql` — DuckDB
|
|
|
|
## Nvim Buffer Awareness
|
|
|
|
At the start of every conversation, check for open nvim buffers in the current directory and read them proactively:
|
|
|
|
```bash
|
|
lsof +D ~/.local/state/nvim/swap/ 2>/dev/null | grep -o "/swap/.*" | sed 's|^/swap/||' | tr "%" "/" | sed -E 's/\.sw[op]$//' | grep "$(pwd | sed 's|^//|/|')"
|
|
```
|
|
|
|
## Setup Environment
|
|
|
|
Dotfiles are managed via symlinks from `~/setup_env/dotfiles/`. Editing `~/.<file>` directly edits the repo. Always edit dotfiles at their source (`~/setup_env/dotfiles/`) rather than the symlink target. `_lib.sh` handles deployment; `.bashrc_local` and `.bashrc_paths` are gitignored and machine-specific.
|