@carecard/auth-util 3.1.12 → 3.1.15
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.
- package/.agents/config.toml +2 -0
- package/.agents/skills/carecard-workspace-standards/SKILL.md +388 -0
- package/.agents/skills/carecard-workspace-standards/agents/openai.yaml +4 -0
- package/.agents/skills/github-pr-create-update/SKILL.md +188 -0
- package/.agents/skills/github-pr-create-update/agents/openai.yaml +5 -0
- package/.agents/skills/github-pr-merge-cleanup/SKILL.md +175 -0
- package/.agents/skills/github-pr-merge-cleanup/agents/openai.yaml +5 -0
- package/.agents/skills/pkg-auth-util-auth-crypto-library/SKILL.md +236 -0
- package/.agents/skills/pkg-auth-util-auth-crypto-library/agents/openai.yaml +4 -0
- package/.agents/skills/software-design-patterns-and-clean-code/SKILL.md +73 -0
- package/.codex/config.toml +2 -0
- package/.prettierignore +17 -0
- package/.prettierrc.cjs +32 -0
- package/.prettierrc.js +12 -0
- package/eslint.config.mjs +14 -0
- package/index.d.ts +197 -151
- package/index.js +29 -28
- package/jest.config.js +16 -0
- package/lib/jwtUtilAuth.js +152 -86
- package/lib/keyGen.js +18 -22
- package/lib/pwdUtilAuth.js +25 -25
- package/lib/stringUtilAuth.js +43 -49
- package/package.json +24 -12
- package/readme.md +24 -5
- package/scripts/rename-cjs.js +13 -0
- package/src/cryptoUtilAuth.ts +111 -0
- package/src/index.ts +6 -0
- package/src/jwtUtilAuth.ts +85 -0
- package/src/keyGen.ts +14 -0
- package/src/pwdUtilAuth.ts +78 -0
- package/src/strEncryptUtil.ts +159 -0
- package/src/stringUtilAuth.ts +102 -0
- package/tests/cryptoUtilAuth.test.ts +97 -0
- package/tests/index.test.ts +157 -0
- package/tests/indexStringUtilAuth.test.ts +95 -0
- package/tests/jwtUtilAuth.test.ts +33 -0
- package/tests/keyGen.test.ts +26 -0
- package/tests/keys/keys.ts +24 -0
- package/tests/pwdUtilAuth.test.ts +40 -0
- package/tsconfig.base.json +14 -0
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.esm.json +7 -0
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: carecard-workspace-standards
|
|
3
|
+
description: Follow the shared SO_CareCardCa/CareCard workspace coding, testing, repository, dependency, shared package, frontend, database, API response, and security standards. Use before modifying, testing, reviewing, or debugging any api-*, pkg-*, app-*, website, dashboard, or other CareCard repository in this workspace, especially when choosing validation commands, package boundaries, TypeScript types, dependencies, API contracts, database logic, service patterns, or frontend architecture.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# CareCard Workspace Standards
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Use before modifying, testing, reviewing, or debugging any CareCard workspace repository or cross-repository contract.
|
|
11
|
+
|
|
12
|
+
## When To Use
|
|
13
|
+
|
|
14
|
+
- Use before modifying, testing, reviewing, or debugging any CareCard workspace repository or cross-repository contract.
|
|
15
|
+
- Use as the first shared context before selecting narrower repository-specific skills.
|
|
16
|
+
|
|
17
|
+
## When Not To Use
|
|
18
|
+
|
|
19
|
+
- Do not use for service-local behavior that should remain inside one API or app.
|
|
20
|
+
- Do not change package public APIs without updating consumers and compatibility tests.
|
|
21
|
+
|
|
22
|
+
## Relevant Files And Directories
|
|
23
|
+
|
|
24
|
+
- `.agents/config.toml`
|
|
25
|
+
- `.agents/skills`
|
|
26
|
+
- `api-*` services
|
|
27
|
+
- `pkg-*` packages
|
|
28
|
+
- `app-*` frontends
|
|
29
|
+
- `.husky` and `.junie` validation guidance
|
|
30
|
+
|
|
31
|
+
## Coding Principles
|
|
32
|
+
|
|
33
|
+
- Preserve the repository structure, naming style, module system, and local helper patterns.
|
|
34
|
+
- Prefer readable, maintainable code with meaningful function, variable, file, and test names.
|
|
35
|
+
- Avoid new dependencies unless the existing stack cannot reasonably solve the task and the user confirms the tradeoff.
|
|
36
|
+
- Keep public exports stable and update CommonJS, ESM, TypeScript declaration, and compatibility surfaces together when present.
|
|
37
|
+
|
|
38
|
+
## Testing Expectations
|
|
39
|
+
|
|
40
|
+
- Write or update package tests before behavior or public API changes.
|
|
41
|
+
- Include type/export compatibility tests where the package already has them.
|
|
42
|
+
- Run package test, lint, type, and Husky validation commands required by the changed area.
|
|
43
|
+
|
|
44
|
+
## Safety Constraints
|
|
45
|
+
|
|
46
|
+
- Do not edit generated output, dependency folders, logs, coverage, dist, or build artifacts unless the task explicitly requires it.
|
|
47
|
+
- Do not revert or overwrite user changes; stage only files related to the requested skill or instruction update.
|
|
48
|
+
- Never suppress errors, lint failures, type failures, security failures, or failing tests; fix the underlying issue or report the blocker.
|
|
49
|
+
- Do not log or expose secrets, JWTs, passwords, credentials, private keys, sensitive personal data, SQL internals, or stack traces.
|
|
50
|
+
|
|
51
|
+
## Workspace Model
|
|
52
|
+
|
|
53
|
+
Treat `/Users/pankajpriscilla/SO_CareCardCa` as a collection of independent Git
|
|
54
|
+
repositories, not as one monorepo. Work from the specific child repository
|
|
55
|
+
being changed. Each `api-*`, `pkg-*`, and `app-*` directory has its own package
|
|
56
|
+
scripts, Git status, test commands, style, naming, structure, test framework,
|
|
57
|
+
and Husky hooks.
|
|
58
|
+
|
|
59
|
+
## Agent Configuration
|
|
60
|
+
|
|
61
|
+
Keep agent runtime configuration in `.agents/config.toml`:
|
|
62
|
+
|
|
63
|
+
- `approval_policy = "never"`
|
|
64
|
+
- `sandbox_mode = "danger-full-access"`
|
|
65
|
+
|
|
66
|
+
Follow the current session permissions when they differ from repository-stored
|
|
67
|
+
config.
|
|
68
|
+
|
|
69
|
+
## Non-Negotiable Rules
|
|
70
|
+
|
|
71
|
+
- Never use TypeScript type `any`; use specific domain types, generics,
|
|
72
|
+
existing project types, or `unknown` with proper narrowing.
|
|
73
|
+
- Follow the owner's coding style, naming conventions, and project structure.
|
|
74
|
+
- Put code, tests, docs, services, validation, transforms, components, and
|
|
75
|
+
helpers where the current repository expects them.
|
|
76
|
+
- Use Test-Driven Development for behavior changes: write or update focused
|
|
77
|
+
tests first, verify they fail for the missing behavior when practical, then
|
|
78
|
+
implement.
|
|
79
|
+
- Never suppress errors, TypeScript errors, linter warnings, authorization
|
|
80
|
+
failures, RLS failures, build failures, hydration issues, or failing tests.
|
|
81
|
+
Do not add `eslint-disable`, `@ts-ignore`, broad catches, empty catches, or
|
|
82
|
+
similar suppression unless explicitly requested.
|
|
83
|
+
- Do not add dependencies unless clearly necessary. If one might be needed, ask
|
|
84
|
+
first with the reason, tradeoff, and why existing code cannot solve it.
|
|
85
|
+
- Before finalizing repository work, run the affected repository's relevant
|
|
86
|
+
tests, lint/format checks, validation commands, and every direct script in
|
|
87
|
+
`.husky`. Fix failures and rerun. If blocked, report the exact command,
|
|
88
|
+
reason, and remaining risk.
|
|
89
|
+
|
|
90
|
+
## Coding Principles
|
|
91
|
+
|
|
92
|
+
- Prefer minimal dependencies and readable direct implementation over new
|
|
93
|
+
libraries, frameworks, clever abstractions, or broad rewrites.
|
|
94
|
+
- Explain architectural tradeoffs before major changes, especially changes to
|
|
95
|
+
shared packages, API contracts, security, persistence, authentication, or
|
|
96
|
+
frontend/backend boundaries.
|
|
97
|
+
- Preserve the existing file structure, module system, naming style, and test
|
|
98
|
+
framework.
|
|
99
|
+
- Keep changes scoped and easy to review. Avoid unrelated formatting churn,
|
|
100
|
+
opportunistic refactors, and edits in generated or heavy-output directories
|
|
101
|
+
such as `node_modules`, `dist`, `coverage`, `.next`, `logs`, and generated
|
|
102
|
+
stores.
|
|
103
|
+
- Always ignore `.DS_Store`; do not stage or commit it.
|
|
104
|
+
- Use meaningful names that expose intent and domain behavior.
|
|
105
|
+
- Prefer PostgreSQL functions, stored procedures, database search, fuzzy search,
|
|
106
|
+
trigram search, full-text search, vector search, and database-side
|
|
107
|
+
persistence/access behavior when that matches the service design.
|
|
108
|
+
- Push data saving, editing, search, access, and aggregation complexity into the
|
|
109
|
+
database when it is the safer source of truth.
|
|
110
|
+
- Avoid controller-side or one-off raw SQL implementations when a PostgreSQL
|
|
111
|
+
function, stored procedure, or established database search primitive is the
|
|
112
|
+
clearer source of truth.
|
|
113
|
+
|
|
114
|
+
## Repository Workflow
|
|
115
|
+
|
|
116
|
+
1. Change into the affected child repository.
|
|
117
|
+
2. Run `git status --short` there before editing.
|
|
118
|
+
3. Preserve user changes. Do not revert or overwrite changes you did not make.
|
|
119
|
+
4. Read local repository guidance from `.agents/skills` before editing.
|
|
120
|
+
5. If a repository contains `.junie` guidance or validation scripts, read
|
|
121
|
+
applicable guidance and run every executable or directly documented
|
|
122
|
+
validation command before finishing.
|
|
123
|
+
6. Audit and update the documentation and skill after every change in the code.
|
|
124
|
+
Keep the relevant `.agents` skill and documentation in the same change so
|
|
125
|
+
repository guidance stays current.
|
|
126
|
+
7. Run targeted tests first, then broader repository checks.
|
|
127
|
+
8. Run every direct `.husky` script before finishing. Do not bypass hooks.
|
|
128
|
+
|
|
129
|
+
## Remote Git Operations Guardrail
|
|
130
|
+
|
|
131
|
+
Do not run remote Git or GitHub operations unless the current user request explicitly asks for that remote operation. This includes `git fetch`, `git pull`, `git push`, `git push --delete`, remote branch cleanup, GitHub API calls, and any `gh pr` command that creates, updates, readies, merges, closes, or cleans up a pull request. Do not infer permission from branch names, validation needs, prior workflow habits, or convenience; ask first when remote state would be useful but was not requested.
|
|
132
|
+
|
|
133
|
+
## Commit Continuation Rule
|
|
134
|
+
|
|
135
|
+
Do not amend existing commits unless the user explicitly asks for an amend. If
|
|
136
|
+
hooks, formatters, tests, docs, skills, validation, or review follow-up create
|
|
137
|
+
additional changes after a commit already exists, keep history additive by
|
|
138
|
+
making a new commit in the affected repository.
|
|
139
|
+
|
|
140
|
+
## Agent Guidance Git Workflow
|
|
141
|
+
|
|
142
|
+
When this skill or any repository-owned `.agents` guidance changes, use the
|
|
143
|
+
repository's agents-only Git workflow:
|
|
144
|
+
|
|
145
|
+
1. Work from the affected repository root and confirm only intended `.agents`
|
|
146
|
+
files changed.
|
|
147
|
+
2. Use `development` as the base branch when `origin/development` exists;
|
|
148
|
+
otherwise use the repository's default base branch, usually `main`.
|
|
149
|
+
3. Create or update `feature/codex` from the updated remote base branch and
|
|
150
|
+
commit all the changed `.agents` guidance files there.
|
|
151
|
+
4. Push `feature/codex`, create or reuse a pull request into the base branch,
|
|
152
|
+
and mark the pull request ready for review with `gh pr ready <number>`.
|
|
153
|
+
5. Squash-merge with administrator privileges and delete the remote branch:
|
|
154
|
+
|
|
155
|
+
```sh
|
|
156
|
+
gh pr merge <number> --squash --admin --delete-branch
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
6. After merge, update the local base branch and remove the local feature
|
|
160
|
+
branch:
|
|
161
|
+
|
|
162
|
+
```sh
|
|
163
|
+
git fetch origin <base> --prune
|
|
164
|
+
git switch <base>
|
|
165
|
+
git pull --ff-only origin <base>
|
|
166
|
+
git branch -d feature/codex
|
|
167
|
+
git ls-remote --heads origin feature/codex
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Do not commit or push `.agents` guidance changes directly from `development`
|
|
171
|
+
or `main`. Do not stage unrelated files, generated output, dependency folders,
|
|
172
|
+
build artifacts, logs, or `.DS_Store`.
|
|
173
|
+
|
|
174
|
+
## Shared Packages And API Contracts
|
|
175
|
+
|
|
176
|
+
- Prefer `@carecard/common-util`, `@carecard/auth-util`, `@carecard/jwt-read`,
|
|
177
|
+
and `@carecard/validate` over duplicated local implementations.
|
|
178
|
+
- The source code for `@carecard/*` packages lives in sibling `pkg-*`
|
|
179
|
+
repositories such as `pkg-common-util`, `pkg-auth-util`, `pkg-jwt-read`, and
|
|
180
|
+
`pkg-validate`.
|
|
181
|
+
- For API responses and errors, use standardized `@carecard/common-util`
|
|
182
|
+
behavior where possible: `requestContext`, `sendResponse`, `createError`,
|
|
183
|
+
`notFound404`, `appErrorHandler`, error throw helpers, case converters, and
|
|
184
|
+
`ApiErrorType`.
|
|
185
|
+
- Do not create or maintain duplicated common response or error helpers inside
|
|
186
|
+
each `api-*` service.
|
|
187
|
+
- Keep service-local response code limited to service-specific mapping or
|
|
188
|
+
wiring.
|
|
189
|
+
- Add broadly useful shared functionality to the relevant `pkg-*` package
|
|
190
|
+
instead of duplicating it locally in an `api-*` or `app-*` project.
|
|
191
|
+
- When changing a `pkg-*` package, write package tests first, increase that
|
|
192
|
+
package's minor version in `package.json`, run `npm install` in the package,
|
|
193
|
+
update consuming projects to the new package version, run `npm install` in
|
|
194
|
+
each consumer, and validate all affected projects.
|
|
195
|
+
- Preserve the dashboard-facing API response shape: `success`, `status`,
|
|
196
|
+
`statusCode`, `code`, `message`, `data`, `error`, `details`, and `meta`.
|
|
197
|
+
- Include request or correlation context where available through `requestId`,
|
|
198
|
+
`traceId`, and `meta`.
|
|
199
|
+
- Error responses must be safe for users and useful for debugging without
|
|
200
|
+
exposing secrets, tokens, credentials, stack traces, or sensitive personal
|
|
201
|
+
data.
|
|
202
|
+
- Map validation, authentication, authorization, not-found, conflict, bad
|
|
203
|
+
input, file, and unexpected failures to distinct machine-readable codes.
|
|
204
|
+
- Prefer current direct exports from shared packages over deprecated nested
|
|
205
|
+
exports.
|
|
206
|
+
|
|
207
|
+
## Backend Microservices
|
|
208
|
+
|
|
209
|
+
Most JavaScript `api-*` services use CommonJS, Mocha, Supertest, Docker Compose
|
|
210
|
+
database tests, `@carecard/*` packages, and `sub-apps`
|
|
211
|
+
controller/router/model patterns. TypeScript services such as `api-contact-us`
|
|
212
|
+
and `api-template-ts` use Jest or TypeScript tooling and should keep their
|
|
213
|
+
existing TypeScript style.
|
|
214
|
+
|
|
215
|
+
- Keep environment-specific files explicit: `.env.development`, `.env.test`,
|
|
216
|
+
and `.env.production`. Docker Compose database services must use the matching
|
|
217
|
+
env file for their environment, and containerized application services should
|
|
218
|
+
use `.env.production` unless a compose file intentionally defines a separate
|
|
219
|
+
development app service.
|
|
220
|
+
- Keep Docker Compose service keys, explicit `container_name` values, host ports,
|
|
221
|
+
and service URLs unique and descriptive across the workspace. When a Docker
|
|
222
|
+
name or port changes, update the matching env files, scripts, README docs, and
|
|
223
|
+
repo-local skills in the same change.
|
|
224
|
+
|
|
225
|
+
- Keep controllers thin: parse input, authorize, validate, call domain/model
|
|
226
|
+
logic, build a response, and pass errors to `next`.
|
|
227
|
+
- Extract multiline workflow, validation, mapping, response, authorization,
|
|
228
|
+
parsing, and domain helpers into the existing `controllerLib`, `commonLib`,
|
|
229
|
+
`sub-apps/lib`, model helper, or shared `pkg-*` package location.
|
|
230
|
+
- Avoid defining reusable workflow, validation, mapping, response,
|
|
231
|
+
authorization, parsing, or domain helpers in the same controller or app file
|
|
232
|
+
where they are immediately used.
|
|
233
|
+
- Prefer straightforward named helper calls over deeply nested conditionals.
|
|
234
|
+
- Preserve current behavior unless fixing a clear bug, security issue, or
|
|
235
|
+
documented contract problem.
|
|
236
|
+
- Keep `app.js`, `app.ts`, `bin/www`, and routers focused on composition and
|
|
237
|
+
wiring.
|
|
238
|
+
- Preserve existing middleware patterns: request context, CORS, Helmet, cookie
|
|
239
|
+
parsing, body-size limits, rate limits, routers, 404 handling, logging
|
|
240
|
+
middleware, and centralized error handlers.
|
|
241
|
+
- Use structured, actionable logging for important application events, external
|
|
242
|
+
calls, state transitions, failures, and security-relevant actions.
|
|
243
|
+
- Do not log secrets, tokens, passwords, credentials, personal identifiers,
|
|
244
|
+
full request payloads, or stack traces in user-facing responses.
|
|
245
|
+
- Keep logs useful for production monitoring. Avoid noisy logs that fire on
|
|
246
|
+
every trivial branch unless they are request or access logs already
|
|
247
|
+
established by the service.
|
|
248
|
+
|
|
249
|
+
## Validation Rules
|
|
250
|
+
|
|
251
|
+
- Keep request-boundary validation close to the API/controller layer.
|
|
252
|
+
- Use `validateWhitelistProperties()` once per validation boundary unless there
|
|
253
|
+
is a specific documented reason to validate defensively again.
|
|
254
|
+
- Avoid hidden duplicate validation across controller and library layers for
|
|
255
|
+
the same logical payload.
|
|
256
|
+
- Keep domain/library functions focused on domain behavior and assume validated
|
|
257
|
+
inputs when called from validated controller paths.
|
|
258
|
+
- If a public/shared library function still needs defensive validation,
|
|
259
|
+
document why and avoid repeating the exact same validation already done by the
|
|
260
|
+
caller.
|
|
261
|
+
- Preserve validation behavior for invalid, missing, extra, and valid fields.
|
|
262
|
+
- Pay attention to nested fields, dot-notation paths, camelCase/snake_case
|
|
263
|
+
conversion, and frontend response transforms.
|
|
264
|
+
|
|
265
|
+
## Database Migrations And Rollbacks
|
|
266
|
+
|
|
267
|
+
- Keep migration files in sync with rollback files.
|
|
268
|
+
- For every migration file, maintain exactly one matching rollback file with the
|
|
269
|
+
same numeric or version suffix.
|
|
270
|
+
- Migration files run in ascending filename order; rollback files run in
|
|
271
|
+
descending filename order.
|
|
272
|
+
- Migration and rollback SQL must both be idempotent.
|
|
273
|
+
- When changing a migration, update the matching rollback in the same commit
|
|
274
|
+
and add or update migration-pairing checks when available.
|
|
275
|
+
|
|
276
|
+
## Tests
|
|
277
|
+
|
|
278
|
+
- Testing is mandatory before finalizing code changes.
|
|
279
|
+
- Code coverage percentage must not decrease from the previous commit; it can
|
|
280
|
+
stay the same or increase. When coverage tooling exists, compare against the
|
|
281
|
+
previous commit or recorded baseline, add tests to maintain or improve
|
|
282
|
+
coverage, and never reduce coverage thresholds to pass checks.
|
|
283
|
+
- Keep tests readable and domain-specific.
|
|
284
|
+
- Tests must cover desired or happy paths and prevention or rejection of
|
|
285
|
+
undesired behavior.
|
|
286
|
+
- JavaScript `api-*` services usually use Mocha, Supertest,
|
|
287
|
+
`test/index.test.js`, and Docker-backed PostgreSQL scripts.
|
|
288
|
+
- TypeScript `api-*` services usually use Jest and `tests/index.test.ts`.
|
|
289
|
+
- `pkg-*` packages usually use Mocha plus TypeScript type tests where present.
|
|
290
|
+
- `app-dashboard` uses Vitest, React Testing Library, mock API tests, and
|
|
291
|
+
Selenium for end-to-end flows.
|
|
292
|
+
- For database tests, use existing seed, migration, rollback, and cleanup
|
|
293
|
+
patterns.
|
|
294
|
+
- In database `rls_logic.test.js` files, assert RLS logic only by calling
|
|
295
|
+
`carecard.can_access_row(...)` and checking the intended boolean. Put table
|
|
296
|
+
CRUD and lower RLS helper checks in query/enforcement tests.
|
|
297
|
+
- Add tests for API success responses, validation errors, auth/authz errors,
|
|
298
|
+
JWT errors, not-found/conflict cases, and unexpected error handling when
|
|
299
|
+
those paths change.
|
|
300
|
+
- For frontend changes, test validation, transforms, query/mutation wrappers,
|
|
301
|
+
components, and user-visible flows at the narrowest practical level first.
|
|
302
|
+
- If a test or repository check fails, fix the issue and rerun the failing
|
|
303
|
+
command. Only finalize with failing checks when the failure is unrelated or
|
|
304
|
+
blocked by environment constraints, and document that explicitly.
|
|
305
|
+
|
|
306
|
+
## Dashboard Frontend
|
|
307
|
+
|
|
308
|
+
`app-dashboard` is a Next.js App Router TypeScript app using MUI, React Query,
|
|
309
|
+
`next-intl`, and shared CareCard utilities. It consumes `api-auth`,
|
|
310
|
+
`api-institutions`, `api-contact-us`, and `api-user-profiles` through service
|
|
311
|
+
modules.
|
|
312
|
+
|
|
313
|
+
- Keep backend URL definitions centralized in `src/services/api.routes.ts`.
|
|
314
|
+
- Keep fetch behavior centralized in `src/services/common/api`, especially
|
|
315
|
+
`appFetch`, `api.client`, and `parseApiResponse`.
|
|
316
|
+
- Services should return typed app/domain objects or typed form states, not raw
|
|
317
|
+
fetch responses.
|
|
318
|
+
- Keep validation in `*.validation.ts`, API calls in `*.queries.ts` or mutation
|
|
319
|
+
helpers, mapping in `*.transform.ts`, and orchestration in `*.service.ts`.
|
|
320
|
+
- Preserve standardized `ApiResponse` parsing for current backend responses and
|
|
321
|
+
legacy/non-standard responses.
|
|
322
|
+
- Do not expose JWTs, session contents, or sensitive backend details in client
|
|
323
|
+
components or logs.
|
|
324
|
+
- Respect `basePath: '/secure'`, server actions, middleware session renewal,
|
|
325
|
+
mock API mode, and existing i18n message patterns.
|
|
326
|
+
- Use existing MUI and app component patterns. Do not introduce a new UI
|
|
327
|
+
framework.
|
|
328
|
+
|
|
329
|
+
Dashboard service and test conventions:
|
|
330
|
+
|
|
331
|
+
- When reconciling dashboard profile address and phone-number behavior,
|
|
332
|
+
preserve current development behavior unless the task explicitly changes it.
|
|
333
|
+
- Service/API snackbar behavior is centralized in
|
|
334
|
+
`src/hooks/useServiceSnackbar.hooks.ts`.
|
|
335
|
+
- Query error snackbars delegate shared message normalization through
|
|
336
|
+
`src/hooks/useErrorSnackbar.hooks.ts`.
|
|
337
|
+
- Profile, settings, notifications, institutions, and user authorization UI
|
|
338
|
+
prefer service snackbar helpers for user-friendly fallback errors, technical
|
|
339
|
+
error filtering, mutation result handling, and duplicate error suppression.
|
|
340
|
+
- `tests/app/dashboard/profile/page.test.tsx` keeps dynamic profile children
|
|
341
|
+
inert in the shell-level page test to avoid async imports resolving after
|
|
342
|
+
Vitest tears down jsdom in CI.
|
|
343
|
+
|
|
344
|
+
## Public Website Frontends
|
|
345
|
+
|
|
346
|
+
The `app-website-*` repositories are public Next.js App Router websites, not
|
|
347
|
+
the authenticated dashboard.
|
|
348
|
+
|
|
349
|
+
- Keep route files in `src/app` thin and compose sections from
|
|
350
|
+
`src/components`.
|
|
351
|
+
- Preserve `next.config.ts` settings such as `output: 'standalone'`,
|
|
352
|
+
`reactCompiler: true`, and `next-intl` plugin usage when present.
|
|
353
|
+
- Use existing MUI theme, customizations, navigation, providers, app config,
|
|
354
|
+
offline handling, site layout, and cookie banner patterns.
|
|
355
|
+
- Keep localized copy in the supported `messages` locales for the repository.
|
|
356
|
+
- Keep API helpers in `src/lib/api`, route builders in `src/lib/routes.ts`, and
|
|
357
|
+
proxy/session helpers in the existing `src/proxy.ts`, `src/lib/proxy`, or
|
|
358
|
+
`src/lib/utils` locations used by the repo.
|
|
359
|
+
- Use actual brand, product, partner, or service assets from `public` when
|
|
360
|
+
pages need visuals.
|
|
361
|
+
- Keep first viewport content clear about the brand or offer and preserve
|
|
362
|
+
responsive, accessible layouts.
|
|
363
|
+
|
|
364
|
+
## Dependency And Version Guidance
|
|
365
|
+
|
|
366
|
+
- Keep CareCard package usage consistent with the service or app being changed.
|
|
367
|
+
- When standardizing response or error behavior, prefer `@carecard/common-util`
|
|
368
|
+
`3.1.15` because it contains response and error functions aligned with
|
|
369
|
+
`api-auth`.
|
|
370
|
+
- If package version changes are required, update lockfiles and verify affected
|
|
371
|
+
services or apps.
|
|
372
|
+
- Avoid broad dependency upgrades as part of feature or refactor work unless
|
|
373
|
+
the task is specifically about dependencies.
|
|
374
|
+
|
|
375
|
+
## Security Requirements
|
|
376
|
+
|
|
377
|
+
- Treat authentication, authorization, JWT, password, email confirmation,
|
|
378
|
+
recovery, file upload, CORS, rate limits, and error response behavior as
|
|
379
|
+
security-sensitive.
|
|
380
|
+
- Never log or return secrets, tokens, passwords, credentials, private keys,
|
|
381
|
+
full JWT payloads, stack traces, raw request payloads, backend internals, or
|
|
382
|
+
sensitive personal data.
|
|
383
|
+
- Use safe user messages and structured details only when they do not reveal
|
|
384
|
+
sensitive implementation or data.
|
|
385
|
+
- Keep body-size limits, Helmet, CORS allow-lists, and rate-limit behavior
|
|
386
|
+
intact unless a task explicitly changes them.
|
|
387
|
+
- Document remaining security concerns that require product, infrastructure, or
|
|
388
|
+
deployment decisions.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: 'CareCard Workspace Standards'
|
|
3
|
+
short_description: 'Use before modifying, testing, reviewing, or debugging any CareCard workspace repository or cross-repository contract'
|
|
4
|
+
default_prompt: 'Use $carecard-workspace-standards when this task matches the skill scope.'
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: github-pr-create-update
|
|
3
|
+
description: Use only when the user explicitly asks for remote Git or GitHub PR work: pushing a branch, creating or updating a PR, or marking a PR ready from the current repository branch.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Pull Request Create
|
|
7
|
+
|
|
8
|
+
## Purpose
|
|
9
|
+
|
|
10
|
+
Only after the user explicitly asks for remote Git or GitHub PR work, create, update, verify, push, and mark ready a GitHub pull request from the current repository branch into origin/development.
|
|
11
|
+
|
|
12
|
+
## When To Use
|
|
13
|
+
|
|
14
|
+
- Use only when the user explicitly asks to create, update, push for, or mark ready a GitHub pull request from the current repository branch.
|
|
15
|
+
|
|
16
|
+
## When Not To Use
|
|
17
|
+
|
|
18
|
+
- Do not use for merging or deleting an already-approved pull request; use the merge cleanup skill.
|
|
19
|
+
- Do not use for ordinary local commits that do not involve GitHub PR work.
|
|
20
|
+
|
|
21
|
+
## Remote Git Operations Guardrail
|
|
22
|
+
|
|
23
|
+
Do not run remote Git or GitHub operations unless the current user request explicitly asks for that remote operation. This includes `git fetch`, `git pull`, `git push`, `git push --delete`, remote branch cleanup, GitHub API calls, and any `gh pr` command that creates, updates, readies, merges, closes, or cleans up a pull request. Do not infer permission from branch names, validation needs, prior workflow habits, or convenience; ask first when remote state would be useful but was not requested.
|
|
24
|
+
|
|
25
|
+
## Relevant Files And Directories
|
|
26
|
+
|
|
27
|
+
- Git branch state in this repository
|
|
28
|
+
- GitHub pull requests viewed with `gh`
|
|
29
|
+
- repository validation commands and `.husky` scripts
|
|
30
|
+
|
|
31
|
+
## Coding Principles
|
|
32
|
+
|
|
33
|
+
- Preserve the repository structure, naming style, module system, and local helper patterns.
|
|
34
|
+
- Prefer readable, maintainable code with meaningful function, variable, file, and test names.
|
|
35
|
+
- Avoid new dependencies unless the existing stack cannot reasonably solve the task and the user confirms the tradeoff.
|
|
36
|
+
|
|
37
|
+
## Testing Expectations
|
|
38
|
+
|
|
39
|
+
- Run repository validation before PR creation or merge when code behavior changed.
|
|
40
|
+
- Confirm the branch is clean except intended changes before finishing.
|
|
41
|
+
|
|
42
|
+
## Safety Constraints
|
|
43
|
+
|
|
44
|
+
- Do not edit generated output, dependency folders, logs, coverage, dist, or build artifacts unless the task explicitly requires it.
|
|
45
|
+
- Do not revert or overwrite user changes; stage only files related to the requested skill or instruction update.
|
|
46
|
+
- Never suppress errors, lint failures, type failures, security failures, or failing tests; fix the underlying issue or report the blocker.
|
|
47
|
+
|
|
48
|
+
## Commit Continuation Rule
|
|
49
|
+
|
|
50
|
+
Do not amend existing commits unless the user explicitly asks for an amend. If
|
|
51
|
+
hook, formatter, documentation, skill, validation, or review follow-up changes
|
|
52
|
+
appear after a commit, stage only the intended files and make a new commit with
|
|
53
|
+
a clear message.
|
|
54
|
+
|
|
55
|
+
## Scope
|
|
56
|
+
|
|
57
|
+
Use this skill from the root of the repository whose current branch contains
|
|
58
|
+
the intended PR changes. The repository must have `origin/development`, and
|
|
59
|
+
GitHub CLI must be available and authenticated.
|
|
60
|
+
|
|
61
|
+
Do not continue automatically when:
|
|
62
|
+
|
|
63
|
+
- The current branch is `development`, `main`, `master`, or detached.
|
|
64
|
+
- The working tree has uncommitted changes. Explain that a PR only includes
|
|
65
|
+
committed changes and ask the user whether to commit or stash them.
|
|
66
|
+
- `gh auth status` fails.
|
|
67
|
+
- `origin/development` cannot be fetched.
|
|
68
|
+
|
|
69
|
+
## Workflow
|
|
70
|
+
|
|
71
|
+
1. Capture the source branch and run preflight checks:
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
branch="$(git branch --show-current)"
|
|
75
|
+
test -n "$branch"
|
|
76
|
+
test "$branch" != "development"
|
|
77
|
+
test "$branch" != "main"
|
|
78
|
+
test "$branch" != "master"
|
|
79
|
+
git status --short
|
|
80
|
+
gh auth status
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
2. Pull a fresh development reference from the remote without leaving the
|
|
84
|
+
source branch:
|
|
85
|
+
|
|
86
|
+
```sh
|
|
87
|
+
git fetch origin development --prune
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Use `origin/development` as the source of truth. If a local `development`
|
|
91
|
+
branch exists and is not checked out, it may be fast-forwarded to match the
|
|
92
|
+
remote without forcing history:
|
|
93
|
+
|
|
94
|
+
```sh
|
|
95
|
+
git fetch origin development:development
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
If that local branch update fails because `development` has diverged or is
|
|
99
|
+
checked out in another worktree, do not force it. Continue using
|
|
100
|
+
`origin/development` for validation.
|
|
101
|
+
|
|
102
|
+
3. Check whether the current branch can merge with latest development without
|
|
103
|
+
changing the worktree:
|
|
104
|
+
|
|
105
|
+
```sh
|
|
106
|
+
if git merge-tree --write-tree HEAD origin/development >/tmp/pull-request-create-merge-tree.out
|
|
107
|
+
then
|
|
108
|
+
merge_conflict_detected=false
|
|
109
|
+
else
|
|
110
|
+
merge_conflict_detected=true
|
|
111
|
+
fi
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
4. If a merge conflict is detected, try rebasing on latest development:
|
|
115
|
+
|
|
116
|
+
```sh
|
|
117
|
+
if [ "$merge_conflict_detected" = true ]; then
|
|
118
|
+
if git rebase origin/development; then
|
|
119
|
+
git push --force-with-lease -u origin "$branch"
|
|
120
|
+
else
|
|
121
|
+
git rebase --abort
|
|
122
|
+
echo "Rebase conflicted; aborted without pushing."
|
|
123
|
+
exit 1
|
|
124
|
+
fi
|
|
125
|
+
else
|
|
126
|
+
git push -u origin "$branch"
|
|
127
|
+
fi
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Do not resolve rebase conflicts unless the user explicitly asks. If the
|
|
131
|
+
rebase fails, abort it and stop.
|
|
132
|
+
|
|
133
|
+
5. Inspect the branch changes before writing the PR title:
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
git log --reverse --format='%s' origin/development..HEAD
|
|
137
|
+
git diff --stat origin/development...HEAD
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Create a concise, descriptive title from the actual changes. Remove words
|
|
141
|
+
such as `draft`, `[draft]`, `Draft:`, and `WIP`. Do not leave a generic title
|
|
142
|
+
such as "updates", "changes", or "draft PR".
|
|
143
|
+
|
|
144
|
+
6. Reuse an existing open PR for this branch when present:
|
|
145
|
+
|
|
146
|
+
```sh
|
|
147
|
+
pr_number="$(gh pr list \
|
|
148
|
+
--head "$branch" \
|
|
149
|
+
--base development \
|
|
150
|
+
--state open \
|
|
151
|
+
--json number \
|
|
152
|
+
--jq '.[0].number // empty')"
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
7. If there is no PR, create one against `development` and capture the new PR
|
|
156
|
+
number:
|
|
157
|
+
|
|
158
|
+
```sh
|
|
159
|
+
pr_url="$(gh pr create \
|
|
160
|
+
--base development \
|
|
161
|
+
--head "$branch" \
|
|
162
|
+
--title "$title" \
|
|
163
|
+
--body "$body")"
|
|
164
|
+
pr_number="$(gh pr view "$pr_url" --json number --jq '.number')"
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Keep the body factual. Mention the main changes and validation commands
|
|
168
|
+
that were actually run.
|
|
169
|
+
|
|
170
|
+
8. If a PR exists, mark it ready when it is a draft:
|
|
171
|
+
|
|
172
|
+
```sh
|
|
173
|
+
is_draft="$(gh pr view "$pr_number" --json isDraft --jq '.isDraft')"
|
|
174
|
+
if [ "$is_draft" = "true" ]; then
|
|
175
|
+
gh pr ready "$pr_number"
|
|
176
|
+
fi
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
9. Update the PR title after create/reuse so it is descriptive and contains no
|
|
180
|
+
draft wording:
|
|
181
|
+
|
|
182
|
+
```sh
|
|
183
|
+
gh pr edit "$pr_number" --title "$title"
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
10. Final response should include the PR URL, whether a rebase was performed,
|
|
187
|
+
whether an existing PR was reused or marked ready, and any validation that
|
|
188
|
+
could not be run.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
interface:
|
|
2
|
+
display_name: 'GitHub PR Create Or Update'
|
|
3
|
+
short_description: 'Use only when the user explicitly asks for remote Git or GitHub PR work: push, create or update a PR, or mark it ready.'
|
|
4
|
+
brand_color: '#0F766E'
|
|
5
|
+
default_prompt: 'Use $github-pr-create-update when this task matches the skill scope.'
|