Improve CLAUDE.md docs and add bash style rules

Expand CLAUDE.md with detailed helper function reference,
environment variables section, and commit conventions.
Add .claude/rules/bash-style.md for bash coding standards.
This commit is contained in:
lachtan
2026-03-15 14:36:53 +01:00
parent ef57d56b2c
commit f8a61e9290
2 changed files with 93 additions and 6 deletions

View File

@@ -1,6 +1,7 @@
# CLAUDE.md
# Linux Workspace
Dotfiles & workstation automation for Linux, macOS, WSL. `bashrc` loads `rc/*.sh` (ordered by prefix) and adds `bin/` to PATH. `$LWS` points to repo root.
Dotfiles & workstation automation for Linux, macOS, WSL. `bashrc` loads `rc/*.sh` (ordered by prefix)
and adds `bin/` to PATH. `$LWS` points to repo root.
## Directory Layout
@@ -9,19 +10,34 @@ Dotfiles & workstation automation for Linux, macOS, WSL. `bashrc` loads `rc/*.sh
- `bin/` — Scripts auto-added to PATH. New CLI tools go here.
- `scripts/` — Setup scripts NOT on PATH (git-config, docker fixes, gnome config).
- `conf/` — Tool configs (vim, WireGuard, WSL).
- `functions.sh` — Core lib: `append_path`, `prepend_path`, `set_uniq_path`, `source_directory_sh`, `is_fast_init`/`is_slow_init`, WSL detection, debug logging.
- `functions.sh` — Core lib (see below).
## Key Helpers (`functions.sh`)
- `can_run <cmd>` — check if command is available
- `is_slow_init` / `is_fast_init` — check `LWS_FAST` mode
- `is_interactive_shell` — true when `[[ $- == *i* ]]`
- `is_wsl` — detect WSL environment
- `true_false <val>` — normalize `1/true/yes` to boolean
- `prepend_path` / `append_path` / `prepend_path_try` / `append_path_try` — safe PATH manipulation
- `source_try <file>` — source file if it exists
- `source_directory_sh <dir>` — source all `*.sh` in a directory
- `xlog <msg>` — debug log (only in interactive + `LWS_DEBUG`)
## Conventions
All new bash scripts MUST use:
All new bash scripts should use:
```bash
#!/usr/bin/env bash
set -E -o errexit -o nounset -o pipefail
```
Before writing shell code, check `functions.sh` for existing helper functions (e.g. `can_run`, `append_path_try`, `source_try`) and prefer them over raw commands.
Before writing shell code, check `functions.sh` for existing helper functions and prefer them over raw commands.
RC files MUST guard slow tools and check availability:
```bash
if is_slow_init && can_run pyenv; then
# initialize pyenv
@@ -30,4 +46,11 @@ fi
Installers (`install/*.sh`) MUST be idempotent — check before installing.
Env vars: `LWS_FAST=1` skips slow tools, `LWS_DEBUG=1` enables debug logging.
## Environment Variables
- `LWS_FAST=1` — skips slow tools during shell init
- `LWS_DEBUG=1` — enables debug logging via `xlog`
## Commits
Do not add `Co-Authored-By` lines to commit messages.