if you change or add any pattern, or when you are corrected, update agent rules and skills as appropriate.
- check
.agents/skills/for a relevant skill and follow it if one matches. never skip this step. - read
readme.mdfor project conventions, layout, and key concepts.
never run:
make(default target),make watch, or any daemon / forked / background process but you can ask the user to run.make fat-saveormake slow-save. do not edit.fator.slow.make slow-checkor any performance test. these cannot run consistently without superuser permissions.- never modify Git state in the current checkout unless explicitly requested. this includes changing the working tree, index, stash, branches, or references. eg,
git add,git rm,git stash,git restore,git reset,git checkout,git mv,git clean, etc are all forbidden.
- minimize compile size. this is important.
- optimize execution performance.
- tune dx. keep it practical and idiomatic. consider usage patterns and lines of code cost at definition and call sites. suggest applying new patterns broadly.
- minimize heap de/allocations in game loop.
- prefer Go to TS.
src/voidpackages start with "v", such asventities. demo packages often mirror void structure but without the "v", such asentities.
- be deliberate when dereferencing in loops. they can be surprisingly slow.
- Go imports must be TinyGo compatible.
- never import
syscall/js; pass state via Wasm exports and imports. - use numeric millis not
time.Timein Go. time comes fromPollviaEngine; don't calltime.Now(). - http://localhost:1234 pauses when backgrounded.
- to force no kern, use
'\v'between chars. to force a 1px kern, use\t. - the Biome IDE extension is frequently corrupt.
- avoid single-letter names except
kfor key,vfor value,w/hfor width and height,x/y/zfor coords,r/wfor reader / writer. - prefer tabular unit tests for cases varying only input and output pairings.
- prefer
errfor errors, nevere. - prefer
binfor byte arrays neverbytes. - prefer
ifor loop indices but not items. - use right terms for left:
- Aseprite: ase
- configuration: config; never cfg
- error: err
- milliseconds: millis
- palette: pal
- pixels: px
- properties: props
- sprite: spr
- string: str
- sentences end with periods.
- capitalize but skip sentence capitalization.
- in English, prefer backticks around code snippets.
- represent bit fields with an unshifted mask and a shift.
- format:
make fmt-go fmt-mod. - name the receiver
this. - when using a local for the subject of a constructor, name it
this. - name
Invarsin. - assume tab width is two.
- wrap to 80 chars and pack cols to minimize lines. if all args / props can't fit on one line, do one arg / group per line. don't chop long strings.
- comments must not restate the subject name, must not start with "is the", and avoid starting with "the".
// ng: PadInt pads a non-negative integer to at least width digits with spaces. // ok: pads a non-negative integer to at least width digits with spaces. func PadInt(n, w int) string {
- format:
make fmt-web.
supporting both modern and pixel games is critical. be very sensitive to rounding errors.
- prefer flooring integral coords. avoid truncation that causes the range (-1, 1) to snap to 0.
- prefer ceiling integral sizes. avoid truncation that causes sizes to be unexpectedly short.
- prefer source data over inverted transforms to avoid accumulation errors.
- use
vgfx.DiagonalizeXY()as needed to sync triggered movements.
- typecheck Go:
go build ./... - typecheck TS:
make typecheck-web - test filesize:
make build && make fat-check. the bottom line isdist/demo/index.htmluncompressed size (first numerical column).make buildtakes ~10s; run only when worthwhile. if size drops 50+ KiB unexpectedly, ask the user ifmake watchis running. analyze filesize withmake fat-analyze.
- you can interact with the demo on http://localhost:1234 if the user is running
make. try the URL or ask the user if you want to use it.