Skip to content

Commit e111aaa

Browse files
committed
chore: update AI-related files
Signed-off-by: Ilya Lesikov <ilya@lesikov.com>
1 parent 9395ef9 commit e111aaa

4 files changed

Lines changed: 172 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Repository Guidelines
2+
3+
All rules in this document are requirements — not suggestions. ALWAYS follow them.
4+
5+
Wormatter is a DST-based Go source code formatter. Highly opinionated, but very comprehensive. Gofumpt and gci built-in.
6+
7+
## Highest-priority rule (MANDATORY)
8+
9+
- NEVER add comments unless they document a non-obvious public API or explain genuinely non-obvious logic. NEVER add comments that restate what the code does, repeat the field/function name, describe obvious error handling, or act as section separators. When in doubt, don't comment.
10+
- ALWAYS use `task` commands for build/test/lint/format — NEVER raw `go build`, `go test`, `go vet`, `go fmt`, or `golangci-lint` directly.
11+
- ALWAYS verify, don't assume — check the actual state before making changes.
12+
- ALWAYS start with the simplest possible solution. If it works, stop. Add complexity only when justified by a concrete, current requirement — NEVER for hypothetical future needs.
13+
- NEVER leave TODOs, stubs, or partial implementations.
14+
- ALWAYS stay within the scope of what was asked. When asked to update a plan — only update the plan, don't change code. When asked to brainstorm/discuss — only discuss, don't write code. When asked to do X — do X and nothing else. NEVER make unsolicited changes.
15+
16+
## Code style
17+
18+
### Design (MANDATORY)
19+
20+
> NEVER edit rules below directly. Instead ALWAYS update [CODESTYLE.md](CODESTYLE.md) and ask AI to sync the section below with it.
21+
22+
- ALWAYS prefer stupid and simple over abstract and extendable.
23+
- ALWAYS prefer a bit of duplication over complex abstractions.
24+
- ALWAYS prefer clarity over brevity in names.
25+
- ALWAYS minimize interfaces, generics, embedding.
26+
- ALWAYS prefer fewer types. Prefer no types over few. Prefer data types over types with behavior.
27+
- ALWAYS prefer functions over methods. ALWAYS prefer public fields over getters/setters.
28+
- ALWAYS keep everything private/internal as much as possible.
29+
- ALWAYS validate early, validate a lot. ALWAYS keep APIs stupid and minimal.
30+
- NEVER prefer global state. ALWAYS prefer simplicity over micro-optimizations.
31+
- ALWAYS use libraries for complex things instead of reinventing the wheel.
32+
- NEVER add comments unless they document a non-obvious public API or explain genuinely non-obvious logic. NEVER add obvious/redundant comments, NEVER add comments restating what code does. When in doubt, don't comment.
33+
34+
### Conventions (MANDATORY)
35+
36+
> NEVER edit rules below directly. Instead ALWAYS update [CODESTYLE.md](CODESTYLE.md) and ask AI to sync the section below with it.
37+
38+
- All arguments of a public function are required — passing nil not allowed.
39+
- Optional arguments via `<FunctionName>Options` as the last argument. NEVER use functional options.
40+
- Use guard clauses and early returns to keep the happy path unindented.
41+
- Use `samber/lo` helpers: `lo.Filter`, `lo.Find`, `lo.Map`, `lo.Contains`, `lo.Ternary`, `lo.ToPtr`, `lo.Must`, etc.
42+
- Constructors: `New<TypeName>[...]()`. No network/filesystem calls in constructors.
43+
- Interfaces: ALWAYS add `var _ Animal = (*Dog)(nil)` compile-time check.
44+
- Constants: avoid `iota`. Prefix enum constants with type name: `LogLevelDebug LogLevel = "debug"`.
45+
- Errors: ALWAYS wrap with context: `fmt.Errorf("read config: %w", err)`. Describe what is being done, not what failed. Panic on programmer errors. Prefer one-line `if err := ...; err != nil`.
46+
47+
### Go standard guidelines (MANDATORY)
48+
49+
Follow [Effective Go](https://go.dev/doc/effective_go) and [Go Code Review Comments](https://go.dev/wiki/CodeReviewComments). Commonly violated rules:
50+
51+
- NEVER use `this`/`self` as receiver names. Use 1-2 letter names, consistent across methods.
52+
- NEVER discard errors with `_`. Indent error flow, not happy path.
53+
- NEVER use dot imports.
54+
- NEVER use named returns or naked returns.
55+
56+
## Commands (MANDATORY)
57+
58+
ALWAYS use these `task` commands. NEVER use raw `go build`, `go test`, `go fmt`, `go vet`, or `golangci-lint` directly. Pass extra args after `--` to forward them to the underlying command (e.g., `task test -- -run TestMyFunc`).
59+
60+
- NEVER `go build` → ALWAYS `task build`. Builds binary to `./bin/`.
61+
- NEVER `go test` → ALWAYS `task test`. Runs all tests.
62+
- `task clean` — clean build artifacts.
63+
- `task install` — install binary to `$GOPATH/bin`.
64+
65+
## Testing (MANDATORY)
66+
67+
- ALWAYS use `testify` (`assert`, `require`) when writing new tests.
68+
- When writing tests as an AI agent → ALWAYS name the file `*_ai_test.go`, add `//go:build ai_tests` build tag, prefix test functions with `TestAI_`.
69+
- ALWAYS place tests alongside source files, not in a separate directory.
70+
- Test helpers go in `helpers_test.go` (or `helpers_ai_test.go` for AI-written helpers).
71+
- Test fixtures go in `testdata/` subdirectory next to the tests.
72+
73+
## PR review guidelines (MANDATORY)
74+
75+
- NEVER add new external dependencies without flagging to the user first.
76+
- NEVER introduce breaking user-facing changes (not API changes) unless they are hidden behind a feature flag. Flag to the user first.
77+
- NEVER introduce changes that may compromise security. Flag to the user first.

CODESTYLE.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## Design
2+
3+
* Prefer stupid and simple over abstract and extendable.
4+
* Prefer a bit of duplication over complex abstractions.
5+
* Prefer clarity over brevity in variable, function and type names.
6+
* Minimize usage of interfaces, generics, embedding.
7+
* Prefer few classes over many.
8+
* Prefer no classes over few.
9+
* Prefer data classes over regular classes.
10+
* Prefer functions over methods.
11+
* Prefer public fields over getters/setters.
12+
* Keep everything private/internal as much as possible.
13+
* Validate early, validate a lot.
14+
* Keep APIs stupid and minimal.
15+
* Avoid global state.
16+
* Prefer simplicity over micro-optimizations.
17+
* For complex things use libraries instead of reinventing the wheel.
18+
* Document only non-obvious public APIs or complex/weird code.
19+
20+
## Conventions
21+
22+
### Functions/methods
23+
24+
* All arguments of a **public** function are required: passing nil not allowed.
25+
* Optional arguments of a **public** function are provided via `<MyFunctionName>Options` as the last argument.
26+
* Avoid functional options pattern.
27+
* Use guard clauses and early returns/continues to keep the happy path unindented.
28+
* Use `samber/lo` helpers (if nothing similar in the standard lib): `lo.Filter`, `lo.Find`, `lo.Map`, `lo.Contains`, `lo.Ternary`, `lo.ToPtr`, `lo.Must`, etc.
29+
30+
### Constructors
31+
32+
* Constructors are optional.
33+
* Should be named `New<TypeName>[...]`, e.g. `NewResource()` and `NewResourceFromManifest()`.
34+
* No network/filesystem calls or resource-intensive operations. Do it somewhere higher, like in `BuildResources()`.
35+
36+
### Interfaces
37+
38+
* Always add a compile-time check for each implementation, e.g. `var _ Animal = (*Dog)(nil)`.
39+
40+
### Constants
41+
42+
* Avoid `iota`.
43+
* Prefix the enum-like constant name with the type name, e.g. `LogLevelDebug LogLevel = "debug"`.
44+
45+
### Errors
46+
47+
* Always wrap errors with additional context using `fmt.Errorf("...: %w", err)`.
48+
* On programmer errors prefer panics, e.g. on an unexpected case in a switch.
49+
* Do one-line `if err := myfunc(); err != nil` wherever possible, generally prefer one-line handling.
50+
* When wrapping errors with fmt.Errorf, describe what is being done, not what failed, e.g. `fmt.Errorf("read config file: %w", err)` instead of `fmt.Errorf("cannot read config file: %w", err)`.
51+
52+
## Go standard guidelines
53+
54+
Follow these two guides:
55+
56+
* [Effective Go](https://go.dev/doc/effective_go)
57+
* [Go Code Review Comments](https://go.dev/wiki/CodeReviewComments)

OPENCODE.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## Exploring the codebase (MANDATORY)
2+
3+
These are NOT suggestions — they are requirements.
4+
5+
- ALWAYS use **LSP** (`goToDefinition`, `findReferences`, `goToImplementation`, `hover`, `incomingCalls`/`outgoingCalls`, `documentSymbol`, `workspaceSymbol`) for navigating code. NEVER use `grep` for finding definitions, references, implementations, or callers — LSP is precise, `grep` is a guess.
6+
- To find a symbol's definition when you have a call site: use `goToDefinition`.
7+
- To find a symbol's definition without a call site: use `workspaceSymbol`. If it returns no results, fall back to `grep`.
8+
- To understand a file's structure: use `documentSymbol`.
9+
- To find interface implementations: use `goToImplementation`.
10+
- To check types or godoc: use `hover`.
11+
- ALWAYS use **CodeAlive MCP** (`codealive_codebase_search`, `codealive_codebase_consultant`) for semantic/intent-based code search. Call `codealive_get_data_sources` first. NEVER substitute with `grep` when the query is about intent or behavior.
12+
- Only fall back to `grep`/`glob` for simple literal pattern matching (specific strings, config keys, error messages).
13+
- Only use `task` subagent (`explore`/`general`) for broad codebase exploration or multi-step investigation when the above tools are insufficient.
14+
15+
## External documentation (MANDATORY)
16+
17+
These are NOT suggestions — they are requirements.
18+
19+
- ALWAYS use **LSP** `hover` to look up type signatures and godoc for any symbol (including external dependencies).
20+
- Use **Context7 MCP** (`context7_resolve-library-id` + `context7_query-docs`) for library documentation, guides, or examples.
21+
- Use **codesearch** (Exa) for finding code examples, API references, or documentation for libraries and tools.
22+
- Use **websearch** for current information, recent changes, or topics beyond training data.
23+
- Use **webfetch** to retrieve content from a specific URL (docs page, issue, PR).
24+
- NEVER guess at APIs — look them up.
25+
26+
## Verifying changes (MANDATORY)
27+
28+
ALWAYS verify after making changes:
29+
30+
- ALWAYS run `task build` — verify it compiles.
31+
- ALWAYS run `task test` — verify tests pass.

opencode.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"$schema": "https://opencode.ai/config.json",
3+
"instructions": [
4+
"OPENCODE.md",
5+
"AGENTS.md"
6+
]
7+
}

0 commit comments

Comments
 (0)