@activatus/code-standards 0.0.0-stage → 3.0.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.
- package/README.md +199 -2
- package/docs/Guides/_category_.json +4 -0
- package/docs/Guides/component-library-workflow.md +182 -0
- package/docs/Guides/migrating.md +161 -0
- package/docs/Guides/setup.md +158 -0
- package/docs/Standards/_category_.json +4 -0
- package/docs/Standards/agent-skills.md +125 -0
- package/docs/Standards/agent-specs.md +74 -0
- package/docs/Standards/direnv.mdx +249 -0
- package/docs/Standards/documentation.md +314 -0
- package/docs/Standards/editorconfig.md +74 -0
- package/docs/Standards/eslint.md +900 -0
- package/docs/Standards/human-readable-names.md +274 -0
- package/docs/Standards/lint-errors.md +171 -0
- package/docs/Standards/prettier.md +106 -0
- package/docs/Standards/readable-code.md +570 -0
- package/docs/Standards/stylelint.md +193 -0
- package/docs/Standards/styling.md +290 -0
- package/docs/Standards/tech-stack.md +158 -0
- package/docs/Structure/_category_.json +4 -0
- package/docs/Structure/api-routes.md +118 -0
- package/docs/Structure/component-organization.md +526 -0
- package/docs/Structure/folder-structure.md +366 -0
- package/docs/Structure/import-organization.md +158 -0
- package/docs/Structure/naming-conventions.md +334 -0
- package/docs/design-system-components.md +117 -0
- package/docs/intro.md +44 -0
- package/docs/ontology.md +127 -0
- package/docs/templates.mdx +396 -0
- package/docs/version-history.md +338 -0
- package/package.json +60 -3
- package/scripts/renameSymbol.mjs +188 -0
- package/static/templates/.editorconfig +25 -0
- package/static/templates/.envrc +25 -0
- package/static/templates/.nvmrc +1 -0
- package/static/templates/AGENTS.md +163 -0
- package/static/templates/decision-doc.md +19 -0
- package/static/templates/docs/ai/agent-harness.md +17 -0
- package/static/templates/docs/ai/agents.md +17 -0
- package/static/templates/docs/ai/architecture.md +17 -0
- package/static/templates/docs/ai/context.md +17 -0
- package/static/templates/docs/ai/model-routing.md +17 -0
- package/static/templates/docs/ai/models.md +17 -0
- package/static/templates/docs/ai/retrieval.md +17 -0
- package/static/templates/docs/ai/tools.md +17 -0
- package/static/templates/docs/architecture/authentication.md +17 -0
- package/static/templates/docs/architecture/backend.md +17 -0
- package/static/templates/docs/architecture/background-jobs.md +17 -0
- package/static/templates/docs/architecture/backups.md +17 -0
- package/static/templates/docs/architecture/caching.md +17 -0
- package/static/templates/docs/architecture/ci-cd.md +17 -0
- package/static/templates/docs/architecture/disaster-recovery.md +17 -0
- package/static/templates/docs/architecture/environments.md +17 -0
- package/static/templates/docs/architecture/frontend.md +17 -0
- package/static/templates/docs/architecture/hosting.md +17 -0
- package/static/templates/docs/architecture/observability.md +17 -0
- package/static/templates/docs/architecture/realtime.md +17 -0
- package/static/templates/docs/architecture/search.md +17 -0
- package/static/templates/docs/architecture/services.md +17 -0
- package/static/templates/docs/architecture/state-management.md +17 -0
- package/static/templates/docs/architecture/storage.md +17 -0
- package/static/templates/docs/architecture/system.md +17 -0
- package/static/templates/docs/business/buying-trigger.md +17 -0
- package/static/templates/docs/business/customer-value.md +17 -0
- package/static/templates/docs/business/customer.md +17 -0
- package/static/templates/docs/business/defensibility.md +17 -0
- package/static/templates/docs/business/growth.md +17 -0
- package/static/templates/docs/business/pricing.md +17 -0
- package/static/templates/docs/business/revenue-model.md +17 -0
- package/static/templates/docs/business/unit-economics.md +17 -0
- package/static/templates/docs/data/analytics.md +17 -0
- package/static/templates/docs/data/audit.md +17 -0
- package/static/templates/docs/data/database.md +17 -0
- package/static/templates/docs/data/indexing.md +17 -0
- package/static/templates/docs/data/migrations.md +17 -0
- package/static/templates/docs/data/model.md +17 -0
- package/static/templates/docs/data/retention.md +17 -0
- package/static/templates/docs/data/schema.md +17 -0
- package/static/templates/docs/deployment/approval.md +17 -0
- package/static/templates/docs/deployment/live-verification.md +17 -0
- package/static/templates/docs/deployment/process.md +17 -0
- package/static/templates/docs/deployment/rollback.md +17 -0
- package/static/templates/docs/design/design-system.md +17 -0
- package/static/templates/docs/design/errors.md +17 -0
- package/static/templates/docs/design/feedback.md +17 -0
- package/static/templates/docs/design/interactions.md +17 -0
- package/static/templates/docs/design/layout.md +17 -0
- package/static/templates/docs/design/navigation.md +17 -0
- package/static/templates/docs/design/principles.md +17 -0
- package/static/templates/docs/design/responsive.md +17 -0
- package/static/templates/docs/development/branching.md +17 -0
- package/static/templates/docs/development/code-quality.md +17 -0
- package/static/templates/docs/development/coding-standards.md +21 -0
- package/static/templates/docs/development/commits.md +17 -0
- package/static/templates/docs/development/merge-strategy.md +17 -0
- package/static/templates/docs/development/process.md +17 -0
- package/static/templates/docs/development/pull-requests.md +17 -0
- package/static/templates/docs/experience/accessibility.md +17 -0
- package/static/templates/docs/experience/aha-moment.md +17 -0
- package/static/templates/docs/experience/anti-experience.md +17 -0
- package/static/templates/docs/experience/friction.md +17 -0
- package/static/templates/docs/experience/outcomes.md +17 -0
- package/static/templates/docs/experience/principles.md +17 -0
- package/static/templates/docs/experience/retention.md +17 -0
- package/static/templates/docs/experience/sharing.md +17 -0
- package/static/templates/docs/overview/how-it-works.md +17 -0
- package/static/templates/docs/overview/what-is-it.md +17 -0
- package/static/templates/docs/overview/writing-docs.md +16 -0
- package/static/templates/docs/pitch/alternatives.md +17 -0
- package/static/templates/docs/pitch/assumptions.md +17 -0
- package/static/templates/docs/pitch/audience.md +17 -0
- package/static/templates/docs/pitch/concept.md +17 -0
- package/static/templates/docs/pitch/differentiators.md +17 -0
- package/static/templates/docs/pitch/outcomes.md +17 -0
- package/static/templates/docs/pitch/problem.md +17 -0
- package/static/templates/docs/pitch/product-market-fit.md +17 -0
- package/static/templates/docs/pitch/success-criteria.md +17 -0
- package/static/templates/docs/pitch/validation.md +17 -0
- package/static/templates/docs/pitch/value-proposition.md +17 -0
- package/static/templates/docs/pitch/vision.md +17 -0
- package/static/templates/docs/scope/core.md +17 -0
- package/static/templates/docs/scope/exclusions.md +17 -0
- package/static/templates/docs/scope/future.md +17 -0
- package/static/templates/docs/scope/launch.md +17 -0
- package/static/templates/docs/scope/post-launch.md +17 -0
- package/static/templates/docs/scope/priorities.md +17 -0
- package/static/templates/docs/scope/quality-bar.md +17 -0
- package/static/templates/docs/security/audit.md +17 -0
- package/static/templates/docs/security/data-access.md +17 -0
- package/static/templates/docs/security/logging.md +17 -0
- package/static/templates/docs/security/privacy.md +17 -0
- package/static/templates/docs/security/secrets.md +17 -0
- package/static/templates/docs/security/threat-model.md +17 -0
- package/static/templates/docs/testing/end-to-end.md +17 -0
- package/static/templates/docs/testing/integration.md +17 -0
- package/static/templates/docs/testing/regression.md +17 -0
- package/static/templates/docs/testing/security.md +17 -0
- package/static/templates/docs/testing/strategy.md +17 -0
- package/static/templates/docs/testing/test-data.md +17 -0
- package/static/templates/docs/testing/unit.md +17 -0
- package/static/templates/docs/uat/checks.md +17 -0
- package/static/templates/docs/uat/strategy.md +17 -0
- package/static/templates/docs/users/permissions.md +17 -0
- package/static/templates/docs/users/roles.md +17 -0
- package/static/templates/docs/users/user-types.md +17 -0
- package/static/templates/docs/workflows/assignment.md +17 -0
- package/static/templates/docs/workflows/bugfix.md +17 -0
- package/static/templates/docs/workflows/dependencies.md +17 -0
- package/static/templates/docs/workflows/deployment.md +17 -0
- package/static/templates/docs/workflows/development.md +17 -0
- package/static/templates/docs/workflows/planning.md +17 -0
- package/static/templates/docs/workflows/review.md +17 -0
- package/static/templates/docs/workflows/uat.md +17 -0
- package/static/templates/docsSite/docusaurus.config.mjs +144 -0
- package/static/templates/docsSite/gitignore.txt +3 -0
- package/static/templates/docsSite/package.json.txt +42 -0
- package/static/templates/docsSite/pnpm-workspace.yaml +2 -0
- package/static/templates/docsSite/sidebars.mjs +7 -0
- package/static/templates/docsSite/src/css/custom.css +7 -0
- package/static/templates/docsSite/src/pages/index.tsx +9 -0
- package/static/templates/docsSite/static/images/logo.svg +4 -0
- package/static/templates/docsSite/tsconfig.json +7 -0
- package/static/templates/eslint/base/eslint.config.mjs +104 -0
- package/static/templates/eslint/nextjs/eslint.config.mjs +181 -0
- package/static/templates/eslint/react/eslint.config.mjs +173 -0
- package/static/templates/eslint/typescript/eslint.config.mjs +154 -0
- package/static/templates/globals.css +16 -0
- package/static/templates/husky/pre-commit +1 -0
- package/static/templates/next.config.mjs +21 -0
- package/static/templates/prettier.config.mjs +26 -0
- package/static/templates/skills/codeReview.md +31 -0
- package/static/templates/skills/format.md +18 -0
- package/static/templates/skills/lint.md +21 -0
- package/static/templates/skills/lintFix.md +24 -0
- package/static/templates/skills/securityAudit.md +28 -0
- package/static/templates/skills/test.md +24 -0
- package/static/templates/skills/typescript.md +28 -0
- package/static/templates/skills/updateLayout.md +20 -0
- package/static/templates/stylelint/css/stylelint.config.mjs +40 -0
- package/static/templates/stylelint/scss/stylelint.config.mjs +13 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 2
|
|
3
|
+
sidebar_label: "Setup"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Setting Up a Project
|
|
7
|
+
|
|
8
|
+
> For the AI agent. A person has told you to follow the Activatus Code Standards in their project. This is everything you do, in order.
|
|
9
|
+
|
|
10
|
+
The person creates the app themselves — with `create-next-app`, Expo or anything else — and tells you to follow the standards. **Do not ask which framework the project uses.** Look at the project: its `package.json` and files tell you. The person only answers the questions below and checks your work. They never run a command.
|
|
11
|
+
|
|
12
|
+
**These standards are the base, for code only.** A project builds on top of them: it can add its own folders and conventions, and it makes its own project-management decisions (tickets, statuses, releases, who commits). Those go in the project's own docs, not here.
|
|
13
|
+
|
|
14
|
+
## 1. Install the standards
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add -D @activatus/code-standards
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
**If pnpm refuses because the version is too new**, that is pnpm's `minimumReleaseAge` setting: by default it will not install a version published less than a day ago. The standards come from us, so add the package to `minimumReleaseAgeExclude` in `pnpm-workspace.yaml`:
|
|
21
|
+
|
|
22
|
+
```yaml title="pnpm-workspace.yaml"
|
|
23
|
+
minimumReleaseAgeExclude:
|
|
24
|
+
- "@activatus/code-standards"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The standards are now in `node_modules/@activatus/code-standards/`:
|
|
28
|
+
|
|
29
|
+
| Folder | What it holds |
|
|
30
|
+
| ------------------------- | ------------------------------------------------------------------------------------------ |
|
|
31
|
+
| `docs/` | Every standard, as Markdown. The same pages as https://activatus-code-standards.vercel.app |
|
|
32
|
+
| `docs/version-history.md` | What changed in each version, and what a project has to do about it |
|
|
33
|
+
| `static/templates/` | The config files to copy: `AGENTS.md`, ESLint, Prettier, Stylelint and the rest |
|
|
34
|
+
|
|
35
|
+
**Read the standards from `node_modules`, not the website.** The installed package is the exact version the project uses. The package version is the standards version: `2.0.0` is version 2.
|
|
36
|
+
|
|
37
|
+
## 2. Work out where the project is
|
|
38
|
+
|
|
39
|
+
Open the project's `AGENTS.md` and look for `**Code standards version:**`.
|
|
40
|
+
|
|
41
|
+
| What you find | What it means | Go to |
|
|
42
|
+
| -------------------------------------------- | ------------------------------------ | ----------------------------------------------------------- |
|
|
43
|
+
| No `AGENTS.md`, or no code standards version | The standards have never been set up | [3. Agree the standards](#3-agree-the-standards) |
|
|
44
|
+
| A version lower than the installed package | The project follows an older version | [Updating to a newer version](#updating-to-a-newer-version) |
|
|
45
|
+
| The same version as the installed package | Already up to date | Nothing to do. Tell the person |
|
|
46
|
+
|
|
47
|
+
## 3. Agree the standards
|
|
48
|
+
|
|
49
|
+
**Print this list to the person exactly as it is written**, with the same numbers, so they can answer with numbers:
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
These are the Activatus Code Standards. Want anything different?
|
|
53
|
+
Tell me the numbers to skip or change, or say "all good".
|
|
54
|
+
|
|
55
|
+
1. Human-readable names: every name is whole words, using the Dictionary
|
|
56
|
+
2. Readable code: files under 300 lines, one job per function, one parameter, return early, no magic numbers
|
|
57
|
+
3. Arrow functions and const only, named exports, no classes
|
|
58
|
+
4. Every function and component has a test file
|
|
59
|
+
5. Strict TypeScript: no any, no !, no unexplained as; type names end in Props or Type
|
|
60
|
+
6. ESLint, with the standard config
|
|
61
|
+
7. Prettier, with the Tailwind class-sorting plugin
|
|
62
|
+
8. Stylelint, for any hand-written CSS
|
|
63
|
+
9. EditorConfig
|
|
64
|
+
10. Node version set by .nvmrc and direnv
|
|
65
|
+
11. Styling: Tailwind, flexbox first, colours only from the global palette
|
|
66
|
+
12. Folder structure: folders at the project root; reusable helper functions in utils/ (no business rules, no outside calls)
|
|
67
|
+
13. Components live where they are used: components/ui/, components/shared/, or beside their page
|
|
68
|
+
14. Component files in a fixed order, with index.ts exports, and server and client code in separate files
|
|
69
|
+
15. Design System Components: every project builds the standard components with the same props
|
|
70
|
+
16. Imports: no circular imports, import from folders not files
|
|
71
|
+
17. API routes: one folder per route, kebab-case
|
|
72
|
+
18. Docs: every file in docs/ is a Decision Doc, shown at /docs by the docs site
|
|
73
|
+
19. Lint before every commit: a Husky hook runs pnpm lint
|
|
74
|
+
20. AGENTS.md and the eight agent skills
|
|
75
|
+
21. The Ontology: the shared words for code
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Then wait for the answer.
|
|
79
|
+
|
|
80
|
+
| The person says | Do |
|
|
81
|
+
| --------------------------------------- | ----------------------------- |
|
|
82
|
+
| "All good" | Apply every standard |
|
|
83
|
+
| "Skip 7" | Apply every standard except 7 |
|
|
84
|
+
| "Change 7: we use Biome for formatting" | Apply 7 as they describe it |
|
|
85
|
+
| Something unclear | Ask. Do not guess |
|
|
86
|
+
|
|
87
|
+
**Record the answer** in `docs/development/coding-standards.md`, under "Details". For each skipped or changed standard, write its number, its name, what is different, and the reason the person gave. If nothing is different, write "No differences". Copy the file from `static/templates/docs/development/coding-standards.md` if it does not exist.
|
|
88
|
+
|
|
89
|
+
The list has nothing about branches, commit messages or whether agents may commit. Those are the project's own workflow. Ask the person how they work, and write it in the "Project workflow" section of `AGENTS.md`. See [Project workflow](/Standards/agent-specs#project-workflow).
|
|
90
|
+
|
|
91
|
+
## 4. Apply the standards
|
|
92
|
+
|
|
93
|
+
Do only the standards the person agreed to. Copy every file from `node_modules/@activatus/code-standards/static/templates/` — never write a config file from scratch.
|
|
94
|
+
|
|
95
|
+
**Every config file is `.mjs`, even in a TypeScript project.** Never convert one to `.ts` or `.mts`. `.mjs` works in both, so every project looks the same. If the project has a config as `.js`, `.ts` or `.mts`, such as `next.config.ts` from `create-next-app` or `vitest.config.mts`, rename it to `.mjs`, removing any TypeScript-only syntax: a type annotation becomes a JSDoc comment, for example `/** @type {import("next").NextConfig} */`. A tool that cannot read `.mjs` keeps its own format.
|
|
96
|
+
|
|
97
|
+
**An existing project with code already in it** also needs its code brought up to the standards. Do that with [Migrating an Existing Project](/Guides/migrating), one stage per pull request, after the config files below are in place.
|
|
98
|
+
|
|
99
|
+
| Standard | What to set up |
|
|
100
|
+
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
101
|
+
| 6. ESLint | Copy the config for the project's framework from `static/templates/eslint/`: `base`, `typescript`, `react` or `nextjs`. Install the packages listed on the [ESLint page](/Standards/eslint). Add the scripts `"lint": "eslint ."` and `"lint:fix": "eslint . --fix"` |
|
|
102
|
+
| 7. Prettier | `pnpm add -D prettier prettier-plugin-tailwindcss`. Copy `static/templates/prettier.config.mjs`. Add the scripts `"format": "prettier --write ."` and `"format:check": "prettier --check ."` |
|
|
103
|
+
| 8. Stylelint | Only if the project has hand-written CSS or SCSS. Copy the config from `static/templates/stylelint/css/` or `scss/`. See [Stylelint](/Standards/stylelint) |
|
|
104
|
+
| 9. EditorConfig | Copy `static/templates/.editorconfig` |
|
|
105
|
+
| 10. Node version | Copy `static/templates/.nvmrc` and `static/templates/.envrc`. See [direnv + nvm](/Standards/direnv) |
|
|
106
|
+
| 11. Styling | Copy `static/templates/globals.css` to `app/globals.css`. Ask the person for the project's colours, and replace the example palette |
|
|
107
|
+
| 18. Docs | Copy `static/templates/docs/` to `docs/` and `static/templates/docsSite/` to `docsSite/`. Add the `/docs` route from `static/templates/next.config.mjs`. See [Setting it up](/Standards/documentation#-setting-it-up) |
|
|
108
|
+
| 19. Lint before commit | Copy `static/templates/husky/pre-commit` to `.husky/pre-commit`, once `pnpm lint` passes. See [Lint before every commit](/Standards/lint-errors#lint-before-every-commit) |
|
|
109
|
+
| 20. AGENTS.md and skills | Copy `static/templates/AGENTS.md` to the project root and fill in every `[placeholder]`. If the framework wrote its own `AGENTS.md` (Next.js does), keep any instruction it gives about reading the framework's own docs. Copy `static/templates/skills/` into `.agents/skills/`, and again into `.claude/commands/` |
|
|
110
|
+
|
|
111
|
+
The other standards are rules for how code is written. There is nothing to install for them: follow them in every change.
|
|
112
|
+
|
|
113
|
+
**Finish by:**
|
|
114
|
+
|
|
115
|
+
1. Setting `**Code standards version:**` in `AGENTS.md` to the installed package's major version. See [Finishing a change later](#finishing-a-change-later) if anything is left to do.
|
|
116
|
+
2. Running `pnpm lint`, `pnpm format:check` and the tests.
|
|
117
|
+
3. Telling the person what you set up, which standards they skipped, and anything only they can do, such as filling in a secret in `.env.local`.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Updating to a newer version
|
|
122
|
+
|
|
123
|
+
The project already follows the standards, and a newer version is out.
|
|
124
|
+
|
|
125
|
+
1. **Note the project's version.** Read `**Code standards version:**` in `AGENTS.md`. This is the version the code follows.
|
|
126
|
+
2. **Update the package:**
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
pnpm update @activatus/code-standards --latest
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Its major version is now the newest version.
|
|
133
|
+
|
|
134
|
+
3. **Read `node_modules/@activatus/code-standards/docs/version-history.md`**, but only the versions newer than the project's. Do not re-read the rest of the standards.
|
|
135
|
+
4. **Skip any change to a standard the project opted out of.** The opt-outs are listed in `docs/development/coding-standards.md`.
|
|
136
|
+
5. **Do every other change** as its "What to do" says, and run its "How to check" search. One pull request per kind of change.
|
|
137
|
+
6. **Set `**Code standards version:**`** in `AGENTS.md` to the new version, and tell the person what changed. If a change is being finished later, record it first: see [Finishing a change later](#finishing-a-change-later).
|
|
138
|
+
|
|
139
|
+
See the [Version History](/version-history) for the full update rules.
|
|
140
|
+
|
|
141
|
+
---
|
|
142
|
+
|
|
143
|
+
## Finishing a change later
|
|
144
|
+
|
|
145
|
+
Sometimes a change is too big for the update, such as switching on the standard ESLint config in a project that never had it. It can be done later in its own Pull Request, but **the version number must stay honest**.
|
|
146
|
+
|
|
147
|
+
1. Set the project's version to the new version anyway.
|
|
148
|
+
2. In `docs/development/coding-standards.md`, under **Unfinished changes**, list each change that is not done yet: its version and number, what is left, and where it is being done (a ticket or a Pull Request).
|
|
149
|
+
|
|
150
|
+
```md
|
|
151
|
+
## Unfinished changes
|
|
152
|
+
|
|
153
|
+
- Version 2, change 4: the standard ESLint config is not switched on yet. Being done in ACT-120.
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
3. When it is finished, remove it from the list.
|
|
157
|
+
|
|
158
|
+
An agent updating to a later version reads this list first, and finishes or skips those changes before starting the new ones.
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 8
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Agent Skills
|
|
6
|
+
|
|
7
|
+
A skill is a reusable instruction file an agent runs when you type `/lint`, `/format`, `/codeReview`. Every Activatus repository provides the same [standard set](/Standards/agent-specs#standard-skills), copied from the [Templates page](/templates#skills). This page is the standard they are written to.
|
|
8
|
+
|
|
9
|
+
Skills are shared, versioned, and executed with real tool access. A vague one wastes a run; a wrong one edits files it was never meant to touch. They get the same review as any other code.
|
|
10
|
+
|
|
11
|
+
## Where skills live
|
|
12
|
+
|
|
13
|
+
One canonical copy, one mirror:
|
|
14
|
+
|
|
15
|
+
| Path | Role |
|
|
16
|
+
| ----------------------- | ------------------------------------------------------------------------------------ |
|
|
17
|
+
| `.agents/skills/*.md` | **Canonical.** Portable location any compatible agent reads. The only copy you edit. |
|
|
18
|
+
| `.claude/commands/*.md` | Claude Code mirror, exposed as `/name`. |
|
|
19
|
+
|
|
20
|
+
Keep the mirror identical to the canonical copy — edit the skill in `.agents/skills/`, then copy it across.
|
|
21
|
+
|
|
22
|
+
:::note[Why two locations rather than one format]
|
|
23
|
+
|
|
24
|
+
`.claude/commands/` is Claude Code's older flat-file layout; its newer equivalent is a directory per skill (`.claude/skills/<name>/SKILL.md`). Activatus stays on flat files because the same file has to serve `.agents/skills/` for non-Claude agents, and a flat `.md` is the only shape both read. Revisit this if bundled resources (`scripts/`, `references/`) are ever needed — that is what the directory format buys.
|
|
25
|
+
|
|
26
|
+
:::
|
|
27
|
+
|
|
28
|
+
## Frontmatter
|
|
29
|
+
|
|
30
|
+
Every skill starts with YAML frontmatter. Without it the agent falls back to guessing from the first line of the body.
|
|
31
|
+
|
|
32
|
+
```markdown
|
|
33
|
+
---
|
|
34
|
+
name: lint
|
|
35
|
+
description: Run all linters in check-only mode and report issues
|
|
36
|
+
argument-hint: "[path]"
|
|
37
|
+
allowed-tools: Read, Glob, Grep, Bash(pnpm lint:*), Bash(eslint:*)
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
Run all configured linters and report issues without modifying any files.
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| Field | Required | Purpose |
|
|
44
|
+
| -------------------------- | --------------------- | ------------------------------------------------------------------ |
|
|
45
|
+
| `name` | Yes | The invocation name, in camelCase. Must match the filename. |
|
|
46
|
+
| `description` | Yes | One line, **under 60 characters**. How an agent decides to use it. |
|
|
47
|
+
| `argument-hint` | If it takes arguments | Shown during autocomplete. |
|
|
48
|
+
| `allowed-tools` | Strongly encouraged | The tools the skill may use. See below. |
|
|
49
|
+
| `model` | No | Pin only for genuinely mechanical skills. |
|
|
50
|
+
| `disable-model-invocation` | No | Set when a skill must only ever be run by a human. |
|
|
51
|
+
|
|
52
|
+
Quote any `argument-hint` that starts with `[`, or YAML parses it as a list:
|
|
53
|
+
|
|
54
|
+
```yaml
|
|
55
|
+
argument-hint: "[path]" # string
|
|
56
|
+
argument-hint: [path] # a one-element array — wrong
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## `allowed-tools` is the contract
|
|
60
|
+
|
|
61
|
+
Prose like "this skill is read-only" is a request. `allowed-tools` is the enforcement. Whatever a skill's body promises not to do, the allowlist should make impossible:
|
|
62
|
+
|
|
63
|
+
| The skill says | So the allowlist omits |
|
|
64
|
+
| -------------------------- | ---------------------- |
|
|
65
|
+
| "Do NOT make file changes" | `Edit`, `Write` |
|
|
66
|
+
| "Do NOT auto-fix" | `Edit`, `Write` |
|
|
67
|
+
| "Do NOT stage or commit" | every `Bash(git …)` |
|
|
68
|
+
| "Do NOT push" | `Bash(git push:*)` |
|
|
69
|
+
|
|
70
|
+
Three rules follow from this:
|
|
71
|
+
|
|
72
|
+
1. **Every command the body tells the agent to run must be allowlisted.** A body that says `eslint $ARGUMENTS` under an allowlist of only `Bash(pnpm exec eslint:*)` blocks itself halfway through. List each form the body actually uses.
|
|
73
|
+
2. **Grant the narrowest set that still works.** `Bash(pnpm lint:*), Bash(eslint:*)` over a bare `Bash`.
|
|
74
|
+
3. **Never grant `git commit` or `git push`.** A skill does one job and leaves its changes for whoever ran it. Committing is the [project's workflow](/Standards/agent-specs#project-workflow), not a skill's.
|
|
75
|
+
|
|
76
|
+
Be honest about the limit: patterns gate the command, not its flags. `Bash(eslint:*)` still permits `eslint --fix`. The allowlist reliably prevents a skill from reaching for a whole _category_ of tool; keep the prose instruction as well for anything finer.
|
|
77
|
+
|
|
78
|
+
## Write for the agent, not the user
|
|
79
|
+
|
|
80
|
+
A skill body is the agent's instructions. Write directives, not a description of what the user is about to experience.
|
|
81
|
+
|
|
82
|
+
```markdown
|
|
83
|
+
<!-- Good — tells the agent what to do -->
|
|
84
|
+
|
|
85
|
+
Run each applicable linter in check-only mode and report the findings grouped by file.
|
|
86
|
+
|
|
87
|
+
<!-- Bad — tells the user what will happen -->
|
|
88
|
+
|
|
89
|
+
This command will check your code and give you a nice report.
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Structure
|
|
93
|
+
|
|
94
|
+
- **Number the steps.** Agents follow ordered lists more reliably than prose paragraphs.
|
|
95
|
+
|
|
96
|
+
- **Indent sub-steps by three spaces**, not two. An ordered item's content offset is three characters (`1. `), and at two spaces CommonMark — and Prettier — will lift the bullets out into a separate list and break the numbering.
|
|
97
|
+
|
|
98
|
+
```markdown
|
|
99
|
+
2. Run each applicable linter:
|
|
100
|
+
- ESLint: `eslint $ARGUMENTS`
|
|
101
|
+
- Stylelint: `stylelint "**/*.{css,scss}"`
|
|
102
|
+
3. Collect the warnings.
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
- **State the contract explicitly**, in the body as well as the frontmatter — `Do NOT stage or commit`, `Do NOT push`.
|
|
106
|
+
|
|
107
|
+
- **Say what to do when a prerequisite is missing.** Naming the fallback is what stops an agent from quietly substituting a worse one.
|
|
108
|
+
|
|
109
|
+
## Prefer the project's own scripts
|
|
110
|
+
|
|
111
|
+
Respect the project's own scripts. `pnpm lint` picks up workspace configuration that a bare `eslint .` at the root will miss, and in a monorepo the bare form is simply wrong.
|
|
112
|
+
|
|
113
|
+
## Checklist
|
|
114
|
+
|
|
115
|
+
Before merging a skill:
|
|
116
|
+
|
|
117
|
+
- [ ] `name` matches the filename
|
|
118
|
+
- [ ] `description` is one line, under 60 characters
|
|
119
|
+
- [ ] `argument-hint` present if it takes arguments, and quoted if it starts with `[`
|
|
120
|
+
- [ ] `allowed-tools` omits everything the body promises not to do
|
|
121
|
+
- [ ] `allowed-tools` includes every command the body does invoke
|
|
122
|
+
- [ ] Body is written as instructions to the agent
|
|
123
|
+
- [ ] Sub-steps indented three spaces
|
|
124
|
+
- [ ] Prettier leaves the file unchanged
|
|
125
|
+
- [ ] `.claude/commands/` mirror matches `.agents/skills/`
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 7
|
|
3
|
+
sidebar_label: "AGENTS.md"
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# AGENTS.md Specifications
|
|
7
|
+
|
|
8
|
+
Every Activatus repository must have an `AGENTS.md` in its root. This file gives AI coding agents (Claude Code, Copilot, Cursor, etc.) the context they need to work effectively without repeated explanation.
|
|
9
|
+
|
|
10
|
+
## Project workflow
|
|
11
|
+
|
|
12
|
+
**How a project runs its work is not part of these standards.** Branch names, commit messages, Pull Requests, merging, releases, and whether AI agents may commit, push or make branches are all the project's own decisions. Every project makes them differently.
|
|
13
|
+
|
|
14
|
+
Each project writes them up in its own docs, usually in `docs/development/`, and its `AGENTS.md` has a **Project workflow** section that points to them and states the rules an agent must follow. The most important one goes first: whether an agent may commit.
|
|
15
|
+
|
|
16
|
+
## Template
|
|
17
|
+
|
|
18
|
+
Start from the [AGENTS.md template](/templates#agents) and replace every `[placeholder]`.
|
|
19
|
+
|
|
20
|
+
## Required sections
|
|
21
|
+
|
|
22
|
+
Every `AGENTS.md` must include these sections. Monorepos (`pnpm-workspace.yaml`, Turborepo, Nx, etc.) also require a **Workspace packages** table listing each package, its path and a one-line description.
|
|
23
|
+
|
|
24
|
+
| Section | Purpose |
|
|
25
|
+
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
26
|
+
| Project overview | One paragraph: what it does, who uses it, why it exists |
|
|
27
|
+
| Repository layout | Directory tree at depth 2 |
|
|
28
|
+
| Tech stack | Language, runtime, framework, database, infra (with versions) |
|
|
29
|
+
| Essential commands | Install, dev, build, test, lint, type-check |
|
|
30
|
+
| Project workflow | The project's own rules for branches, commits, Pull Requests and merging, and whether agents may commit. Points to where they are written up |
|
|
31
|
+
| Environment variables | All required and optional env vars with descriptions |
|
|
32
|
+
| Ontology | Link to the [ontology](/ontology), and the instruction to read it and use its terms |
|
|
33
|
+
| Documentation | Where the project's docs are, and the instruction to read them before starting work |
|
|
34
|
+
| Code standards | Link to these standards and the rules agents must follow in every change |
|
|
35
|
+
| Available skills | Table of the agent skills the project provides |
|
|
36
|
+
| Out of scope for AI agents | Explicit list of what agents must not do in this project |
|
|
37
|
+
|
|
38
|
+
## Standard skills
|
|
39
|
+
|
|
40
|
+
Every project provides these eight skills. **The files are ready to copy from the [Templates page](/templates#skills)** — copy them into `.agents/skills/`, and again into `.claude/commands/` for Claude Code. They are written to the [agent skills standard](/Standards/agent-skills).
|
|
41
|
+
|
|
42
|
+
| Skill | Invocation | What it does |
|
|
43
|
+
| -------------- | -------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
44
|
+
| Lint | `/lint [path]` | Runs ESLint (and Stylelint if configured) in check-only mode; reports all issues grouped by file |
|
|
45
|
+
| Lint & fix | `/lintFix [path]` | Runs ESLint and Stylelint in fix mode, then Prettier; reports what changed and what is left |
|
|
46
|
+
| Format | `/format [path]` | Runs Prettier in write mode; reports reformatted files |
|
|
47
|
+
| Code review | `/codeReview [branch, commit or path]` | Reviews changes for correctness, security, types, tests and standards compliance. Report only |
|
|
48
|
+
| Update layout | `/updateLayout` | Regenerates the "Repository layout" section of `AGENTS.md` (and "Workspace packages" in monorepos) |
|
|
49
|
+
| Security audit | `/securityAudit [path]` | Audits dependencies and code for secrets, missing access control, unvalidated input and injection. Report only |
|
|
50
|
+
| TypeScript | `/typescript [path]` | Tightens loose types and removes `any`, `!` and unexplained `as` |
|
|
51
|
+
| Test | `/test [path]` | Runs the test suite; reports failures grouped by cause, tests that never ran, and files missing a test |
|
|
52
|
+
|
|
53
|
+
Skill files are named in camelCase (`lintFix.md`), so the invocation is camelCase too (`/lintFix`). They are not documentation pages and have no URL, so the kebab-case rule for docs does not apply.
|
|
54
|
+
|
|
55
|
+
No skill commits, pushes or makes branches. A skill does one job and leaves its changes for the agent or person who ran it. Whether those changes are then committed is the [project's workflow](#project-workflow).
|
|
56
|
+
|
|
57
|
+
### Skill locations
|
|
58
|
+
|
|
59
|
+
Skills are stored in two locations so they work with different tooling:
|
|
60
|
+
|
|
61
|
+
| Path | Used by |
|
|
62
|
+
| ------------------- | ----------------------------------------- |
|
|
63
|
+
| `.agents/skills/` | General agent discovery convention |
|
|
64
|
+
| `.claude/commands/` | Claude Code slash command system (mirror) |
|
|
65
|
+
|
|
66
|
+
## Writing guidelines
|
|
67
|
+
|
|
68
|
+
| Do | Don't |
|
|
69
|
+
| ------------------------------------------------------ | -------------------------------------------- |
|
|
70
|
+
| Use concrete commands (`pnpm test`) | Use vague instructions ("run the tests") |
|
|
71
|
+
| State constraints explicitly ("do not push to `main`") | Assume the agent knows your branching policy |
|
|
72
|
+
| Include version numbers in the tech stack | Leave versions ambiguous |
|
|
73
|
+
| Keep it under ~300 lines | Write a novel — agents have context limits |
|
|
74
|
+
| Run `/updateLayout` after structural changes | Let the directory tree go stale |
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 4
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# direnv + nvm
|
|
6
|
+
|
|
7
|
+
Automatically switch to the project's Node.js version when you `cd` into the repository. No manual `nvm use` required.
|
|
8
|
+
|
|
9
|
+
## How it works
|
|
10
|
+
|
|
11
|
+
Two files work together:
|
|
12
|
+
|
|
13
|
+
| File | Purpose |
|
|
14
|
+
| -------- | ------------------------------------------------------------------------ |
|
|
15
|
+
| `.nvmrc` | Declares the required Node.js major version (e.g. `20`) |
|
|
16
|
+
| `.envrc` | Loaded by direnv on `cd`; sources nvm and activates the declared version |
|
|
17
|
+
|
|
18
|
+
When you enter the project directory direnv runs `.envrc`, which installs the declared Node version (if missing) and activates it for your shell session. Leaving the directory restores the previous environment automatically.
|
|
19
|
+
|
|
20
|
+
## Installation
|
|
21
|
+
|
|
22
|
+
### macOS
|
|
23
|
+
|
|
24
|
+
**Homebrew** (recommended):
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
brew install direnv nvm
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Homebrew installs nvm to a prefix path rather than `$HOME/.nvm`. The `.envrc` handles this automatically by falling back to `$(brew --prefix nvm)/nvm.sh` when `$NVM_DIR/nvm.sh` is not found.
|
|
31
|
+
|
|
32
|
+
Add to the **end** of `~/.zshrc` (or `~/.bashrc` for bash):
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# nvm
|
|
36
|
+
export NVM_DIR="$HOME/.nvm"
|
|
37
|
+
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
38
|
+
|
|
39
|
+
# direnv
|
|
40
|
+
eval "$(direnv hook zsh)" # replace zsh with bash if needed
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Manual nvm install** (alternative):
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Install nvm
|
|
47
|
+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
|
|
48
|
+
|
|
49
|
+
# Install direnv
|
|
50
|
+
brew install direnv
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The install script appends the nvm bootstrap to your shell profile automatically.
|
|
54
|
+
|
|
55
|
+
Then add the direnv hook to the **end** of `~/.zshrc`:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
eval "$(direnv hook zsh)"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Restart your shell (or `source ~/.zshrc`) after editing the profile.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
### Linux
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Install nvm
|
|
69
|
+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The script appends the following to your `~/.bashrc` (or `~/.zshrc`):
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
export NVM_DIR="$HOME/.nvm"
|
|
76
|
+
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Install direnv using your package manager:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
# Debian / Ubuntu
|
|
83
|
+
sudo apt install direnv
|
|
84
|
+
|
|
85
|
+
# Arch
|
|
86
|
+
sudo pacman -S direnv
|
|
87
|
+
|
|
88
|
+
# Fedora
|
|
89
|
+
sudo dnf install direnv
|
|
90
|
+
|
|
91
|
+
# Or via the official install script:
|
|
92
|
+
curl -sfL https://direnv.net/install.sh | bash
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Add the direnv hook to the **end** of `~/.bashrc` (or `~/.zshrc`):
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
eval "$(direnv hook bash)" # replace bash with zsh if needed
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Restart your shell after editing the profile.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
### Windows
|
|
106
|
+
|
|
107
|
+
direnv and nvm are Unix tools. On Windows the recommended path is **WSL 2**. A Git Bash alternative is available for teams that cannot use WSL.
|
|
108
|
+
|
|
109
|
+
#### Option A — WSL 2 (recommended)
|
|
110
|
+
|
|
111
|
+
WSL 2 provides a full Linux environment. Follow the [Linux instructions](#linux) inside your WSL shell. Your editor (VS Code, JetBrains) should be configured to open projects inside WSL for the environment to be active.
|
|
112
|
+
|
|
113
|
+
Install WSL 2 if you haven't already:
|
|
114
|
+
|
|
115
|
+
```powershell
|
|
116
|
+
# Run in PowerShell (Administrator)
|
|
117
|
+
wsl --install
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Then open a WSL terminal and follow the [Linux setup](#linux) above.
|
|
121
|
+
|
|
122
|
+
#### Option B — Git Bash + nvm-windows
|
|
123
|
+
|
|
124
|
+
If WSL is not available, direnv and [nvm-windows](https://github.com/coreybutler/nvm-windows) can be used together in Git Bash.
|
|
125
|
+
|
|
126
|
+
**1. Install nvm-windows**
|
|
127
|
+
|
|
128
|
+
Download and run the installer from the [nvm-windows releases page](https://github.com/coreybutler/nvm-windows/releases). This installs `nvm.exe` and adds it to `PATH`.
|
|
129
|
+
|
|
130
|
+
nvm-windows exposes `nvm` as an executable in Git Bash — no `nvm.sh` sourcing is needed. The `.envrc` detects this automatically.
|
|
131
|
+
|
|
132
|
+
**2. Install direnv**
|
|
133
|
+
|
|
134
|
+
Download the latest Windows binary from the [direnv releases page](https://github.com/direnv/direnv/releases) (`direnv.windows-amd64.exe`), rename it to `direnv.exe`, and place it somewhere on your `PATH` (e.g. `C:\Program Files\direnv\`).
|
|
135
|
+
|
|
136
|
+
**3. Hook direnv into Git Bash**
|
|
137
|
+
|
|
138
|
+
Add to `~/.bashrc` inside Git Bash:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
eval "$(direnv hook bash)"
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
Restart Git Bash after editing.
|
|
145
|
+
|
|
146
|
+
:::note
|
|
147
|
+
|
|
148
|
+
nvm-windows reads `.nvmrc` when a version is passed explicitly. The `.envrc` in this project uses `nvm install "$version"` and `nvm use "$version"` (reading from `.nvmrc`), which is compatible with both nvm and nvm-windows.
|
|
149
|
+
|
|
150
|
+
:::
|
|
151
|
+
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## After cloning
|
|
155
|
+
|
|
156
|
+
After cloning a project that ships `.envrc`, run once:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
direnv allow
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
direnv prompts for this on every new `.envrc` it has not seen before — this is a security feature that prevents untrusted scripts from running automatically. Re-run `direnv allow` whenever `.envrc` changes.
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Files
|
|
167
|
+
|
|
168
|
+
### `.nvmrc`
|
|
169
|
+
|
|
170
|
+
Contains just the Node.js major version:
|
|
171
|
+
|
|
172
|
+
```text
|
|
173
|
+
20
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Update this when the project requires a new minimum Node version.
|
|
177
|
+
|
|
178
|
+
### `.envrc`
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
|
|
182
|
+
|
|
183
|
+
# Source the nvm shell function.
|
|
184
|
+
# Handles: manual install ($HOME/.nvm), Homebrew on macOS, and WSL.
|
|
185
|
+
# On Windows with nvm-windows, nvm is already an executable in PATH — no sourcing needed.
|
|
186
|
+
if [ -s "$NVM_DIR/nvm.sh" ]; then
|
|
187
|
+
. "$NVM_DIR/nvm.sh"
|
|
188
|
+
elif [ "$(uname -s 2>/dev/null)" = "Darwin" ] && command -v brew &>/dev/null; then
|
|
189
|
+
_nvm_sh="$(brew --prefix nvm 2>/dev/null)/nvm.sh"
|
|
190
|
+
[ -s "$_nvm_sh" ] && . "$_nvm_sh"
|
|
191
|
+
unset _nvm_sh
|
|
192
|
+
fi
|
|
193
|
+
|
|
194
|
+
if [ -f ".nvmrc" ]; then
|
|
195
|
+
_node_version="$(tr -d '[:space:]' < .nvmrc)"
|
|
196
|
+
nvm install "$_node_version"
|
|
197
|
+
nvm use "$_node_version"
|
|
198
|
+
unset _node_version
|
|
199
|
+
fi
|
|
200
|
+
|
|
201
|
+
# Ensure the pnpm shim declared in package.json#packageManager is active via Corepack.
|
|
202
|
+
# `corepack enable` is idempotent — safe to run on every cd.
|
|
203
|
+
if command -v corepack &>/dev/null; then
|
|
204
|
+
corepack enable pnpm
|
|
205
|
+
fi
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
The script handles four environments:
|
|
209
|
+
|
|
210
|
+
| Environment | How nvm is loaded |
|
|
211
|
+
| -------------------------------- | --------------------------------------------------------------- |
|
|
212
|
+
| macOS — manual install | `$HOME/.nvm/nvm.sh` sourced directly |
|
|
213
|
+
| macOS — Homebrew | `$(brew --prefix nvm)/nvm.sh` sourced as fallback |
|
|
214
|
+
| Linux / WSL 2 | `$HOME/.nvm/nvm.sh` sourced directly |
|
|
215
|
+
| Windows — Git Bash + nvm-windows | `nvm` is already in `PATH` as an executable; no sourcing needed |
|
|
216
|
+
|
|
217
|
+
The version is read explicitly from `.nvmrc` (stripping whitespace) and passed to both `nvm install` and `nvm use`, making the script compatible with both nvm and nvm-windows.
|
|
218
|
+
|
|
219
|
+
`corepack enable pnpm` installs a global shim so that running `pnpm` always delegates to the exact version declared in `package.json#packageManager` (e.g. `pnpm@9.15.0`). It is idempotent — safe to run on every `cd`. Corepack ships with Node.js 16.9+ so no separate install is required. If `corepack` is not in `PATH`, the block is skipped safely.
|
|
220
|
+
|
|
221
|
+
:::caution[Avoid `corepack use pnpm`]
|
|
222
|
+
|
|
223
|
+
`corepack use pnpm` (without an explicit version) writes the **latest** pnpm release into `package.json#packageManager`, silently upgrading the project. Never use it in `.envrc`.
|
|
224
|
+
|
|
225
|
+
:::
|
|
226
|
+
|
|
227
|
+
## `.gitignore`
|
|
228
|
+
|
|
229
|
+
Add the direnv cache directory — it contains compiled environment snapshots and should never be committed:
|
|
230
|
+
|
|
231
|
+
```text
|
|
232
|
+
.direnv/
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Troubleshooting
|
|
238
|
+
|
|
239
|
+
**`direnv: command not found`** — direnv is not installed or not on `PATH`. Follow the installation steps for your platform above.
|
|
240
|
+
|
|
241
|
+
**`nvm: command not found` inside `.envrc`** — The `.envrc` could not locate `nvm.sh`. Check:
|
|
242
|
+
|
|
243
|
+
- Manual install: confirm `$HOME/.nvm/nvm.sh` exists.
|
|
244
|
+
- Homebrew (macOS): confirm `brew list nvm` shows nvm is installed.
|
|
245
|
+
- The `NVM_DIR` environment variable is not pointing somewhere unexpected.
|
|
246
|
+
|
|
247
|
+
**`direnv` not activating on `cd`** — The shell hook is missing or in the wrong position. Make sure `eval "$(direnv hook zsh)"` (or bash) appears at the very **end** of your shell profile, after all other tool initialisations.
|
|
248
|
+
|
|
249
|
+
**`nvm use` reports wrong version on Windows** — Ensure nvm-windows v1.1.10 or later is installed. Earlier versions do not reliably accept explicit version arguments.
|