📚 Trim agent guidance while keeping required memory reads

Keep the memory reading order and hard rules visible before agents act.
Move detailed coverage and CI guidance out of the common entry points,
and keep the backend assertion flag explicit for direct test runs.

AI-assisted-by: gpt-6.2-sol
This commit is contained in:
Andrey Antukh 2026-11-23 14:45:21 +00:00
parent 6c482b0435
commit d40fe15a31
8 changed files with 101 additions and 329 deletions

View File

@ -531,6 +531,10 @@ in plain words — the agents pick the right skill from what you say.
Create a folder here with a `SKILL.md` inside. The file needs `name` and
`description` in its frontmatter, and a clear "When to use" section so
agents know when to reach for it. Keep one job per skill, and keep the
agents know when to reach for it. Use the description to route requests
and the body to tell the agent what to do. Link to the relevant memory for
the full rules or command reference instead of copying it into the skill.
Keep short reminders where they prevent an agent from skipping a required
read or check. Keep one job per skill, and keep the
two families apart: flows are named with a verb first; reference skills
end in `-criteria`.

View File

@ -2,9 +2,9 @@ Act as a senior full-stack software engineer for this project.
## Instructions
1. Read `AGENTS.md` first and follow its memory-reading rules: read `mem:critical-info`, then the core memory of every module your work touches, plus any deeper memories they reference.
1. Read `AGENTS.md`. Open `mem:critical-info` before exploring, even for read-only tasks; read each relevant `<module>/core` and its applicable references before planning, editing, or drawing conclusions. If another module becomes relevant, stop and read its guidance before continuing.
2. Work autonomously: explore the codebase first, follow existing patterns and conventions, apply DRY/KISS.
3. Verify before finishing: run tests, lint and fm, fix anything you broke. Never report done with failing checks.
3. Verify before finishing: run tests, lint and fmt; fix anything you broke. Never report done with failing checks.
4. Before finishing, review the affected memories and documentation against the implementation. If the change introduces behavior, contracts, decisions, or constraints that are not documented, or makes existing documentation inaccurate, update the relevant memories and docs in the same change.
## Strong Rules

View File

