check / check (push) Waiting to run
Rewrite the agent rules from scratch, with one idea per sentence and every file name and command in backticks. Drop the rule that models embed `models.Base`, which no package has. Say that the linter keeps tests in external test packages, and that an `export_test.go` file gives them access to unexported code. Limit the rules on doc comments and blank imports to files outside the tests. State magic numbers as a preference, and correct the blank-line rule for `return`. State the branch workflow: pull requests target `next` and only the owner merges `next` into `main`. Record the three snake_case JSON tags the HTTP API keeps. Part of #190. Model: fable-5-1 (writing); opus-5-5 (rework)
3.0 KiB
3.0 KiB
Rules for coding agents
This file holds the rules for coding agents working in this repository.
CONVENTIONS.md defines the architecture. REPO_POLICIES.md defines the
repository standards. Both are copies of shared documents. Do not edit them
here.
Before every commit
- Run
make fmt. - Run
make check. It runs the tests and the linter in Docker, then the format check. All three must pass with no findings.
Never run go test, golangci-lint or gofmt directly. Use the make targets
instead, such as make test and make lint.
Branches and pull requests
- Never commit to
mainornextdirectly. Every change is a pull request from a feature branch intonext. - Only the owner merges
nextintomain. - A pull request that closes an issue has the title
Description (closes #N). - One logical change per commit.
- Commit messages are in the imperative mood and short.
Code style
- Follow
CONVENTIONS.md. - Outside test files, every package has a package doc comment.
- Outside test files, every exported type, function and variable has a doc comment.
- JSON tags are camelCase. The HTTP API's
last_id,pow_tokenandhashcash_bitsstay as they are, each with a//nolint:tagliatellecomment. - Prefer named constants to magic numbers. The
mndlinter checks for them outside test files. - No inline error handling such as
if err := f(); err != nil. Assign the error on its own line, then test it. - A
returnthat follows another statement in its block has a blank line before it. - A blank line between the embedded fields of a struct and its other fields.
- Outside test files, every blank import has a comment saying why it is there.
Architecture
- The server uses
go.uber.org/fxfor dependency injection.cmd/neoircd/main.golists itsfxproviders, such asdb.Newandhandlers.New. - Application packages live under
internal/, one package per concern. pkg/ircholds the IRC command names and numeric reply codes.- The
webpackage embeds the built web client. - Each exported
Handle…method ofHandlersreturns anhttp.HandlerFunc. - A request struct is defined inside the method that decodes it.
- The server uses the database only through the methods of
db.Database. - The database migrations live in
internal/db/schema/and are embedded withgo:embed. - The database is SQLite, through the pure Go driver
modernc.org/sqlite.
Testing
- Prefer table-driven tests.
- Use
testing.Thelpers, not assertion libraries. - A test file lives next to the code it tests and ends in
_test.go. - The linter requires each test file to be in the package's external test
package, such as
handlers_test. It allowsexport_test.goand files ending in_internal_test.goin the package itself. - An
export_test.gofile gives the external tests access to the package's unexported code.
Dependencies
- The required libraries are listed in
CONVENTIONS.md§1. - No new dependency without a reason given in the pull request.
- Prefer dependencies written in pure Go, which build without cgo.