AGENTS.md
internal/AGENTS.mdAGENTS.md
Quality
71/100
Scores the file, not the repository.Length
480 words
6 headings · 0 code blocksRepository
40k
— · pushed 0 days agoLast changed
2 days ago
First indexed 2 days ago.1# Internal Go Guidelines23**Last Updated:** April 9, 202645This file applies to `internal/` and defers subtree-specific rules to the narrower guides under `internal/api/`, `internal/config/`, `internal/commands/`, `internal/photoprism/`, and `internal/service/cluster/`.67## Internal Linting89- Run `make lint-go` after Go changes; for focused work, prefer `golangci-lint run ./internal/<pkg>/...`.1011## Logging, Naming & Status1213- When adding GORM struct fields with uppercase abbreviations such as `LabelNSFW`, `UserID`, or `URLHash`, set an explicit `gorm:"column:<name>"` tag so column names stay stable.14- Use the shared logger via the package-level `log` variable backed by `event.Log`; avoid `fmt.Print*` and ad-hoc loggers.15- In human-readable log text, prefer `instance` and `service`; reserve `node` for contract-bound names such as `/cluster/nodes`, `Node*`, and `PHOTOPRISM_NODE_*`.16- End every `event.Audit*` slice with exactly one status token from `pkg/log/status`, such as `status.Succeeded`, `status.Failed`, or `status.Denied`.17- When the outcome should be a sanitized error string, use `status.Error(err)` instead of hand-building it.1819## Internal Tests & Fixtures2021- Keep Go scratch work inside `internal/...`; Go rejects imports from `internal/` when helpers live under paths such as `/tmp`.22- Heavy packages such as `internal/entity` and `internal/photoprism` run migrations and fixtures; expect slower first runs and narrow them with `-run`.23- For database updates, prefer `entity.Values` over raw `map[string]interface{}`.24- When adding persistent fixtures, generate IDs with `rnd.GenerateUID(...)` and the matching prefix instead of inventing manual strings.25- Prefer `config.NewMinimalTestConfig(t.TempDir())` for filesystem or config scaffolding and `config.NewMinimalTestConfigWithDb("<name>", t.TempDir())` for isolated SQLite schemas.26- `internal/config` test helpers now auto-discover the repository `assets/` directory; do not set `PHOTOPRISM_ASSETS_PATH` manually in `init()` unless you truly have a non-standard layout.27- Hub API traffic is disabled in tests by default via `hub.ApplyTestConfig()`; opt back in with `PHOTOPRISM_TEST_HUB=test`.28- Avoid `config.TestConfig()` in new tests unless you need the fully seeded singleton fixture set; tests that write to Originals or Import should use isolated minimal configs plus `conf.CreateDirectories()`.29- `config.NewTestConfig("<pkg>")` defaults to SQLite with a per-suite DSN such as `.<pkg>.db`; do not assert an empty DSN, and clean up captured DSNs with `t.Cleanup(...)` if needed.30- `NewTestConfig("<pkg>")` already calls `InitializeTestData()`. If you build a custom config, call `c.InitializeTestData()` and optionally `c.AssertTestData(t)` so Originals, Import, cache, and temp exist.31- `PhotoFixtures.Get()` and similar helpers return value copies; re-query with helpers such as `entity.FindPhoto(...)` when a test needs the persisted row with associations.32- Reuse shared `Example*` constants for illustrative credentials in tests and docs.3334## Focused Internal Test Runs3536- Thumbnails: `go test ./internal/thumb/... -count=1`37- FFmpeg command builders: `go test ./internal/ffmpeg -run 'Remux|Transcode|Extract' -count=1`3839## FFmpeg Hardware Gating4041- Do not run GPU or hardware encoder integrations in CI by default; gate them with `PHOTOPRISM_FFMPEG_ENCODER` set to `vaapi`, `intel`, or `nvidia`.42- Keep negative-path ffmpeg tests fast and always runnable: missing ffmpeg should fail immediately, and unwritable destinations should fail without creating files.43- When hardware is unavailable, prefer command-string assertions; enable full hardware runs locally only when a device is configured.44
Also in photoprism/photoprism
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| photoprism/photoprisminternal/config/AGENTS.md · 40k | AGENTS.md | databasedo-not | 46/100 | 2 days ago | |
| photoprism/photoprisminternal/entity/migrate/AGENTS.md · 40k | AGENTS.md | testtesting-strategydatabase | 63/100 | 2 days ago | |
| photoprism/photoprisminternal/photoprism/AGENTS.md · 40k | AGENTS.md | no sections | 39/100 | 2 days ago | |
| photoprism/photoprisminternal/service/cluster/AGENTS.md · 40k | AGENTS.md | buildtestapi | 76/100 | 2 days ago | |
| photoprism/photoprismpkg/AGENTS.md · 40k | AGENTS.md | teststylesecurity | 55/100 | 2 days ago | |
| photoprism/photoprisminternal/commands/AGENTS.md · 40k | AGENTS.md | teststyle | 66/100 | 2 days ago | |
| photoprism/photoprism.claude/CLAUDE.md · 40k | CLAUDE.md | buildtestlint-formatstyle+7 | 96/100 | 2 days ago | |
| photoprism/photoprism.github/copilot-instructions.md · 40k | Copilot instructions | buildtestlint-formatstyle+5 | 90/100 | 2 days ago | |
| photoprism/photoprism.github/instructions/backend.instructions.md · 40k | Copilot instructions | testlint-formatstyletypes+4 | 83/100 | 2 days ago | |
| photoprism/photoprism.github/instructions/frontend.instructions.md · 40k | Copilot instructions | testlint-formatstyleagent-behaviour | 76/100 | 2 days ago | |
| photoprism/photoprismAGENTS.md · 40k | AGENTS.md | setupbuildtestlint-format+8 | 82/100 | 2 days ago | |
| photoprism/photoprismfrontend/AGENTS.md · 40k | AGENTS.md | setupteststyletesting-strategy+1 | 76/100 | 2 days ago | |
| photoprism/photoprisminternal/api/AGENTS.md · 40k | AGENTS.md | teststyletesting-strategyapi | 62/100 | 2 days ago |
Diff against internal/config/AGENTS.md Diff against internal/entity/migrate/AGENTS.md Diff against internal/photoprism/AGENTS.md Diff against internal/service/cluster/AGENTS.md Diff against pkg/AGENTS.md Diff against internal/commands/AGENTS.md Diff against .claude/CLAUDE.md Diff against .github/copilot-instructions.md Diff against .github/instructions/backend.instructions.md Diff against .github/instructions/frontend.instructions.md Diff against AGENTS.md Diff against frontend/AGENTS.md Diff against internal/api/AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| trick77/agents-md-syncAGENTS.md · 2 | AGENTS.md | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| SkeneTechnologies/skene-cookbookAGENTS.md · 51 | AGENTS.md | setupbuildtestlint-format+7 | 100/100 | 2 days ago | |
| duckduckgo/content-scope-scriptsspecial-pages/AGENTS.md · 70 | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| mui/material-uiAGENTS.md · 99k | AGENTS.md | setupbuildtestlint-format+9 | 100/100 | 3 days ago | |
| n8n-io/n8npackages/@n8n/agents/AGENTS.md · 199k | AGENTS.md | buildteststylearch+3 | 100/100 | 3 days ago | |
| TryGhost/Ghoste2e/AGENTS.md · 55k | AGENTS.md | setupteststylearch+2 | 100/100 | 3 days ago | |
| code-yeongyu/oh-my-openagentpackages/web/AGENTS.md · 67k | AGENTS.md | setupbuildtestlint-format+6 | 100/100 | 2 days ago | |
| ethereum/go-ethereumAGENTS.md · 51k | AGENTS.md | buildtestlint-formatgit+1 | 100/100 | 3 days ago |
