|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | + |
| 5 | +- `lua/claudecode/`: Core plugin modules (`init.lua`, `config.lua`, `diff.lua`, `terminal/`, `server/`, `tools/`, `logger.lua`, etc.). |
| 6 | +- `plugin/`: Lightweight loader that guards startup and optional auto-setup. |
| 7 | +- `tests/`: Busted test suite (`unit/`, `integration/`, `helpers/`, `mocks/`). |
| 8 | +- `fixtures/`: Minimal Neovim configs for manual and integration testing. |
| 9 | +- `scripts/`: Development helpers; `dev-config.lua` aids local testing. |
| 10 | + |
| 11 | +## Build, Test, and Development Commands |
| 12 | + |
| 13 | +- `make check`: Syntax checks + `luacheck` on `lua/` and `tests/`. |
| 14 | +- `make format`: Format with StyLua (via Nix `nix fmt` in this repo). |
| 15 | +- `make test`: Run Busted tests with coverage (outputs `luacov.stats.out`). |
| 16 | +- `make clean`: Remove coverage artifacts. |
| 17 | + Examples: |
| 18 | +- Run all tests: `make test` |
| 19 | +- Run one file: `busted -v tests/unit/terminal_spec.lua` |
| 20 | + |
| 21 | +## Coding Style & Naming Conventions |
| 22 | + |
| 23 | +- Lua: 2‐space indent, 120‐column width, double quotes preferred. |
| 24 | +- Formatting: StyLua configured in `.stylua.toml` (require-sort enabled). |
| 25 | +- Linting: `luacheck` with settings in `.luacheckrc` (uses `luajit+busted` std). |
| 26 | +- Modules/files: lower_snake_case; return a module table `M` with documented functions (EmmyLua annotations encouraged). |
| 27 | +- Avoid one-letter names; prefer explicit, testable functions. |
| 28 | + |
| 29 | +## Testing Guidelines |
| 30 | + |
| 31 | +- Frameworks: Busted + Luassert; Plenary used where Neovim APIs are needed. |
| 32 | +- File naming: `*_spec.lua` or `*_test.lua` under `tests/unit` or `tests/integration`. |
| 33 | +- Mocks/helpers: place in `tests/mocks` and `tests/helpers`; prefer pure‐Lua mocks. |
| 34 | +- Coverage: keep high signal; exercise server, tools, diff, and terminal paths. |
| 35 | +- Quick tip: prefer `make test` (it sets `LUA_PATH` and coverage flags). |
| 36 | + |
| 37 | +## Commit & Pull Request Guidelines |
| 38 | + |
| 39 | +- Commits: Use Conventional Commits (e.g., `feat:`, `fix:`, `docs:`, `test:`, `chore:`). Keep messages imperative and scoped. |
| 40 | +- PRs: include a clear description, linked issues, repro steps, and tests. Update docs (`README.md`, `ARCHITECTURE.md`, or `DEVELOPMENT.md`) when behavior changes. |
| 41 | +- Pre-flight: run `make format`, `make check`, and `make test`. Attach screenshots or terminal recordings for UX-visible changes (diff flows, terminal behavior). |
| 42 | + |
| 43 | +## Security & Configuration Tips |
| 44 | + |
| 45 | +- Do not commit secrets or local paths; prefer environment variables. The plugin honors `CLAUDE_CONFIG_DIR` for lock files. |
| 46 | +- Local CLI paths (e.g., `opts.terminal_cmd`) should be configured in user config, not hardcoded in repo files. |
0 commit comments