3434- One class per file when substantial; group small related classes.
3535- No ` **kwargs ` — use explicit keyword arguments.
3636- No string-based dispatch (e.g. ` getattr(self, f'_{name}') ` ); write
37- named methods (` _set_sample_form ` , ` _set_beam_mode ` ).
37+ named methods (` _set_sample_form ` , ` _set_beam_mode ` ). Narrow framework
38+ metadata lookups are allowed when the attribute name is a class-level
39+ declaration, is not user input, and is validated in one central place;
40+ for example, ` CategoryItem._category_entry_name ` .
3841- Public attrs are either editable (getter+setter property) or read-only
3942 (getter only). For internal mutation of read-only props, use a private
4043 ` _set_<name> ` method, not a public setter.
7780## Testing
7881
7982- Every new module, class, or bug fix ships with tests. See
80- ` docs/architecture/architecture .md ` §10 for the full strategy.
83+ ` docs/dev/adrs/accepted/test-strategy .md ` for the full strategy.
8184- Unit tests mirror the source tree:
8285 ` src/easydiffraction/<pkg>/<mod>.py ` →
8386 ` tests/unit/easydiffraction/<pkg>/test_<mod>.py ` . Verify with
102105
103106- Before any structural/design change (new categories, factories,
104107 switchable-category wiring, datablocks, CIF serialisation), read
105- ` docs/architecture/architecture.md ` and follow documented patterns.
106- Localised bug fixes or test updates need only this file.
108+ ` docs/dev/adrs/index.md ` and the relevant accepted ADRs. Localised bug
109+ fixes or test updates need only this file.
110+ - Development documentation lives under ` docs/dev/ ` . Use
111+ ` docs/dev/adrs/index.md ` as the architecture and decision navigation
112+ surface; there is no separate ` architecture.md ` source of truth.
107113- Project is in beta: no legacy shims, no deprecation warnings — update
108114 tests and tutorials to the current API.
109115- Minimal diffs; don't reformat working code. Fix only what's asked;
112118 resolves them.
113119- Never remove or replace existing functionality without explicit
114120 confirmation — highlight every removal and wait for approval.
115- - When renaming, grep the entire project (code, tests, tutorials, docs).
121+ - When renaming or auditing usages, search the entire project (code,
122+ tests, tutorials, docs). Use ` git grep -n ` because all contributors
123+ have Git; do not assume ` rg ` is installed. If ` git grep ` is
124+ unavailable, fall back to ` find ... -type f ` plus ` grep -n ` .
116125- Each change is atomic and single-commit-sized: make one change,
117126 suggest the commit message, then stop and wait for confirmation.
118127- When in doubt, ask.
137146
138147Non-trivial changes use a two-phase workflow:
139148
140- - ** Phase 1 — Implementation.** Code, docs, and architecture updates
141- only. Do not create or run tests unless the user explicitly asks. When
142- done, present for review and iterate until approved.
149+ - ** Phase 1 — Implementation.** Code and docs updates only. Update ADRs
150+ when the change affects architecture or documented decisions. Do not
151+ create or run tests unless the user explicitly asks. When done,
152+ present for review and iterate until approved.
143153- ** Phase 2 — Verification.** Add/update tests, then run ` pixi run fix ` ,
144154 ` pixi run check ` , ` pixi run unit-tests ` , ` pixi run integration-tests ` ,
145155 ` pixi run script-tests ` .
146156
147157Notes:
148158
149- - ` pixi run fix ` regenerates ` docs/architecture/package-structure-*.md `
150- automatically — never edit those by hand. Don't review auto-fixes;
151- accept and move on. Then ` pixi run check ` until clean.
159+ - ` pixi run fix ` regenerates ` docs/dev/package-structure/full.md ` and
160+ ` docs/dev/package-structure/short.md ` automatically — never edit those
161+ by hand. Don't review auto-fixes; accept and move on. Then
162+ ` pixi run check ` until clean.
163+ - When a check command needs saved output for analysis, capture the log
164+ and preserve the command exit code with a zsh-safe variable name:
165+ ` pixi run check > /tmp/easydiffraction-check.log 2>&1; check_exit_code=$?; tail -n 200 /tmp/easydiffraction-check.log; exit $check_exit_code ` .
166+ Never assign to ` status ` in zsh; it is readonly. Use task-specific
167+ names such as ` check_exit_code ` , ` unit_tests_exit_code ` , or
168+ ` script_tests_exit_code ` .
152169- Open issues / design questions / planned improvements live in
153- ` docs/architecture/issues_open .md ` (priority-ordered). On resolution,
154- move to ` docs/architecture/issues_closed .md ` and update
155- ` architecture .md` if affected.
170+ ` docs/dev/issues/open .md ` (priority-ordered). On resolution, move to
171+ ` docs/dev/issues/closed .md ` and update the relevant ADR or
172+ ` docs/dev/adrs/index .md` if affected.
156173
157174### Planning
158175
159176When asked to create a plan:
160177
178+ - Start the plan by referencing this file:
179+ ` .github/copilot-instructions.md ` . State any deliberate exception to
180+ these instructions in the plan itself.
161181- First gather enough repository context to make the plan concrete. Ask
162182 all ambiguous or unclear questions in one concise batch; record
163183 unresolved questions in the plan if the user wants it saved before
164184 answering them.
165- - Save plans as ` docs/dev/plan_<feature-name>.md ` (lowercase,
166- dash-separated, e.g. ` plan_background-refactor.md ` ). Use the same
167- ` <feature-name> ` for the implementation branch
168- (` feature/<feature-name> ` ). Do not push the branch unless asked.
185+ - Save plans as ` docs/dev/plans/<feature-name>.md ` (lowercase,
186+ dash-separated, e.g. ` docs/dev/plans/background-refactor.md ` ). When a
187+ plan implements one ADR, use the same slug as the ADR file; for
188+ example, ` docs/dev/adrs/suggestions/foo.md ` maps to
189+ ` docs/dev/plans/foo.md ` . If a plan has no corresponding ADR or spans
190+ multiple ADRs, choose a concise feature slug and list all related ADRs
191+ in the plan. Use the same ` <feature-name> ` for the implementation
192+ branch (` feature/<feature-name> ` ). Do not push the branch unless
193+ asked.
169194- Include a status checklist with ` [ ] ` items; mark ` [x] ` as completed
170195 during implementation.
171196- Apply the two-phase workflow (Phase 1 implementation, Phase 2
@@ -185,6 +210,12 @@ When asked to create a plan:
185210 files likely to change, decisions already made, open questions,
186211 verification commands for Phase 2, and a short suggested commit
187212 message or branch name when useful.
213+ - Verification commands in plans must include the zsh-safe log-capture
214+ pattern from ** Workflow** whenever saved output is needed for later
215+ analysis.
216+ - Before saving a plan, verify that referenced files, directories,
217+ scripts, and task names exist locally when that is practical. If a
218+ referenced tool is optional or missing, include an available fallback.
188219- End every plan with a "Suggested Pull Request" section containing a
189220 short PR title and a brief end-user-oriented description. Keep this
190221 section non-technical enough for scientists and other users to
0 commit comments