@ -5,105 +5,18 @@ description: Run local CI-style checks with ./scripts/ci (lint, tests, format, a
# Local CI
Run the same checks CI runs, locally, for the modules you touched, with
`scripts/ci`. Each task writes a log file; the final summary says what
passed and what failed.
Full details: `mem:scripts/ci` (file: `.serena/memories/scripts/ci.md`)
## When to use
- After implementing or fixing code — verify every module you touched
before declaring the work done.
- When the user asks to run CI, lint, tests, or format checks locally.
- When you changed `common/` — validate its consumers too.
Use after changing code or when asked to run checks. Skip while exploring or
planning. If `common` changed, include its affected consumers (see `mem:critical-info`).
**Skip:** while exploring, planning, or reading code.
## Workflow
## Command reference
Run from the repo root:
```bash
./scripts/ci [OPTIONS] [MODULES...]
```
Modules: `frontend` `backend` `common` `render-wasm` `exporter` `mcp`
`plugins` `library` `media-processor`, or `--all` for every module.
With no task flags it runs three tasks per module, in order: **lint**,
**test**, **fmt** (format check; `--fix` formats files instead). **build**
is opt-in: it compiles the module the way production does and is the slow
one, so it never runs unless you ask for it.
| Flag | Effect |
|------|--------|
| `--all` | Run every module |
| `--exclude MOD` | Skip one module (repeatable) |
| `--lint` / `--no-lint` | Run only lint / drop lint |
| `--test` / `--no-test` | Run only tests / drop tests |
| `--fmt` / `--no-fmt` | Run only format check / drop it |
| `--build` / `--no-build` | Run only the production build / drop it |
| `--fix` | Format files instead of checking (other tasks unaffected) |
| `--paren-repair` | Fix delimiter errors in Clojure/CLJS files |
| `--fail-fast` | Stop at the first failure |
| `--quiet` | Suppress failure output |
| `--dry-run` | Show what would run, execute nothing |
| `--clean` | Delete the `.ci-logs/` directory |
## Reading failures
Every task writes its full output to `.ci-logs/<module>-<task>.log`. On
failure the script prints only the last 30 lines. To diagnose a failure,
**read the log file** — never re-run the command piped through filters
(repo rule: redirect to a file first, then read it). The exit code is 1
when any task failed; the summary lists each failed `module:task` and its
log path.
## Typical workflows
```bash
# Verify a module you changed: lint + tests + format check
./scripts/ci frontend
# Fast pass while iterating: lint only
./scripts/ci --lint frontend
# Lint + format check, skip the long test suite
./scripts/ci --no-test frontend
# Format the module without running the test suite
./scripts/ci --fix --no-test frontend
# Check that the module still compiles (slow: minutes)
./scripts/ci --build frontend
# Compile every module (8 builds, ~4 min with warm caches)
./scripts/ci --build --all
# Broke delimiters in Clojure/CLJS files: repair first, then lint
./scripts/ci --paren-repair frontend
./scripts/ci --lint frontend
# Changed common/ — validate its consumers too
./scripts/ci common frontend backend exporter
# Preview what would run, without running it
./scripts/ci --dry-run --all
```
## Gotchas
- Run from the repo root.
- Test tasks are long-running (backend runs `clojure -M:dev:test`); give
the bash call a generous timeout (10–20 minutes) instead of letting it
time out mid-run.
- `mcp` and `media-processor` have no lint task — they show as skipped,
not failed. `common` has no build task for the same reason.
- Build runs are the slow ones (frontend ~2 min even with warm caches;
cold caches roughly double it). Give the shell a generous timeout and
do not run two builds at once in the same checkout: `render-wasm` takes
a build lock.
- `--paren-repair` only fixes delimiters; run lint afterwards to catch
what remains. See `mem:scripts/paren-repair`.
- What to run and how to read test results: `mem:testing`.
1. Read `mem:scripts/ci` for flags, module-specific commands, and exceptions.
If Clojure or ClojureScript delimiters are broken, repair them before lint.
2. From the repo root, run `./scripts/ci MODULE...` to check lint, tests, and
formatting. Use a single-task flag during iteration, not as a substitute
for final verification. Production builds run only on request.
3. Check the exit code and summary. For failures, read
`.ci-logs/<module>-<task>.log`; never pipe test output directly to filters.
Give long runs a generous shell timeout or run them in the background.

View File

@ -3,56 +3,19 @@ name: testing
description: Enforce TDD workflow and testing best practices for Penpot. Use when implementing features, fixing bugs, or modifying behavior. Reads testing memory for full guidance.
---
# Testing Skill
# Testing
Enforces test-driven development and Penpot testing conventions.
## When to use
## When to Use
- Implementing new logic or behavior
- Fixing any bug (reproduction test required)
- Modifying existing functionality
- Adding edge case handling
**Skip:** Pure configuration changes, documentation updates, or static content with no behavioral impact.
Use for new behavior, behavior changes, edge cases, and bug fixes. Skip
documentation, configuration, and static content changes with no behavioral impact.
## Workflow
Follow TDD (Red → Green → Refactor) whenever practical:
1. **RED** — Write a failing test first
2. **GREEN** — Write minimal code to pass
3. **REFACTOR** — Clean up while tests stay green
For bug fixes, use the Prove-It Pattern: write a test that reproduces the bug, confirm it fails, implement the fix, confirm it passes.
## Required Reading
Before writing any test, read:
1. `.serena/memories/testing.md` — cross-cutting testing principles, TDD workflow, anti-patterns, execution discipline
2. Module-specific testing memory for the affected module:
- `mem:common/testing` — CLJC unit tests
- `mem:frontend/testing` — CLJS unit tests, Playwright E2E
- `mem:backend/testing` — JVM clojure.test conventions
- `mem:exporter/testing` — exporter unit tests
## Key Rules
- Every behavior change needs a test
- Test state, not interactions
- DAMP over DRY — tests are specifications; duplication is OK if each test is self-contained and readable
- Prefer Real > Fake > Stub > Mock
- Arrange-Act-Assert structure
- One assertion per concept
- Never pipe test output to filters — redirect to file first
- Register new test files in the module's runner/entrypoint
## Verification
After completing implementation:
- [ ] Every new behavior has a test
- [ ] All tests pass for touched modules
- [ ] Bug fixes include a reproduction test
- [ ] Lint/formatter passes
1. Before writing tests, read `mem:testing` and its applicable module testing
references for test commands, fixtures, and runner registration.
2. Test every behavior change. Prefer red → green → refactor. For bug fixes,
first write a reproducing test and confirm it fails for the expected reason;
then fix the bug and confirm the test passes.
3. Register new test files if the module requires it. Verify tests, lint, and
formatting with `local-ci` before finishing.

View File

@ -1,34 +1,20 @@
You are working on the GitHub project `penpot/penpot`, a monorepo.
# Memory system
# Cross-cutting guidance
- Memories are the primary project guidance (not docs or other readme files).
- A section's top-level memory is `<section>/core`. When a section is relevant, read the core memory before focused memories.
- Edits/stale refs/duplication cleanup: `mem:memory-maintenance`.
- Cross-cutting testing principles, TDD workflow, and anti-patterns: `mem:testing`.
- Structured logging conventions (`:hint` casing and fields, log levels): `mem:clojure/logging` — read before adding or changing any log call.
- Verified Clojure language behaviors that contradict common assumptions (e.g. `int?` covers `Long`; `integer?` is the general predicate): `mem:clojure/idioms` — read before assuming stdlib predicate semantics.
- Read `mem:clojure/core` (function shape, boundary checks, naming) before writing or modifying Clojure/ClojureScript code — not only when designing a solution or an API.
- Align the values of multi-line Clojure/CLJS `let` bindings to the same column.
- Promises: which call style to use where (`fmap`/`mcat`/`merr` vs `then`/`catch`) and how they bridge to rx: `mem:clojure/promesa` — read before chaining promises or mixing them with observables.
# Development workflow
- Commit/PR/issue creation is **on explicit request only**. Before any of these actions, read the relevant memory — don't infer format from prior examples:
- Before `git commit` → `mem:workflow/creating-commits` (subject/body format, 80-char body wrapping enforced by `scripts/check-commit`, `AI-assisted-by: model-name` trailer)
- Before `gh issue create` → `mem:workflow/creating-issues` (title derivation, body template, labels, Issue Type)
- Before `gh pr create` / `gh pr edit` → `mem:workflow/creating-prs` (title format, body structure, "Note:" line)
- Before updating `CHANGES.md` → `mem:workflow/updating-changelog` (sources of truth, entry rules, the `:boom:`/`:rocket:` label contracts, pre-flight checks, anomaly report)
- Before a repo-wide pnpm version update → `mem:workflow/updating-pnpm` (workspace layout, `scripts/sync-pnpm-version` flow, the stamp-missing-field and ignored-builds gotchas, verification steps)
- Before a Node version update → `mem:workflow/updating-node` (the six pin sites in `.nvmrc`, the devenv and image Dockerfiles and the plugins-deploy workflows, the DHI tag and digest rules, what to verify)
- Before bumping a non-JS dependency pinned in `docker/images/` (JDK, ImageMagick) → `mem:workflow/docker-images`
- **Never `git push`, force-push, or modify `git origin`** (or any other remote). The user pushes from their own shell; if a push is required, say so and wait. Never amend a commit that the user has already pushed unless explicitly asked.
- **Never edit `CHANGES.md` by hand.** The changelog is generated from GitHub milestones during the release process; update it only via `mem:workflow/updating-changelog` (the `update-changelog` skill flow) or on explicit user request.
- You have access to the GitHub CLI `gh` or corresponding MCP tools.
- Before writing code, analyze the task in depth and describe your plan. If the task is complex, break it down into atomic steps. After making changes, run the applicable lint and format checks for the affected module before considering the work done (per example `mem:backend/core` or `mem:frontend/core`).
- Align `let` binding values: when a `let` form has multiple bindings spanning several lines, align the value forms to the same column with spaces.
- If you introduce delimiter errors (mismatched parens/brackets) in Clojure/CLJS files, fix them with `scripts/paren-repair` BEFORE running lint/format checks. See `mem:scripts/paren-repair` for usage.
- Never run anything that destroys data without explicit permission, including `drop-devenv`, `docker compose down -v`, `docker volume rm ...`. The user's real work lives in the volumes of the shared infra.
- **Never wait for background work with a sleep.** A long command moved to the background reports its own completion: do not poll it with `sleep 150` (or any other wait) inside a foreground command, and do not re-read its output file to check whether it finished. Keep working on something else, or end the response and wait for the notification.
# Project modules
@ -45,8 +31,6 @@ This is a monorepo. Principles that apply to one module do *not* generally apply
- `docs/`: documentation site; core workflow and conventions: `mem:docs/core`.
- `media-processor/`: TypeScript/Node.js HTTP service for image (sharp) and font (FontForge) processing; core conventions: `mem:media-processor/core`.
The memory is structured in a way that you can get the critical information about the module. You can read it from `mem:<MODULE>/core`
# Low-centrality project paths
- `docker/` contains devenv related code, not needed unless specifically instructed. When working on devenv startup, compose layout, instance config (`defaults.env`), tmux session lifecycle, RustFS provisioning, or anything in `manage.sh`'s `*-devenv` commands, read `mem:devenv/core`.
@ -56,18 +40,17 @@ The memory is structured in a way that you can get the critical information abou
# Dev Scripts (scripts/)
- `scripts/nrepl-eval.mjs` — Evaluate Clojure/ClojureScript code via nREPL. Supports `--backend` (port 6064) and `--frontend` (port 3447) aliases. See `mem:scripts/nrepl-eval`.
- `scripts/paren-repair` — Fix mismatched delimiters in Clojure/CLJS files and reformat with cljfmt. Run before lint checks when LLM edits break parens. See `mem:scripts/paren-repair`.
- `scripts/paren-repair` — Fix mismatched delimiters in Clojure/CLJS and reformat with cljfmt. If edits break delimiters, repair them before lint and format checks. See `mem:scripts/paren-repair`.
- `scripts/psql` — PostgreSQL client wrapper with devenv defaults. Companion: `scripts/db-schema` for DDL dumps. See `mem:scripts/psql`.
- `scripts/taiga.py` — Fetch public issues, user stories, and tasks from the Penpot Taiga project without authentication. See `mem:scripts/taiga`.
- `scripts/gh.py` — GitHub operations helper: list milestone issues, fetch PR details, compare against CHANGES.md, create issues with their Issue Type in one command. Requires `gh` CLI. See `mem:scripts/gh`.
- `scripts/coverage-summary.mjs` — Renders an lcov file as a markdown table grouped by source area, for `$GITHUB_STEP_SUMMARY` (`--title`, `--lcov`, optional `--note`, `--unloaded`). Used by the backend, common and frontend test workflows; module coverage commands are in `mem:backend/testing`, `mem:common/testing`, `mem:frontend/testing`.
- `scripts/coverage-comment.mjs` — Keeps one PR comment (`<!-- coverage-report -->`) with the coverage table of Backend, Common, Frontend and Render WASM, in the format of the Vitest Coverage Report Action (status, metric, %, covered/total, changed-file coverage, run/commit footer). Each test job updates its own project: the data of all three lives base64-encoded in a hidden `coverage-data` block, and the job re-reads after `SETTLE_MS` and rewrites if a concurrent job dropped its data; extra report comments from simultaneous creates are merged and deleted. Targets (`THRESHOLDS`, per project and metric, status colour only, never fail CI) are on lines only: 70 Backend, 70 Common, 50 Frontend, 40 Render WASM; other metrics get the blue dot. Statements are Clojure forms for Backend/Common (`--emma-xml`) and llvm regions for Render WASM (`--llvm-json`). Shared lcov parsing: `scripts/coverage-lcov.mjs`. The test workflows run it only for PRs from branches of this repo (job-level `pull-requests: write`, `continue-on-error`): fork PRs get a read-only token, so they only get the run-page summary. A fork-safe `workflow_run` commenter would run only from the default branch's copy of the workflow.
- Before changing coverage summaries or PR comments, read `mem:scripts/coverage-reporting` for metrics, concurrent comment updates, and fork permissions.
- `scripts/project-anomalies.py` — Main-board anomaly check for a milestone (`check` writes `tmp/<MILESTONE>-ANOMALIES.md`). Bulk resolution via `scripts/gh.py`. See `mem:scripts/project-anomalies`.
- `scripts/changelog.py` — Changelog checks for `mem:workflow/updating-changelog`: `boom` (generate the `:boom:` section from `breaking change` issues), `check-merged` (PR merge status), `cross-ref` (milestone PRs vs changelog section), `report` (anomaly report to CHANGES-ISSUES.md). Calls `scripts/gh.py` via subprocess. See `mem:scripts/changelog`.
- `scripts/error-reports.mjs` — Query error reports via RPC API with token authentication. Supports list/get operations with filtering and pagination. See `mem:scripts/error-reports`.
- `scripts/clean-node-modules` — Remove stale `node_modules` from all pnpm workspaces (root, modules, member packages). Keeps the shared pnpm store at `<repo>/.pnpm-store` unless `--store`; ignores `external/` and `.opencode/`. Usage and reinstall steps: `mem:workflow/updating-pnpm`.
- `scripts/setup-opencode` — Install the opencode CLI in-container as a global pnpm package in `$PNPM_HOME`. Not part of the devenv image; see `mem:devenv/core`.
- `scripts/ci` — CI orchestration script: runs lint, tests, and format checks per module, plus the production build on request (`--build`). Modules: `frontend backend common render-wasm exporter mcp plugins library media-processor`. Logs go to `.ci-logs/`; read the log file on failure. It is the preferred way to run the backend tests, and it exports `PENPOT_FLAGS` with `enable-backend-asserts`, which is what makes `clojure.core/assert` exist in the compiled test code. See `mem:scripts/ci`.
- `scripts/ci` — Per-module lint, tests and format checks. See `mem:scripts/ci` for flags, logs and the backend assert flag.
# Dependency graph

View File

@ -0,0 +1,7 @@
# CI coverage reporting
- Backend, Common, Frontend and Render WASM test workflows use `scripts/coverage-summary.mjs` to write source-area tables from lcov to `$GITHUB_STEP_SUMMARY` (`--title`, `--lcov`, optional `--note`, `--unloaded`). Module coverage commands: `mem:backend/testing`, `mem:common/testing`, `mem:frontend/testing`.
- `scripts/coverage-comment.mjs` maintains one PR comment marked `<!-- coverage-report -->`. It renders the four projects together, including changed-file coverage and a run/commit footer. `scripts/coverage-lcov.mjs` supplies shared lcov parsing.
- Each job updates only its project. Base64-encoded `coverage-data` holds all four projects; the writer re-reads after a delay based on `SETTLE_MS` and retries if a concurrent update dropped its data. Concurrent creates are merged and extra comments deleted.
- Line thresholds affect status color only: Backend 70%, Common 70%, Frontend 50%, Render WASM 40%. Other metrics use the neutral blue status. Backend/Common statement counts are Clojure forms (`--emma-xml`); Render WASM statement counts are LLVM regions (`--llvm-json`).
- The comment steps use job-level `pull-requests: write` and `continue-on-error`, and run only for same-repo pull requests with coverage output. Fork PRs receive the run-page summary, not a comment; their PR token is read-only. A `workflow_run` commenter would run from the default branch's workflow, not the PR's.

View File

@ -4,16 +4,12 @@
Tests are proof that code works. Every behavior change needs a test.
Testing in this monorepo varies by module. Each module has its own test
commands, helpers, runner registration requirements, and conventions. This
memory covers cross-cutting testing principles. For module-specific commands
and helpers, consult:
Testing in this monorepo varies by module. Each module has its own test commands, helpers, runner registration requirements, and conventions. This memory covers cross-cutting testing principles. For module-specific commands and helpers, consult:
- `mem:common/testing` — CLJC unit tests (JVM + JS), test helpers, fixture
builders, production-path change helpers
- `mem:frontend/testing` — CLJS unit tests, Playwright E2E integration tests,
live browser verification via nREPL
- `mem:common/testing` — CLJC unit tests (JVM + JS), test helpers, fixture builders, production-path change helpers
- `mem:frontend/testing` — CLJS unit tests, Playwright E2E integration tests, live browser verification via nREPL
- `mem:backend/testing` — JVM `clojure.test` under `backend/test/`
- `mem:exporter/testing` — exporter unit tests
## When to Use
@ -22,16 +18,13 @@ and helpers, consult:
- Modifying existing functionality
- Adding edge case handling
**When NOT to use:** Pure configuration changes, documentation updates, or
static content changes with no behavioral impact.
**When NOT to use:** Pure configuration changes, documentation updates, or static content changes with no behavioral impact.
## TDD: Recommended Workflow
Write a failing test before writing the code that makes it pass. For bug fixes,
reproduce the bug with a test before attempting a fix.
Write a failing test before writing the code that makes it pass. For bug fixes, reproduce the bug with a test before attempting a fix.
When TDD isn't practical (exploratory work, tight coupling to unknown APIs),
still write tests before considering the work complete.
When TDD isn't practical (exploratory work, tight coupling to unknown APIs), still write tests before considering the work complete.
```
RED GREEN REFACTOR
@ -42,17 +35,13 @@ still write tests before considering the work complete.
Test FAILS Test PASSES Tests still PASS
```
- **RED** — Write the test first. It must fail. A test that passes immediately
proves nothing.
- **RED** — Write the test first. It must fail. A test that passes immediately proves nothing.
- **GREEN** — Write the minimum code to make the test pass. Don't over-engineer.
- **REFACTOR** — With tests green, improve the code without changing behavior:
extract shared logic, improve naming, remove duplication. Run tests after
every step.
- **REFACTOR** — With tests green, improve the code without changing behavior: extract shared logic, improve naming, remove duplication. Run tests after every step.
## The Prove-It Pattern (Bug Fixes)
When a bug is reported, **do not start by trying to fix it.** Start by writing
a test that reproduces it:
When a bug is reported, **do not start by trying to fix it.** Start by writing a test that reproduces it:
1. Write a test that demonstrates the bug
2. Confirm the test FAILS (proving the bug exists)
@ -62,54 +51,34 @@ a test that reproduces it:
## Core Principles
- **Test State, Not Interactions** — assert on outcomes, not method calls;
survives refactoring
- **DAMP over DRY** — tests are specifications; duplication is OK if each test
is self-contained and readable. A test should tell a complete story without
requiring the reader to trace through shared helpers.
- **Prefer Real Implementations** — hierarchy: Real > Fake > Stub > Mock;
mock only at boundaries (network, RPC, filesystem, email)
- **Test State, Not Interactions** — assert on outcomes, not method calls; survives refactoring
- **DAMP over DRY** — tests are specifications; duplication is OK if each test is self-contained and readable. A test should tell a complete story without requiring the reader to trace through shared helpers.
- **Prefer Real Implementations** — hierarchy: Real > Fake > Stub > Mock; mock only at boundaries (network, RPC, filesystem, email)
- **Arrange-Act-Assert** — every test: setup / action / verify
- **One Assertion Per Concept** — each test verifies one behavior; split
compound assertions
- **One Assertion Per Concept** — each test verifies one behavior; split compound assertions
- **Descriptive Test Names** — names read like specifications
- **English Only** — test names, `testing` strings, comments, and every
code-facing text MUST be in English; see the hard rule in `AGENTS.md`.
- **English Only** — test names, `testing` strings, comments, and every code-facing text MUST be in English; see the hard rule in `AGENTS.md`.
## Prefer Real Implementations Over Mocks
Work down this list:
1. **Real implementation** — Test the actual code with real collaborators.
Highest confidence.
2. **Fake** — A simplified but functional in-memory implementation (e.g.
atom/dict-backed store instead of a real database).
3. **Stub** — Returns canned data. Use when the collaborator's logic is
irrelevant.
4. **Mock** — Last resort, only at boundaries. Use only when verifying
interaction with an external system that cannot be faked.
1. **Real implementation** — Test the actual code with real collaborators. Highest confidence.
2. **Fake** — A simplified but functional in-memory implementation (e.g. atom/dict-backed store instead of a real database).
3. **Stub** — Returns canned data. Use when the collaborator's logic is irrelevant.
4. **Mock** — Last resort, only at boundaries. Use only when verifying interaction with an external system that cannot be faked.
**Rule of thumb:** If you can write a fake or use the real implementation, do
that. If you find yourself asserting on call counts or invocation order, ask
whether a fake would be clearer.
**Rule of thumb:** If you can write a fake or use the real implementation, do that. If you find yourself asserting on call counts or invocation order, ask whether a fake would be clearer.
## Fixtures over Manual Setup
Use fixture/`beforeEach` mechanisms for shared setup and teardown. Each test
should own its state so tests don't interfere with each other. Shorter-scope
fixtures (`:each` / per-test) are preferred; longer-scope fixtures (`:once` /
suite-level) are only for expensive, immutable shared setup.
Use fixture/`beforeEach` mechanisms for shared setup and teardown. Each test should own its state so tests don't interfere with each other. Shorter-scope fixtures (`:each` / per-test) are preferred; longer-scope fixtures (`:once` / suite-level) are only for expensive, immutable shared setup.
## Parametrized Tests
Use your test framework's parametrize/table-driven mechanism to test multiple
scenarios with a single test body. Keeps tests concise and surfaces all cases
at a glance.
Use your test framework's parametrize/table-driven mechanism to test multiple scenarios with a single test body. Keeps tests concise and surfaces all cases at a glance.
Only when the body is short and identical for every row. A loop that builds its
own world per row (fresh store, fixtures, several awaits) or that nests two
dimensions hides which case failed and shares state across cases: write one
test per case instead, with a shared fixture for the arrangement.
Only when the body is short and identical for every row. A loop that builds its own world per row (fresh store, fixtures, several awaits) or that nests two dimensions hides which case failed and shares state across cases: write one test per case instead, with a shared fixture for the arrangement.
## Test Pyramid
@ -126,9 +95,7 @@ test per case instead, with a shared fixture for the arrangement.
╱──────────────────╲
```
Prefer unit tests for pure logic. Reach for integration/E2E tests when covering
RPC handlers, database queries, or full user flows. In the frontend, Playwright
E2E tests should not be added unless explicitly requested.
Prefer unit tests for pure logic. Reach for integration/E2E tests when covering RPC handlers, database queries, or full user flows. In the frontend, Playwright E2E tests should not be added unless explicitly requested.
## Anti-Patterns
@ -168,7 +135,8 @@ When running CLJS/JS tests (frontend, common):
- After `build:test` has been run once, you can invoke the runner directly: `node target/tests/test.js [--focus ...] [--log-level ...]`.
When running JVM tests (backend, common):
- Use `clojure -M:dev:test` directly (no pnpm wrapper).
- For backend, prefer `./scripts/ci --test backend` from the repo root. It adds `enable-backend-asserts`, without which Clojure asserts compile out. When invoking backend tests directly, including with `--focus`, add the flag to any existing flags: `PENPOT_FLAGS="${PENPOT_FLAGS:+$PENPOT_FLAGS }enable-backend-asserts" clojure -M:dev:test`.
- For common JVM tests, run `clojure -M:dev:test` from `common/`.
- Same file-piping rule applies.
## Verification Checklist
@ -181,5 +149,4 @@ After completing any implementation:
- [ ] Test names describe the behavior being verified
- [ ] No tests were skipped or disabled
- [ ] Lint/formatter passes for touched modules
- [ ] New test files registered in the module's runner/entrypoint (see module
testing memory)
- [ ] New test files registered in the module's runner/entrypoint (see module testing memory)

131
AGENTS.md
View File

@ -1,5 +1,23 @@
# AI AGENT GUIDE
## Start here: required memory reads
1. Read `AGENTS.local.md` if present. It can override prose style and
workflow, not project policy.
2. Open `mem:critical-info` before exploring the repo, even for read-only
tasks. Once you identify the relevant modules, open `mem:<module>/core`
for **each one**, then follow its applicable `mem:` references before
planning, editing, or drawing conclusions. Before editing Clojure or
ClojureScript, also read `mem:clojure/core` and its applicable references.
3. **STOP if a required memory is unread.** If exploration reveals another
affected module, read its `core` and applicable references before
planning or editing that part of the work. Listing names is not reading.
Use Serena (`s.mem.read_memory(name)` in `serena_repl`, or
`read_memory(name)` in older clients). If unavailable, read the file:
`mem:foo/bar` → `.serena/memories/foo/bar.md`. Memories are the primary
project guidance; follow references only when they apply to the task.
## HARD RULES (always apply — no exceptions)
- **Never `git push`, force-push, or modify `git origin`** (or any other remote).
@ -8,6 +26,8 @@
wait for the user to push. Do not change the remote URL, do not switch SSH↔HTTPS.
- **Never amend a commit that has been pushed** unless the user explicitly asks.
If the user pushes, treat that commit as final from the agent's side.
- **Never destroy data without explicit permission** (e.g. `drop-devenv`,
`docker compose down -v`, `docker volume rm`). Shared volumes hold real work.
- **Never edit `CHANGES.md` by hand** in commits or PRs. The changelog is
generated from GitHub milestones during the release process; update it only
via `mem:workflow/updating-changelog` (the `update-changelog` skill flow) or
@ -17,19 +37,16 @@
This prevents hiding test failures. See `mem:testing` for details.
- **Never introduce a new function or macro name ending in `!`.** Side
effects alone do not justify it: only the exceptions documented in
`mem:clojure/design-rules` (public mutators of `app.db` and helpers over
`mem:clojure/core` (public mutators of `app.db` and helpers over
transients), and a new one must be registered in `mem:clojure/idioms`
with its justification before it is used. Existing names stay until their
refactor; a new one fails review. See `mem:clojure/design-rules` before
naming anything.
- **Read `AGENTS.local.md` after this file whenever it exists.** It carries
the developer's steering for this project and overrides this file on prose style and
workflow, but not on project policy, where instructions here prevail.
refactor; a new one fails review.
- **Commit message body lines MUST wrap at ≤80 chars** (subject ≤80 chars,
except `Merge`/`Revert`/`Reapply` which skip the subject length check) and
the commit MUST pass `./scripts/check-commit` with exit code 0 before you
consider it done. This is mechanically checked — do not eyeball it.
- **Read the workflow memory BEFORE the corresponding action**:
- **Create commits, issues, or PRs only on explicit request. Read the workflow
memory BEFORE the corresponding action**:
- Before `git commit` → `mem:workflow/creating-commits` (commit format, AI-assisted-by trailer)
- Before `gh issue create` → `mem:workflow/creating-issues` (title derivation, body template, Issue Type)
- Before `gh pr create` / `gh pr edit` → `mem:workflow/creating-prs` (title format, body structure, AI note)
@ -42,24 +59,6 @@
language may appear in the codebase is product copy rendered through the
i18n system.
## CRITICAL: Read module memories BEFORE writing any code
Do this **before planning, before coding, before touching any file**:
1. Read `critical-info` through Serena (see "Accessing memories" below) or read `.serena/memories/critical-info.md`.
It describes the project structure and tells you which modules exist.
2. From `critical-info`, identify which modules your task affects.
3. Read each affected module's **core memory** — the name is `<module>/core`
(e.g. `frontend/core`, `backend/core`, `common/core`).
4. If the core memory references deeper `mem:` memories relevant to your task, read those too.
5. Before writing or modifying Clojure or ClojureScript, read `mem:clojure/core`
and the relevant focused Clojure memories it references.
**STOP: Do not proceed until you have read the core memory of every affected module.**
Skipping this step is the #1 cause of incorrect or incomplete work.
---
## Auto-triggers
- **Security advisory URL pasted** — When the user pastes a URL matching
@ -90,77 +89,13 @@ Review every prose output against these rules before delivering.
---
# Memory system
## Implementation and verification
Memories are the **primary project guidance** — not docs or readme files.
They are dense, agent-oriented notes: terse bullets, invariants, no prose.
## Progressive discovery model
Memories form a **reference graph**, not a flat list:
```
critical-info ← read first (graph root)
└─ <section>/core ← top-level memory per section (e.g. frontend/core, backend/core)
└─ <topic> ← focused memories (e.g. frontend/handling-errors-and-debugging)
└─ ... ← deeper memories as needed
```
Follow the mandatory reading sequence above. Cross-cutting topics can also be
referenced directly from `critical-info` or other memories.
## Accessing memories
- **If Serena's `serena_repl` tool is available** (Serena 2.x): call `s.mem.read_memory(name)`
and `s.mem.list_memories()` through it.
- **If Serena's `read_memory` / `list_memories` tools are available** (Serena 1.x; some clients
show them as `serena_read_memory` / `serena_list_memories`): use them.
- Either way, `read_memory` takes a memory name (e.g. `critical-info`, `frontend/core`).
- **If Serena is NOT available**: read the filesystem directly.
Memory name `mem:foo/bar` maps to file `.serena/memories/foo/bar.md`.
## Cross-reference convention
Memories reference other memories with `mem:<section>/<name>` inside backticks.
Example: `mem:common/changes-architecture`.
When you encounter a `mem:` reference relevant to your task, read that memory next.
## Topic/folder organization
Memories are grouped into folders for modules or topics. Project modules have
a `<module>/core` memory; other topic folders may contain focused memories only.
---
# Role: Senior Software Engineer
You are a high-autonomy Senior Full-Stack Software Engineer. You have full
permission to navigate the codebase, modify files, and execute commands to
fulfill your tasks. Your goal is to solve complex technical tasks with high
precision while maintaining a strong focus on maintainability and performance.
## Operational Guidelines
1. Before writing code, describe your plan. If the task is complex, break it
down into atomic steps.
2. Be concise and autonomous.
3. Do **not** touch unrelated modules unless the task explicitly requires it.
---
# Available Scripts & Tools
## Native opencode Tools (callable directly by the LLM)
- `paren-repair` — Fix mismatched delimiters + reformat Clojure files. Example: `paren-repair(files="src/foo.clj, src/bar.cljs")`
- `penpot-psql` — Execute SQL against the Penpot database. Example: `penpot-psql(sql="SELECT version();")`
## Scripts (from repo root via `scripts/<name>`)
- `scripts/paren-repair` — Fix mismatched delimiters in Clojure/CLJS files + reformat with cljfmt. See `mem:scripts/paren-repair`.
- `scripts/psql` — Connect to the Penpot PostgreSQL database (wraps `psql` with env-var defaults). See `mem:scripts/psql`.
- `scripts/nrepl-eval.mjs` — Evaluate Clojure code via nREPL (backend + frontend).
- `scripts/check-commit` — Validate commit messages against Penpot's commit guidelines.
- `scripts/check-fmt-clj` — Check Clojure formatting without modifying files.
- `scripts/ci` — CI orchestration script for running lint, tests, format checks and, on request (`--build`), production builds across modules. See `mem:scripts/ci`.
- `scripts/gh.py` — Multi-purpose GitHub CLI helper. Subcommands: `issues` (list issues in a milestone), `prs` (fetch PR details), `advisories` (list/inspect security advisories). See `python3 scripts/gh.py --help`.
- Explore first, describe the plan before writing code, and stay within scope.
- Every behavior change needs a test. Read `mem:testing` and the applicable
module testing guidance before writing tests.
- Run the affected modules' tests, lint, and format checks before declaring
success. See `mem:scripts/ci`. Do not report completion with failing checks.
- Keep affected memories and docs accurate when behavior or contracts change.
- Do not poll background commands with `sleep` or repeated log reads. Continue
other work or wait for the completion notification.