Skip to content

docs: add CSS, component-extraction and testability guidance for agents - #88

Merged
moodyjmz merged 14 commits into
mainfrom
docs/agents-component-css-testing-guidance
Aug 10, 2026
Merged

docs: add CSS, component-extraction and testability guidance for agents#88
moodyjmz merged 14 commits into
mainfrom
docs/agents-component-css-testing-guidance

Conversation

@moodyjmz

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #84. Adds four rules to AGENTS.md covering what came up while redoing #79 and #83 this session:

  • Reuse CSS variables and existing structure — prefer design tokens over hardcoded pixel/colour values; check a comparable component's compiled CSS or src/ usage before hardcoding, and never invent a var() that isn't defined anywhere.
  • Extract components over duplicated template blocks — only for genuine multi-site duplication where a future change would need applying everywhere to stay correct, not surface-level similarity. Scoped as its own commit when pulling apart pre-existing duplication (per "Commit atomically"), unless the component is new to the feature being built.
  • Prefer existing NC/Vue libraries over hand-rolled markup — check @nextcloud/vue/components before writing raw HTML/CSS.
  • Structure code so it's easily unit-testable — small, focused functions/components with explicit inputs, but not extracted solely to reach a test.

This draft went through an internal adversarial review pass before being finalized — it caught and fixed a contradiction with the atomic-commits rule, a too-loose "two call sites" abstraction threshold, a missing test-induced-extraction caveat, and a fragile/unguarded CSS-token-lookup instruction. All four are addressed in the wording above.

Test plan

  • N/A — docs only, no code paths affected

@moodyjmz
moodyjmz marked this pull request as draft July 23, 2026 14:40
moodyjmz and others added 14 commits August 10, 2026 10:16
Adds four rules covering what came up while redoing #79/#83 this
session: reuse existing design tokens over hardcoded values, extract
components only for genuine multi-site duplication (as its own
commit unless the component is new to the feature), prefer
@nextcloud/vue over hand-rolled markup, and structure code for
testability without extracting solely to reach a test.

Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
Restructures the previous commit's four new sections plus the
existing ones into a tighter set, replacing the "extract only for
2+ call sites" rule with a naming-based test — validateFilename in
this repo is a legitimate single-call-site extraction that the old
call-site-count rule would have wrongly discouraged.

Also fixes a real gap found in review: the pre-PR checklist was
missing npm run stylelint, a separate CI gate from npm run lint.

Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
Consolidates the reuse and extraction sections down to their
essential positive rules (name the responsibility; use the design
token or don't invent one) and drops persuasion aimed at a reader
who isn't there. Corrects the var() fallback claim to match the
actual CSS spec behaviour (guaranteed-invalid -> inherited/initial,
not cascade fallback), restores that the bot commits assets (not
just compiles them) and notes /compile needs a human to type it, and
adds the "name needs an 'and'" check as a mechanical extraction test.

Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
The stale-base warning claimed DCO failures that base staleness cannot
cause, and implied "Check build changes" fails only on stale bases when
it fails on any uncompiled src change by design — replace it with the
actual mechanism (CI builds the merge ref, so a moved main makes
compiled assets drift again). State the conventional-commit headline
format CI enforces on every commit, restore the reviewability rationale
for atomic commits, rename the commit section to a single concern, note
/compile requires a maintainer, and add the composer gates (lint,
cs:check, psalm, openapi) that the JS-only pre-PR checklist omitted.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
The app's roadmap is token-authenticated document serving, where a
widened TTL or a casually added #[NoCSRFRequired] is an authentication
change, not a fix. Require reviewable justification for loosening any
check, ban secrets and file paths from logs, and close the baseline
escape hatch for psalm findings.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
Enterprise deployments audit accessibility, so regressions block
releases rather than queueing as polish. State the floor: accessible
names on interactive elements, no colour-only state, keyboard
reachability with visible focus — and note that @nextcloud/vue
components ship these semantics already, reinforcing reuse. The
current eslint config carries no accessibility rules, so the section
says plainly that the check is manual rather than pointing at a gate
that does not exist.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
Anything that grows with a user's file count gets capped or paginated,
component-registered listeners and timers are released in onUnmounted
(TemplateSection.vue is the in-repo shape), file contents stream rather
than load whole since office documents have no upper size, and new
dependencies justify their bundle cost.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
The repo pairs every unit in src/utils/ and src/components/ with a
.spec.ts sibling, but the guidance only asked for testable structure,
not tests. State the requirement as a completion criterion under
commit discipline — inside the separation-of-concerns section it
would read as a tax on the extraction that section argues for.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
A rule an agent can satisfy by articulating a plausible reason is a
rule an agent will self-certify past — the security-attribute and
bundle-cost judgements are exactly where that happens, not just the
extraction seams. Name those triggers and generalize to any call a
reviewer could reasonably contest. Unattended, the fallback is the
narrower, easier-to-reverse option rather than "leave it", which an
agent would treat as inapplicable when the contested change blocks
the feature; the PR-description flag applies either way, since an
agent cannot reliably tell whether it is unattended.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
The spec-sibling rule above only covers new units. It doesn't say
anything about changing what an existing tested function returns or
accepts, which is a different failure mode: the specs already exist,
they just go stale silently until someone runs test:unit. That gap is
what let #100 change getAllOfficeFiles's return shape while leaving
two existing spec files asserting the old one.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
Neither of the two testing rules just added stops the failure mode
where a red test gets skipped, deleted, or de-fanged (a dulled matcher,
a dropped case) instead of the underlying code getting fixed — the PR
still goes green, the bug just loses its test coverage along the way.
State it as its own rule so a genuine behavior-change update to an
expectation isn't confused with silencing one.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
The JS checklist runs test:unit; the PHP one didn't, despite
composer.json defining the same script. A branch about tightening
test discipline shouldn't skip reminding PHP changes to run their
own tests before opening a PR.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
The two existing testing rules cover a new unit and a changed
signature, but not the most common shape a bug fix takes: same
signature, corrected behavior. That gap is exactly what PR #85's own
regression test closed (newest-first cap) and what the DAV
orderby/limit fix in #100 needed independent of its return-shape
change — the doc's rules shouldn't cover the shapes that made this
branch's own examples but miss the shape most bug fixes actually are.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
The red-test rule only recognized two causes: the code is wrong, or
behavior changed on purpose. That left no legitimate path for a test
that was simply wrong to begin with (asserting on a mock, flaky),
which would either force fixing code that isn't broken or invite a
dishonest "behavior changed" justification to stay compliant. Add the
third case, gated the same way as the others — justify it in the
commit — and route it through the existing contestable-call rule
rather than leaving it as a unilateral judgment call.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: James Manuel <moodyjmz@users.noreply.github.com>
@moodyjmz
moodyjmz force-pushed the docs/agents-component-css-testing-guidance branch from d6d271e to d95e231 Compare August 10, 2026 08:17
@moodyjmz
moodyjmz requested a review from Aiiaiiio August 10, 2026 08:17
@moodyjmz
moodyjmz marked this pull request as ready for review August 10, 2026 08:18

@Aiiaiiio Aiiaiiio left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very detailed. I believe a lot of this came from experience :) Starting to be useful for humans as well.

@moodyjmz
moodyjmz merged commit 88e5db9 into main Aug 10, 2026
28 checks passed
@moodyjmz
moodyjmz deleted the docs/agents-component-css-testing-guidance branch August 10, 2026 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants