|
| 1 | +# Gasket |
| 2 | + |
| 3 | +> **Note:** `CLAUDE.md` is a symlink to `AGENTS.md`. They are the same file. |
| 4 | +
|
| 5 | +## Codebase |
| 6 | + |
| 7 | +- pnpm monorepo (pnpm@10.4.1, Node 22, ESM) |
| 8 | +- 50+ packages in `packages/` |
| 9 | +- Plugin-based architecture — apps composed of gasket plugins and presets |
| 10 | +- TypeScript + JSDoc type safety (see [docs/jsdoc-type-safety.md]) |
| 11 | + |
| 12 | +## Commands |
| 13 | + |
| 14 | +| Task | Command | |
| 15 | +|------|---------| |
| 16 | +| Install | `pnpm install` | |
| 17 | +| Build all | `pnpm run -r build` | |
| 18 | +| Test all | `pnpm -w test` | |
| 19 | +| Test single pkg | `cd packages/<pkg> && pnpm test` | |
| 20 | +| Test w/ coverage | `pnpm -w test:coverage` | |
| 21 | +| Lint | `pnpm -w lint` | |
| 22 | +| Lint all pkgs | `pnpm -w lint:all` | |
| 23 | +| Lint fix | `pnpm -w lint:fix` | |
| 24 | +| Typecheck all | `pnpm -w typecheck:all` | |
| 25 | +| Create changeset | `pnpm run changeset` | |
| 26 | +| New package setup | `pnpm run align-packages` | |
| 27 | +| Generate docs | `pnpm run docs` | |
| 28 | + |
| 29 | +## Code Style |
| 30 | + |
| 31 | +### Functional Programming |
| 32 | + |
| 33 | +- Pure functions: same input, same output, no side effects |
| 34 | +- Immutability: `const`, spread, map/filter/reduce — never mutate args |
| 35 | +- Composition over inheritance: small single-purpose functions |
| 36 | +- Declarative: array methods over for/while loops |
| 37 | +- No module-level mutable state (`let`/`var` at module scope) |
| 38 | +- Separate pure computation from effects; push effects to boundaries |
| 39 | +- No `any` without strong justification; prefer union types + type guards |
| 40 | +- Explicit return types for exported functions |
| 41 | +- Use `readonly` for immutable data structures |
| 42 | + |
| 43 | +### Naming & Files |
| 44 | + |
| 45 | +- kebab-case for files and directories (enforced by `unicorn/filename-case`) |
| 46 | +- JSDoc required for all exported functions (types, params, returns) |
| 47 | +- Comments explain WHY, not WHAT |
| 48 | +- Allowed custom JSDoc tags: `@jest-environment`, `@swagger` |
| 49 | + |
| 50 | +### Error Handling |
| 51 | + |
| 52 | +- Pure functions return error values (null, Result, Either) |
| 53 | +- Exceptions for truly exceptional conditions only |
| 54 | +- All errors typed and documented |
| 55 | + |
| 56 | +## Testing |
| 57 | + |
| 58 | +- Vitest — aim for 100% coverage (statements, branches, functions, lines) |
| 59 | +- Table-driven tests for multiple cases |
| 60 | +- Test edge cases: empty inputs, null, undefined, boundary values |
| 61 | +- Mock/stub only effects, never pure computation |
| 62 | +- Tests must be deterministic and independent |
| 63 | +- CI tests on Node 20.x, 22.x, 24.x |
| 64 | + |
| 65 | +## Changes & PRs |
| 66 | + |
| 67 | +- Reference issue in commits when present |
| 68 | +- Include unit tests for bug fixes |
| 69 | +- Target `main` branch |
| 70 | +- Two approvals to merge small PRs |
| 71 | +- Major design changes: post in [Discussions], allow days for feedback |
| 72 | +- Breaking changes / core refactors: tag a [code owner](./CODEOWNERS) |
| 73 | +- Changesets required: run `pnpm run changeset`, commit the file with PR |
| 74 | + |
| 75 | +## Markdown |
| 76 | + |
| 77 | +- READMEs follow standard heading structure (see [CONTRIBUTING.md] for template) |
| 78 | +- Examples use `####` (H4) headings, prefixed with "Example" |
| 79 | +- Never use `inline code` in headings or links |
| 80 | +- jsdocs2md output goes to `docs/API.md` |
| 81 | +- Prefer reference links over inline |
| 82 | + |
| 83 | +## API Compatibility |
| 84 | + |
| 85 | +- Maintain source compat for public APIs |
| 86 | +- Add, don't change or remove |
| 87 | +- Breaking changes: add shim + migration guide, use `@deprecated` JSDoc tag |
| 88 | + |
| 89 | +## Enforcement |
| 90 | + |
| 91 | +Before committing: |
| 92 | + |
| 93 | +1. `pnpm -w lint:all` |
| 94 | +2. `pnpm -w typecheck:all` |
| 95 | +3. `pnpm -w test` |
| 96 | +4. Verify coverage for modified files |
| 97 | + |
| 98 | +[docs/jsdoc-type-safety.md]: ./docs/jsdoc-type-safety.md |
| 99 | +[CONTRIBUTING.md]: ./CONTRIBUTING.md |
| 100 | +[Discussions]: https://github.com/godaddy/gasket/discussions |
0 commit comments