CLAUDE.md
.claude/CLAUDE.mdCLAUDE.md
Quality
96/100
Scores the file, not the repository.Length
1,257 words
14 headings · 3 code blocksRepository
40k
— · pushed 0 days agoLast changed
2 days ago
First indexed 2 days ago.1# CLAUDE.md23This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. Detailed rules are in `.claude/rules/*.md` files organized by topic.45## Build Commands67Run `make help` for an overview of the most common targets, and `make list` to list all of them. Key commands:89**Backend (Go):**10- `make build-go` — build the `photoprism` binary (develop mode)11- `make build-all` — build backend + frontend12- `go build ./...` — compile all Go packages1314**Frontend (Vue 3):**15- `make build-js` — production build of the frontend16- `make watch-js` — watch mode for frontend development (Ctrl+C to stop)1718**Dependencies:**19- `make dep` — install all dependencies (TensorFlow models, ONNX models, JS packages)20- `make dep-js` — install JS dependencies only (`npm ci`). The `photoprism/develop` image and the repo `Makefile` both set `NPM_CONFIG_IGNORE_SCRIPTS=true`, so install scripts are skipped automatically; when running npm directly in an env without that default, pass `--ignore-scripts`. Rebuild native addons with `npm rebuild --ignore-scripts=false <pkg>` — a bare `npm rebuild` no-ops wherever the env default is active.2122**Docker dev environment:**23- `make docker-build` — build local Docker image24- `docker compose up` — start dev environment (app at http://localhost:2342/)25- `make terminal` — open shell in dev container2627## Testing2829**Run all tests:**30- `make test` — runs both JS and Go tests31- `make test-go` — all Go tests (slow, ~20 min)32- `make test-js` — frontend unit tests (Vitest)33- `make test-short` — short Go tests in parallel (~5 min)3435**Run targeted Go tests:**36```bash37go test ./internal/api -run 'TestFunctionName' -count=138go test ./internal/photoprism -run 'TestMediaFile_' -count=139go test ./internal/entity/... -count=1 -tags="slow,develop"40```4142**Run targeted JS tests:**43- `make vitest-watch` — Vitest in watch mode44- `make vitest-coverage` — Vitest with coverage report4546**Reset test databases before running Go tests:**47- `make reset-testdb` — clears SQLite test DBs and MariaDB testdb4849**Subset targets:** `make test-pkg`, `make test-api`, `make test-entity`, `make test-commands`, `make test-photoprism`, `make test-ai`5051## Formatting & Linting5253Available targets: `make fmt` (everything), `make fmt-go`, `make fmt-js`, `make fmt-swag` / `make swag` (Swagger), `make lint-go`, `make lint-js`. Detailed conventions live in `.claude/rules/go-code-style.md` and `.claude/rules/frontend-rules.md`.5455When creating or editing shell scripts, run `shellcheck <file>` and resolve warnings. When editing Markdown files that contain tables, format them with `npx --yes markdown-table-formatter <filename>`.5657The curated `make help` overviews are maintained by hand in a `HELP_TEXT` block per Makefile. After renaming or removing a target, run `make check-make-help` (also part of `make lint`) to confirm that no overview still advertises it.5859## Continuous Integration6061**GitHub Actions is not enabled for this repository.** The workflow files under `.github/workflows/` do not execute, so pushes and pull requests produce no check runs. Treat them as dormant configuration: do not diagnose the absence of runs as a broken workflow, do not propose enabling Actions, and do not add workflows or bot configuration that assumes they will run. Ask a maintainer before changing anything under `.github/workflows/`.6263The `make` targets above are the authoritative build, format, and test gate — run them locally and report the output rather than relying on a hosted runner.6465## Schema Migrations6667If a change touches database schema, check migrations:68```bash69go run cmd/photoprism/photoprism.go migrations ls70go run cmd/photoprism/photoprism.go migrations run71# or via Makefile:72make migrate73```7475Migration files live in `internal/entity/migrate/`.7677## Architecture Overview7879PhotoPrism is a self-hosted photo management app. The backend is Go, the frontend is Vue 3 + Vuetify 3, and the database is MariaDB or SQLite (via GORM).8081### Backend (`internal/`, `pkg/`, `cmd/`)8283| Package | Purpose |84|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|85| `internal/photoprism` | **Core application logic**: indexing originals, metadata extraction, thumbnail generation, import/stacking, converter orchestration (FFmpeg/ImageMagick/ExifTool). Entry point for workers and CLI. |86| `internal/entity` | **Database models** (GORM): Photo, File, Album, Label, Face, User, Session, etc. Contains fixtures for tests and migration helpers. |87| `internal/entity/query` | Database query helpers used by the API and core packages. |88| `internal/api` | **REST API handlers** (Gin): thin handlers that validate input, enforce ACL/auth, delegate to services. Annotated with Swagger comments. |89| `internal/server` | HTTP server setup, routing (Gin engine), WebDAV, static assets, middleware wiring. Routes are registered in `routes.go`. |90| `internal/config` | Application configuration: CLI flags, env vars, client config sent to the frontend. |91| `internal/workers` | Background workers: indexing scheduler, metadata sync, sharing, backup, vision jobs. |92| `internal/commands` | CLI command implementations (`github.com/urfave/cli/v2`). |93| `internal/auth` | Authentication: ACL (`auth/acl`), JWT (`auth/jwt`), OIDC (`auth/oidc`), session management. |94| `internal/form` | Request form/binding structs for the API layer. |95| `internal/meta` | Metadata extraction from EXIF, XMP, JSON sidecars. |96| `internal/ffmpeg` | FFmpeg/transcoding helpers. |97| `internal/thumb` | Thumbnail generation helpers. |98| `internal/ai` | AI/vision model integration (TensorFlow, ONNX). |99| `internal/service` | Services: maps geocoding, hub (membership), cluster, WebDAV client, CIDR helpers. |100| `internal/event` | Event bus for structured logging and audit events. |101| `pkg/` | Standalone, reusable packages: `fs`, `geo`, `media`, `txt`, `clean`, `rnd`, `i18n`, `http`, `time`, etc. No dependency on `internal/`. |102103**Request flow:** HTTP request → Gin middleware (auth, rate limiting) → `internal/api` handler → `internal/photoprism` or `internal/entity` → response.104105**Audit logging convention** (`event.AuditInfo/Warn/Err`): slices must follow the pattern **Who → What → Outcome**:106- Who: `ClientIP(c)` + actor context (`"session %s"`, `"user %s"`)107- What: resource constant + action segments108- Outcome: single token like `status.Succeeded`, `status.Failed`, `status.Denied`, `status.Error(err)`109110### Frontend (`frontend/`)111112Vue 3 app using the Options API and Vuetify 3.113114| Directory | Purpose |115|---------------------------|-------------------------------------------------------------------------------------------------|116| `frontend/src/model/` | Client-side models mirroring API responses (Photo, Album, File, User, etc.) |117| `frontend/src/app/` | App bootstrap, routing (`routes.js`), and the `$session` reactive singleton |118| `frontend/src/page/` | Page-level components |119| `frontend/src/component/` | Reusable UI components |120| `frontend/src/common/` | Shared utilities, the API client (`$api`), and reactive singletons (`$config`, `$view`, `$log`) |121| `frontend/src/locales/` | i18n translation files |122| `frontend/tests/` | Vitest unit tests + TestCafe acceptance tests |123124State management uses reactive singleton modules in `src/common/` and `src/app/`, not Vuex or Pinia. Frontend code-style, formatting, testing, translation, and Playwright rules live in `.claude/rules/frontend-rules.md`.125126### API Conventions127128- REST API v1 base path: `/api/v1/` (configured via `conf.BaseUri()`)129- Authentication: Bearer token (`Authorization` header) or `X-Auth-Token` header130- Pagination: `count`, `offset`, `limit` parameters (default 100, max 1000)131- After adding/changing API handlers, regenerate Swagger docs: `make fmt-go swag-fmt swag`132- New routes must be registered in `internal/server/routes.go`133134### Config & Flags135136Verify config option names before using them:137```bash138./photoprism --help139./photoprism show config-options140./photoprism show config-yaml141```142143### Verify Before Propagating144145Before promoting a claim from `CLAUDE.md`, `AGENTS.md`, a memory entry, or another spec into a new rule, spec, code comment, or commit message, verify it against the current code (grep imports, list directories, read the cited file). Stale documentation silently turns into stale rules and stale specs that future sessions will trust. When the claim names a package, function, file, or framework, the cost of one grep is much smaller than the cost of repeating an error across multiple files.146147### Detailed Rules148149Topic-specific conventions live under `.claude/rules/` and are loaded alongside this file:150151- `code-comments.md` — shared JS/Go doc comment rules (length cap, what to omit); referenced by both style files.152- `go-code-style.md`, `go-testing.md` — Go style, package boundaries, test patterns, fixtures.153- `frontend-rules.md` — JS/Vue code style, formatting, dependencies, tests, Playwright, translations.154- `commit-and-docs-style.md` — commit-message format, GitHub issue templates, spec heading style.155- `safety-and-security.md` — Git/data safety, destructive commands, file I/O and archive-extraction policies, HTTP download helpers.156- `api-and-config.md`, `cluster-operations.md`, `import-index-download.md`, `build-and-runtime.md`, `sources-of-truth.md` — domain-specific guidance.157
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/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/AGENTS.md · 40k | AGENTS.md | teststyletesting-strategy | 71/100 | 2 days ago | |
| photoprism/photoprisminternal/api/AGENTS.md · 40k | AGENTS.md | teststyletesting-strategyapi | 62/100 | 2 days ago | |
| photoprism/photoprisminternal/commands/AGENTS.md · 40k | AGENTS.md | teststyle | 66/100 | 2 days ago | |
| 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 |
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/AGENTS.md Diff against internal/api/AGENTS.md Diff against internal/commands/AGENTS.md 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
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| nimbalyst/nimbalystpackages/android/CLAUDE.md · 1.4k | CLAUDE.md | setupbuildstylearch+2 | 100/100 | 3 days ago | |
| dotCMS/corecore-web/CLAUDE.md · 950 | CLAUDE.md | teststylearchtesting-strategy+3 | 100/100 | 3 days ago | |
| Adit-Jain-srm/NightmareNetCLAUDE.md · 45 | CLAUDE.md | buildtestlint-formatstyle+6 | 100/100 | 3 days ago | |
| microsoft/playwrightCLAUDE.md · 94k | CLAUDE.md | buildtestlint-formatstyle+7 | 100/100 | 3 days ago | |
| livewire/livewireCLAUDE.md · 24k | CLAUDE.md | setupbuildteststyle+4 | 100/100 | 3 days ago | |
| stacklok/toolhiveCLAUDE.md · 2.0k | CLAUDE.md | buildteststylearch+4 | 100/100 | 3 days ago | |
| dotCMS/coreCLAUDE.md · 950 | CLAUDE.md | setupbuildteststyle+7 | 99/100 | 3 days ago | |
| dotCMS/corecore-web/libs/sdk/client/CLAUDE.md · 950 | CLAUDE.md | setupbuildtestlint-format+9 | 97/100 | 3 days ago |
