add global CLAUDE.md: sql style, query tools, nvim awareness
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b3c7edb504
commit
26dd25be77
3
_lib.sh
3
_lib.sh
@ -52,6 +52,9 @@ deploy_configs() {
|
|||||||
migrate_and_link "$config_dir/$config" ~/"$config"
|
migrate_and_link "$config_dir/$config" ~/"$config"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
mkdir -p ~/.claude
|
||||||
|
create_symlink "$config_dir/.claude/CLAUDE.md" ~/.claude/CLAUDE.md
|
||||||
|
|
||||||
echo "Sourcing .bashrc..."
|
echo "Sourcing .bashrc..."
|
||||||
source ~/.bashrc
|
source ~/.bashrc
|
||||||
}
|
}
|
||||||
|
|||||||
50
dotfiles/.claude/CLAUDE.md
Normal file
50
dotfiles/.claude/CLAUDE.md
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# 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.
|
||||||
Loading…
Reference in New Issue
Block a user