|
| 1 | +# Agent Guidelines for articulate-parser |
| 2 | + |
| 3 | +## Build/Test Commands |
| 4 | +- **Build**: `task build` or `go build -o bin/articulate-parser main.go` |
| 5 | +- **Run tests**: `task test` or `go test -race -timeout 5m ./...` |
| 6 | +- **Run single test**: `go test -v -race -run ^TestName$ ./path/to/package` |
| 7 | +- **Test with coverage**: |
| 8 | + - `task test:coverage` or |
| 9 | + - `go test -race -coverprofile=coverage/coverage.out -covermode=atomic ./...` |
| 10 | +- **Lint**: `task lint` (runs vet, fmt check, staticcheck, golangci-lint) |
| 11 | +- **Format**: `task fmt` or `gofmt -s -w .` |
| 12 | +- **CI checks**: `task ci` (deps, lint, test with coverage, build) |
| 13 | + |
| 14 | +## Code Style Guidelines |
| 15 | + |
| 16 | +### Imports |
| 17 | +- Use `goimports` with local prefix: `github.com/kjanat/articulate-parser` |
| 18 | +- Order: stdlib, external, internal packages |
| 19 | +- Group related imports together |
| 20 | + |
| 21 | +### Formatting |
| 22 | +- Use `gofmt -s` (simplify) and `gofumpt` with extra rules |
| 23 | +- Function length: max 100 lines, 50 statements |
| 24 | +- Cyclomatic complexity: max 15 |
| 25 | +- Cognitive complexity: max 20 |
| 26 | + |
| 27 | +### Types & Naming |
| 28 | +- Use interface-based design (see `internal/interfaces/`) |
| 29 | +- Export types/functions with clear godoc comments ending with period |
| 30 | +- Use descriptive names: `ArticulateParser`, `MarkdownExporter` |
| 31 | +- Receiver names: short (1-2 chars), consistent per type |
| 32 | + |
| 33 | +### Error Handling |
| 34 | +- Always wrap errors with context: `fmt.Errorf("operation failed: %w", err)` |
| 35 | +- Use `%w` verb for error wrapping to preserve error chain |
| 36 | +- Check all error returns (enforced by `errcheck`) |
| 37 | +- Document error handling rationale in defer blocks when ignoring close errors |
| 38 | + |
| 39 | +### Comments |
| 40 | +- All exported types/functions require godoc comments |
| 41 | +- End sentences with periods (`godot` linter enforced) |
| 42 | +- Mark known issues with TODO/FIXME/HACK/BUG/XXX |
| 43 | + |
| 44 | +### Security |
| 45 | +- Use `#nosec` with justification for deliberate security exceptions (G304 for CLI file paths, G306 for export file permissions) |
| 46 | +- Run `gosec` and `govulncheck` for security audits |
| 47 | + |
| 48 | +### Testing |
| 49 | +- Enable race detection: `-race` flag |
| 50 | +- Use table-driven tests where applicable |
| 51 | +- Mark test helpers with `t.Helper()` |
| 52 | +- Benchmarks in `*_bench_test.go`, examples in `*_example_test.go` |
| 53 | + |
| 54 | +### Dependencies |
| 55 | +- Minimal external dependencies (currently: go-docx, golang.org/x/net, golang.org/x/text) |
| 56 | +- Run `task deps:tidy` after adding/removing dependencies |
0 commit comments