@precisa-saude/agent-instructions 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/AGENTS.md +453 -0
  2. package/LICENSE +201 -0
  3. package/README.md +71 -0
  4. package/package.json +29 -0
package/AGENTS.md ADDED
@@ -0,0 +1,453 @@
1
+ # Shared agent instructions
2
+
3
+ > **Single source of truth** for cross-repo conventions in the
4
+ > precisa-saude ecosystem (fhir-brasil, medbench-brasil, datasus-brasil,
5
+ > platform, tooling). Published as `@precisa-saude/agent-instructions`
6
+ > on npm and consumed by each repo via imports in `CLAUDE.md`:
7
+ >
8
+ > ```markdown
9
+ > @./node_modules/@precisa-saude/agent-instructions/AGENTS.md
10
+ > @./AGENTS.md
11
+ > ```
12
+ >
13
+ > Each repo's local `AGENTS.md` holds only that repo's specific rules.
14
+ > Edit these shared rules via a PR in the `tooling` repo at
15
+ > `packages/agent-instructions/AGENTS.md` → `semantic-release` publishes
16
+ > → consumers update via `pnpm update @precisa-saude/agent-instructions`.
17
+
18
+ ## Tone and communication
19
+
20
+ Do not open responses with "You're absolutely right" or other effusive
21
+ agreement phrases. Keep a professional, direct tone without unnecessary
22
+ excitement.
23
+
24
+ ## Language — en-US for agent instructions, pt-BR for user-facing text
25
+
26
+ Agent-facing configuration (this file, each repo's `AGENTS.md`, the
27
+ `CLAUDE.md` pointers) is written in **en-US**. It's infrastructure,
28
+ sits next to ESLint/TypeScript configs, and is read by tools and
29
+ contributors from many backgrounds.
30
+
31
+ **User-facing text stays in pt-BR** with full accentuation:
32
+ documentation, READMEs, CHANGELOG, issue templates, PR templates,
33
+ commit messages, and code comments aimed at a human reader.
34
+ Identifiers (types, functions, scripts, package names) stay English.
35
+
36
+ Never drop accents in pt-BR content — it looks careless and
37
+ unprofessional.
38
+
39
+ - Wrong: `definicoes`, `referencia`, `codigo`, `clinica`, `Instalacao`, `rapido`
40
+ - Right: `definições`, `referência`, `código`, `clínica`, `Instalação`, `rápido`
41
+
42
+ Commit messages: the type (`feat`, `fix`, `refactor`, etc.) stays
43
+ English by convention, but the description is pt-BR.
44
+
45
+ ## Data integrity — never fabricate values
46
+
47
+ **CRITICAL**: when a value must come from an authoritative source
48
+ (official microdata, clinical guidelines, answer keys, LOINC codes,
49
+ model training cutoffs, etc.), **integrate the real source or
50
+ explicitly flag the gap**. Don't fill in with plausible values inferred
51
+ from a pattern, a similar name, or "probably this."
52
+
53
+ Anti-patterns to avoid:
54
+
55
+ - Completing a partial date (`2024-11` → `"14 nov. 2024"`) without
56
+ opening the publication — record `nov. 2024` if the day isn't there.
57
+ - Inferring a model's `trainingCutoff` from its release date — if the
58
+ vendor doesn't publish it, the field stays `undefined` and the model
59
+ is classified as `unknown`.
60
+ - Copying a biomarker reference range from a commercial portal — cite
61
+ SBPC/ML, WHO, PubMed, or flag the range as approximate.
62
+ - Generating DATASUS microdata values when the file is corrupted —
63
+ open an issue and wait.
64
+
65
+ General rule: an explicit gap always beats a plausible-but-wrong value.
66
+ Wrong data becomes the basis for charts, decisions, releases, and
67
+ third-party citations.
68
+
69
+ ## Verify sources and references before citing
70
+
71
+ When you add a reference of any kind — ABNT citation in docs, URL in
72
+ code, comment linking to an article, dataset source — **open the page
73
+ and confirm each field** before writing: byline author, publication
74
+ date, the institution that actually publishes (not the one hosting),
75
+ city. Never infer from a URL slug, domain, or acronym.
76
+
77
+ If a field can't be confirmed, use the ABNT conventions `[S. l.]` (no
78
+ location), `[S. n.]` (no publisher), or `[year]` instead of guessing.
79
+ Prefer an explicit gap over a plausible-but-wrong field.
80
+
81
+ Why: wrong references undermine the credibility of the page or package
82
+ they sit on. If a source is worth citing, it's worth opening.
83
+
84
+ ### Sources to avoid
85
+
86
+ For any health, scientific, or clinical content cited across the
87
+ ecosystem (biomarkers, guidelines, methodologies, reference ranges),
88
+ avoid:
89
+
90
+ - `labtestsonline.org.br` — commercial lab-testing portal, not an
91
+ authoritative academic source
92
+ - Generic organization homepages (e.g. `diabetes.org.br/`,
93
+ `endocrino.org.br/`, `cardiol.br/`) — cite the specific publication,
94
+ not the homepage
95
+
96
+ ### Preferred sources (in this order)
97
+
98
+ 1. PubMed articles (`pubmed.ncbi.nlm.nih.gov/PMID/`)
99
+ 2. SciELO Brasil articles (`scielo.br/j/...`)
100
+ 3. Official guideline PDFs (SBD, ABESO, SBC, SBPC/ML, WHO, Ministério
101
+ da Saúde technical reports)
102
+ 4. Society publications with DOI/ISBN (not homepage URLs)
103
+
104
+ Repo-specific additions (extra banned domains in a particular domain,
105
+ etc.) live in each repo's local `AGENTS.md`.
106
+
107
+ ## Follow agreed plans — no silent deviations
108
+
109
+ **CRITICAL**: when implementing a feature based on an agreed plan (in
110
+ `docs/development/`, `.claude/plans/`, or a Linear issue), follow the
111
+ plan exactly or ask before deviating.
112
+
113
+ 1. If a step looks complex, **ask first**: "This step requires X.
114
+ Proceed, or prefer a simpler approach?"
115
+ 2. If you want to simplify, **propose the change explicitly**: "I can
116
+ do an MVP first. Works?"
117
+ 3. **Never silently substitute** a simpler implementation for what was
118
+ agreed.
119
+
120
+ ## Test coverage — never regresses
121
+
122
+ When a coverage check fails, the fix is to add tests, not lower
123
+ thresholds. Coverage should increase over time.
124
+
125
+ 1. Add tests covering the new or modified code
126
+ 2. Focus on branch coverage (usually the hardest threshold)
127
+ 3. Fluctuations within ~0.5% of the threshold are normal — cover the
128
+ gap with a quick test rather than moving the threshold
129
+
130
+ Never disable the pre-push hook, never edit `vitest.config` to lower
131
+ the limit, never use `--no-verify` to push below threshold.
132
+
133
+ ## Keep documentation up to date
134
+
135
+ When making significant changes, update the relevant documentation in
136
+ the same PR. Each repo maintains a specific "change type → files to
137
+ update" table in its local `AGENTS.md`. General rule: a new
138
+ package/feature/endpoint/script used by the user should appear
139
+ somewhere the user can find it.
140
+
141
+ ## Code conventions — shared across all repos
142
+
143
+ All repos in the ecosystem share the same baseline:
144
+
145
+ - **Node 22**, **pnpm workspaces**, **Turborepo** for monorepo tasks
146
+ - **TypeScript strict** with `noUncheckedIndexedAccess` — enforced via
147
+ `@precisa-saude/tsconfig`
148
+ - **ESM + CJS dual builds** via `tsup` for publishable packages
149
+ - **Vitest** for tests with an **80% coverage threshold** (branches,
150
+ functions, lines, statements) per publishable package
151
+ - **ESLint** via `@precisa-saude/eslint-config`
152
+ - **Prettier** via `@precisa-saude/prettier-config`
153
+ - **Commitlint** via `@precisa-saude/commitlint-config` (Conventional
154
+ Commits + AI-attribution blocking)
155
+ - **Husky** hooks for pre-commit (format + lint) and pre-push (lockfile
156
+ - format + lint + typecheck + test)
157
+ - **Renovate** for automated dependency updates
158
+
159
+ Changes to any of these baselines should be proposed in `tooling` and
160
+ rolled out to consumers via `precisa sync` / `pnpm update`. Repo-level
161
+ overrides are allowed only when justified in the repo's local
162
+ `AGENTS.md` with the reason for diverging.
163
+
164
+ ## Commits require explicit permission
165
+
166
+ **CRITICAL**: never create a commit without explicit user approval.
167
+ After making changes, announce the proposed commit message and wait for
168
+ confirmation before running `git commit`. This lets the user review
169
+ the changes, adjust the message, or decide to split across multiple
170
+ commits.
171
+
172
+ ## No AI attribution in commits
173
+
174
+ Do not include `Co-Authored-By: Claude`, `Generated with Claude`, or
175
+ similar lines. The `commit-msg` hook blocks these patterns — don't try
176
+ to bypass.
177
+
178
+ ## Always use pull requests
179
+
180
+ **CRITICAL**: never push directly to `main`. Always create a feature
181
+ branch and open a PR for review. Standard flow:
182
+
183
+ 1. Create a feature branch from an up-to-date `main`
184
+ 2. Commit on the feature branch
185
+ 3. Push and open a PR
186
+ 4. Merge via GitHub after review
187
+
188
+ If you accidentally committed to `main`:
189
+
190
+ ```bash
191
+ git branch feature-branch
192
+ git reset --hard origin/main
193
+ git checkout feature-branch
194
+ git push -u origin feature-branch
195
+ gh pr create --title "..." --body "..."
196
+ ```
197
+
198
+ ## Never skip git hooks
199
+
200
+ **CRITICAL**: do not use `--no-verify`, `--no-gpg-sign`, or any flag
201
+ that bypasses hooks in `git commit`, `git push`, or other git commands.
202
+ If a hook fails, **fix the underlying issue**.
203
+
204
+ ## Pull with rebase before committing
205
+
206
+ To keep history linear, always:
207
+
208
+ ```bash
209
+ git pull --rebase origin main
210
+ ```
211
+
212
+ Never use `git pull` without `--rebase` or `git merge` — both produce
213
+ merge commits.
214
+
215
+ ## GPG signing
216
+
217
+ All commits are signed. Git global config already has
218
+ `commit.gpgsign = true`. Don't publish unsigned commits.
219
+
220
+ ## Conventional Commits
221
+
222
+ Messages follow Conventional Commits (`type(scope): description`).
223
+ Valid scopes per repo are defined in `CONVENTIONS.md` when present.
224
+ Common types: `feat`, `fix`, `perf`, `refactor`, `docs`, `style`,
225
+ `test`, `ci`, `build`, `chore`, `revert`.
226
+
227
+ ## Adding dependencies requires approval
228
+
229
+ **Always ask before adding npm dependencies.** Include:
230
+
231
+ - What the package does
232
+ - Why it's needed
233
+ - Bundle-size and peer-deps impact
234
+ - Whether an existing dep could serve
235
+
236
+ Repo-specific dependency boundaries (zero-runtime-dep packages,
237
+ allowed dep graphs, etc.) live in each repo's local `AGENTS.md`.
238
+
239
+ ## Run lint and typecheck before committing
240
+
241
+ ```bash
242
+ pnpm turbo run lint typecheck
243
+ ```
244
+
245
+ Pre-push hooks run tests/coverage regardless, but catching issues
246
+ locally shortens the feedback loop.
247
+
248
+ ## Permission prompts — be careful with "Always allow"
249
+
250
+ When the agent asks for approval to run a Bash command, **don't select
251
+ "Always allow"** for:
252
+
253
+ - Commands with heredocs or multi-line content (`cat > file << 'EOF' ...`)
254
+ - Commands with inline secrets (`TOKEN="..." curl ...`)
255
+ - Long commit messages (`git commit -m "multi-paragraph message"`)
256
+ - One-off commands that won't be reused verbatim
257
+
258
+ "Always allow" saves the complete command text to
259
+ `.claude/settings.local.json`. Complex commands can break the settings
260
+ parser (patterns with `:*` conflict with permission syntax) and leak
261
+ secrets into plaintext config.
262
+
263
+ **Use "Allow once"** for complex or one-off commands. Reserve "Always
264
+ allow" for short, reusable prefixes (`Bash(aws s3 ls:*)`).
265
+
266
+ ## Responding to PR reviews — always reply and resolve
267
+
268
+ Whenever there are review comments (human or automated bot) on a PR
269
+ you're following:
270
+
271
+ 1. **Read every comment** before moving on:
272
+
273
+ ```bash
274
+ gh api repos/OWNER/REPO/pulls/<N>/comments \
275
+ --jq '.[] | {id, path, line, body: (.body | split("\n")[0])}'
276
+ ```
277
+
278
+ 2. **For each comment**:
279
+ - **Implemented the suggestion**: reply citing the fix commit
280
+ ("Addressed in `abc123`: <explanation>") and resolve the thread.
281
+ - **Disagree or skipping**: reply with the technical reason. Resolve
282
+ the thread.
283
+ - **Need a user decision**: reply asking for clarification, do NOT
284
+ resolve the thread, escalate.
285
+
286
+ 3. **Reply via REST**:
287
+
288
+ ```bash
289
+ gh api -X POST repos/OWNER/REPO/pulls/<N>/comments/<COMMENT_ID>/replies \
290
+ -f body="<text>"
291
+ ```
292
+
293
+ 4. **Resolve via GraphQL**:
294
+
295
+ ```bash
296
+ gh api graphql -f query='
297
+ { repository(owner: "<o>", name: "<r>") {
298
+ pullRequest(number: <n>) {
299
+ reviewThreads(first: 50) {
300
+ nodes { id isResolved comments(first: 1) { nodes { databaseId } } }
301
+ }
302
+ }
303
+ } }'
304
+
305
+ gh api graphql -f query='
306
+ mutation { resolveReviewThread(input: { threadId: "<id>" }) { thread { isResolved } } }'
307
+ ```
308
+
309
+ 5. Fix commits in response to review cite `Refs: #<PR>` in the footer.
310
+
311
+ **Reply and resolve in batch — don't prompt per comment.** On PRs with
312
+ many comments, run all `gh api` calls in a single chained command or
313
+ loop.
314
+
315
+ **CRITICAL: reply and resolve BEFORE pushing the fix.** Sequence:
316
+
317
+ 1. Commit locally (don't push yet)
318
+ 2. Reply to every comment
319
+ 3. Resolve every thread
320
+ 4. Then push
321
+
322
+ Prevents the automated reviewer from running again immediately and
323
+ generating new comments before you've closed the existing ones.
324
+
325
+ Silence on review isn't neutral — it's debt. Close the loop.
326
+
327
+ ### Autonomous polling after push — close the loop without being asked
328
+
329
+ After `gh pr create` or `git push` of a fix responding to review, **don't
330
+ wait for the user to ask whether new comments arrived**. Schedule a
331
+ check yourself with `ScheduleWakeup(delaySeconds: 270, ...)` — 270s
332
+ instead of 300s keeps the prompt cache warm (TTL is 5min).
333
+
334
+ On wake-up, follow the reply-and-resolve protocol above: list new
335
+ comments, reply, resolve threads. If there are fixes to apply, commit
336
+ → reply → resolve → push, and **schedule the next round** with the
337
+ same delay. Stop after two consecutive rounds with no new comments, or
338
+ when the user says so.
339
+
340
+ Goal: shorten review latency. The user shouldn't need to ask "did the
341
+ comments arrive yet?"
342
+
343
+ ## Worktrees for parallel sessions
344
+
345
+ **CRITICAL**: when more than one agent session might be active on the
346
+ repo, use a dedicated `git worktree` per feature. Sharing the working
347
+ tree across parallel sessions has already corrupted state (commits on
348
+ the wrong branch, files from another session ending up in `git add`).
349
+
350
+ Every repo with a frontend or dev server uses the shared
351
+ `@precisa-saude/worktree-cli` package. Per-repo port allocation,
352
+ service filters, and registry paths are declared in each repo's root
353
+ `package.json` under the `"worktree"` field.
354
+
355
+ Invoke via the package bin (preferred) or the backward-compat shim:
356
+
357
+ ```bash
358
+ pnpm exec precisa-worktree list # all worktrees + ports + status
359
+ pnpm exec precisa-worktree setup feat/mine # create + install + allocate
360
+ pnpm exec precisa-worktree dev # start dev servers (foreground)
361
+ pnpm exec precisa-worktree dev --detach # background; logs to /tmp/
362
+ pnpm exec precisa-worktree dev --force # kill conflicting port process
363
+ pnpm exec precisa-worktree stop # kill this worktree's servers
364
+ pnpm exec precisa-worktree logs --service=api # tail a specific service
365
+ pnpm exec precisa-worktree teardown feat/mine # cleanup after merge
366
+ ./scripts/worktree.sh <cmd> # shim, equivalent to above
367
+ ```
368
+
369
+ Commands that accept `[branch]` auto-detect the branch from `cwd` when
370
+ invoked inside a linked worktree. In the main worktree, pass the
371
+ branch explicitly.
372
+
373
+ Repos without a dev server (tooling itself, pure-library packages) use
374
+ plain `git worktree add` — the parallel-session rules still apply.
375
+
376
+ See `@precisa-saude/worktree-cli`'s
377
+ [README](https://github.com/Precisa-Saude/tooling/tree/main/packages/worktree-cli)
378
+ for the full config schema and command reference.
379
+
380
+ ### Before starting any feature
381
+
382
+ 1. Run `./scripts/worktree.sh list` and `git branch --show-current`.
383
+ State which worktree/branch you're in.
384
+ 2. If a worktree already exists for the feature, `cd` into it. Don't
385
+ create a duplicate.
386
+ 3. If none exists, run `./scripts/worktree.sh setup <branch>`.
387
+ 4. **Never** run `git checkout <branch>` in the main worktree to
388
+ "switch to the feature branch" — that changes the HEAD of a working
389
+ tree another session may be using.
390
+
391
+ ### During work
392
+
393
+ - Before `git add`, confirm `git branch --show-current`. If it changed
394
+ since your last commit, STOP — another session touched the working
395
+ tree.
396
+ - Run `git status` frequently. Files you didn't touch in this session
397
+ are probably from another one; **don't** include them (`git add
398
+ <file>` explicit per path, never `git add -A` or `git add .`).
399
+ - `git reflog` when something feels off — it's the source of truth.
400
+ - **Each worktree runs its own services** on its allocated ports.
401
+ Never redirect a worktree's frontend to the main worktree's API —
402
+ the worktree may have backend changes specific to its branch.
403
+
404
+ ### Starting a dev server in a worktree
405
+
406
+ `setup` allocates ports but does NOT start dev servers. Use:
407
+
408
+ - **Foreground** (blocks, good for inspecting output, Ctrl-C to stop):
409
+ ```bash
410
+ pnpm exec precisa-worktree dev
411
+ ```
412
+ - **Detached** (backgrounded, survives the agent session, writes to
413
+ `/tmp/<logPrefix>-<branch>.log` per service):
414
+ ```bash
415
+ pnpm exec precisa-worktree dev --detach
416
+ ```
417
+
418
+ From an agent session, always use `--detach`; the foreground variant
419
+ will be killed when the Bash tool call times out.
420
+
421
+ Verify with e.g. `sleep 5 && curl -sI http://localhost:<PORT> | head -1`
422
+ using the port the CLI printed.
423
+
424
+ Exact port numbers, service filters, and env-var wiring are in each
425
+ repo's `package.json` under the `"worktree"` field — the CLI reads
426
+ them; each repo's `AGENTS.md` restates them for quick reference.
427
+
428
+ ### Cleanup after merge
429
+
430
+ When asked to merge a PR, after the merge completes, **automatically
431
+ clean up**:
432
+
433
+ ```bash
434
+ cd "$(repo main worktree)"
435
+ git pull --rebase origin main
436
+ pnpm exec precisa-worktree teardown <branch>
437
+ ```
438
+
439
+ This stops the dev servers, removes the worktree, deletes the local
440
+ branch, frees the ports in the registry, and clears logs. Don't do any
441
+ of this manually. Pass `--keep-branch` to preserve the local branch.
442
+
443
+ ## Plan persistence
444
+
445
+ Implementation plans created during conversations should be persisted
446
+ for reference across sessions:
447
+
448
+ 1. **Location**: `docs/development/PLAN.md` (or a topical subfolder)
449
+ 2. **Format**: markdown with Objective, Current status, Next steps,
450
+ Context
451
+ 3. **Update regularly** as work progresses
452
+ 4. **Archive completed plans**: move to
453
+ `docs/development/completed/YYYY-MM-DD-name.md`
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @precisa-saude/agent-instructions
2
+
3
+ Single source of shared rules for AI coding agents (Claude Code,
4
+ Cursor, Copilot, etc.) across every Precisa Saúde repository.
5
+
6
+ ## What it is
7
+
8
+ One `AGENTS.md` file with the cross-cutting conventions: tone, git,
9
+ hooks, reviews, worktrees, source verification, test coverage, code
10
+ conventions. Versioned and published to npm like any other package.
11
+ Consumed by reference (`@path` import) from each repo's `CLAUDE.md`,
12
+ with no duplication.
13
+
14
+ The [AGENTS.md](https://agents.md/) standard is open — Claude Code,
15
+ Codex, Cursor, Zed, and others support it via import or direct loading.
16
+
17
+ ## How to consume
18
+
19
+ In each consumer repo:
20
+
21
+ ```bash
22
+ pnpm add -D @precisa-saude/agent-instructions
23
+ ```
24
+
25
+ In the repo's `CLAUDE.md` (Claude Code pointer):
26
+
27
+ ```markdown
28
+ # Claude instructions
29
+
30
+ This repository follows the AGENTS.md convention. Shared rules across
31
+ the precisa-saude ecosystem live in `@precisa-saude/agent-instructions`,
32
+ and repo-specific rules live in `./AGENTS.md`.
33
+
34
+ @./node_modules/@precisa-saude/agent-instructions/AGENTS.md
35
+ @./AGENTS.md
36
+ ```
37
+
38
+ The repo's local `AGENTS.md` contains only that repo's specific section
39
+ (structure, domain conventions, commit scopes, etc.). The shared base
40
+ lives in `node_modules` and is refreshed via
41
+ `pnpm update @precisa-saude/agent-instructions`.
42
+
43
+ ## Reading the shared base on GitHub
44
+
45
+ Because the shared content is installed via npm, readers browsing a
46
+ consumer repo on GitHub won't see the base inline. To read it:
47
+
48
+ https://github.com/Precisa-Saude/tooling/blob/main/packages/agent-instructions/AGENTS.md
49
+
50
+ Each consumer repo includes a link to this URL at the top of its local
51
+ `AGENTS.md` so readers can find the shared rules.
52
+
53
+ ## How to edit shared rules
54
+
55
+ 1. Edit `packages/agent-instructions/AGENTS.md` in the `tooling` repo
56
+ 2. Open a PR in `tooling` — the review bot checks the change
57
+ 3. After merge, `semantic-release` publishes a new version to npm
58
+ 4. Consumers pick it up via
59
+ `pnpm update @precisa-saude/agent-instructions` (or Renovate /
60
+ Dependabot automates it)
61
+
62
+ For rules specific to a single repo, edit that repo's local `AGENTS.md`
63
+ — don't touch the shared base.
64
+
65
+ ## Language
66
+
67
+ This file and the shared base are in **en-US** — agent configuration
68
+ is infrastructure, sitting next to ESLint/TypeScript config, read by
69
+ tools and contributors from many backgrounds. User-facing content in
70
+ the ecosystem (READMEs, CHANGELOG, commit messages, issue/PR templates,
71
+ code comments aimed at readers) stays in pt-BR with full accentuation.
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@precisa-saude/agent-instructions",
3
+ "version": "1.1.0",
4
+ "description": "Shared agent instructions (AGENTS.md) for Precisa Saúde repositories — the single source of truth for cross-repo conventions, consumed by Claude Code and other agent-aware editors via @path imports.",
5
+ "keywords": [
6
+ "agents",
7
+ "agents-md",
8
+ "claude",
9
+ "claude-code",
10
+ "precisa-saude"
11
+ ],
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/Precisa-Saude/tooling.git",
15
+ "directory": "packages/agent-instructions"
16
+ },
17
+ "license": "Apache-2.0",
18
+ "author": "Precisa Saúde",
19
+ "files": [
20
+ "AGENTS.md",
21
+ "README.md"
22
+ ],
23
+ "engines": {
24
+ "node": ">=22.0.0"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ }
29
+ }