@smartsoft001/claude-plugins 2.123.0 → 2.124.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/package.json +1 -1
- package/plugins/smart/.claude-plugin/plugin.json +1 -1
- package/plugins/smart/skills/scaffold-nx-workspace/SKILL.md +84 -0
- package/plugins/smart/skills/scaffold-nx-workspace/references/base-app.md +405 -0
- package/plugins/smart/skills/scaffold-nx-workspace/references/base-claude-config.md +188 -0
- package/plugins/smart/skills/scaffold-nx-workspace/references/base-shared-lib.md +288 -0
- package/plugins/smart/skills/scaffold-nx-workspace/references/patch-delta.md +403 -0
- package/plugins/smart/skills/scaffold-nx-workspace/references/version-resolution.md +83 -0
- package/plugins/smart/skills/scaffold-nx-workspace/scripts/derive-prefix.sh +45 -0
- package/plugins/smart/skills/scaffold-nx-workspace/scripts/verify-scaffold.sh +97 -0
package/package.json
CHANGED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: scaffold-nx-workspace
|
|
3
|
+
description: Scaffold a generic base Nx + Angular SSR workspace in smartsoft001 style by wrapping create-nx-workspace and patching configs. Use whenever the user wants to bootstrap, scaffold, initialize, or set up a NEW smartsoft Nx monorepo / Angular SSR app workspace, or asks for the "podstawowa konfiguracja nx" / base workspace config. Scaffolds ONLY the generic toolchain plus a base SSR app and a base shared lib — no feature modules and no feature npm packages.
|
|
4
|
+
user-invocable: true
|
|
5
|
+
allowed-tools: Bash, Read, Write, Edit, Glob, Grep, AskUserQuestion
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Scaffold Nx Workspace
|
|
9
|
+
|
|
10
|
+
Bootstrap a base Nx + Angular SSR monorepo in smartsoft001 style: wrap `create-nx-workspace`,
|
|
11
|
+
then patch the generated files to the conventions below. The result is a **buildable empty
|
|
12
|
+
shell** — one SSR app (`apps/web`) and one shared lib (`libs/shared/angular`) — ready for the
|
|
13
|
+
feature-module skills to extend.
|
|
14
|
+
|
|
15
|
+
## Conventions (nx build & architecture only)
|
|
16
|
+
|
|
17
|
+
This skill enforces only the build and architecture conventions.
|
|
18
|
+
|
|
19
|
+
- **Toolchain:** npm + Nx + an Angular SSR app built with `@angular/build:application` (esbuild),
|
|
20
|
+
`outputMode: server`; Jest (jest-preset-angular, zoneless env) for unit tests, Playwright for e2e.
|
|
21
|
+
**Versions are never hardcoded** — the Angular version is inferred from the installed
|
|
22
|
+
`@smartsoft001/angular` library, confirmed with the user, and Nx / Node / the rest are derived to
|
|
23
|
+
match (see Step 1).
|
|
24
|
+
- **Caching / affected:** `targetDefaults` cache `build`/`lint`/`jest`; `nx.json` sets `defaultBase`
|
|
25
|
+
for `nx affected`. No Nx Cloud binding.
|
|
26
|
+
- **Lint / format:** ESLint flat config (`eslint.config.mjs`) with `import/order` + an `@<prefix>/**`
|
|
27
|
+
pathGroup; Prettier (`singleQuote`); husky + commitlint (conventional commits, scopes from `libs/`).
|
|
28
|
+
- **Layout:** monorepo with `apps/` (the SSR `web` app) and `libs/`. Shared lib at `libs/shared/angular`,
|
|
29
|
+
aliased `@<prefix>/angular`. Feature code lives in separate libs (`libs/<feature>/...`) added by the
|
|
30
|
+
module skills — never here.
|
|
31
|
+
- **Style:** `scss` everywhere — the app, generated libs, and generated components all default to `scss`.
|
|
32
|
+
- **SSR runtime env:** `EnvironmentService` (in the shared lib) + a `/env.js` endpoint + an `env-init.ts`
|
|
33
|
+
imported first in `main.server.ts`.
|
|
34
|
+
|
|
35
|
+
## Scope
|
|
36
|
+
|
|
37
|
+
**Scaffolds:** workspace config (nx / tsconfig / eslint / jest / prettier / husky / commitlint / `.nvmrc`),
|
|
38
|
+
the `apps/web` SSR shell, the `libs/shared/angular` skeleton, a generic `.claude` baseline, and toolchain
|
|
39
|
+
`package.json` deps.
|
|
40
|
+
|
|
41
|
+
**Hard boundary — does NOT scaffold:** feature modules / domains, feature npm packages, or module-coupled
|
|
42
|
+
components. Stop at the buildable shell and defer those to the feature-module skills.
|
|
43
|
+
|
|
44
|
+
## When to use / not use
|
|
45
|
+
|
|
46
|
+
- **Use for:** bootstrapping a new smartsoft Nx / Angular-SSR workspace, "podstawowa konfiguracja nx", a no-modules skeleton.
|
|
47
|
+
- **Not for:** adding a feature lib/module (→ module skills), adding feature deps, reconfiguring an existing
|
|
48
|
+
workspace's lint/format (→ `/smart:format-code`), or component API questions (→ `smart:angular-components-*`).
|
|
49
|
+
|
|
50
|
+
## Steps
|
|
51
|
+
|
|
52
|
+
1. **Resolve & confirm versions** — the Angular version anchors everything else (see
|
|
53
|
+
`references/version-resolution.md`):
|
|
54
|
+
- Detect the Angular version `@smartsoft001/angular` targets:
|
|
55
|
+
`npm view @smartsoft001/angular peerDependencies.@angular/core` (fall back to
|
|
56
|
+
`dependencies.@angular/core`; or read its installed `package.json`). Take `<NG_VERSION>` / `<NG_MAJOR>`.
|
|
57
|
+
- Confirm with `AskUserQuestion`: "Use Angular `<NG_VERSION>` (matches @smartsoft001/angular)? — or type another version."
|
|
58
|
+
- Derive the rest: `<NX_LINE>` = `^<NG_MAJOR + 1>` (Nx major tracks Angular major + 1, e.g. Angular 21 → Nx 22; verify with `npm view nx@<NX_LINE> version`); `<NODE_VERSION>` = an LTS within `@angular/core@<NG_VERSION>` `engines.node`. Everything else is whatever `create-nx-workspace@<NX_LINE>` installs — not pinned.
|
|
59
|
+
2. **Prefix** — run `scripts/derive-prefix.sh <folder>`, present the candidate via `AskUserQuestion`,
|
|
60
|
+
require confirm/override. Hold as `<PREFIX>` (threaded into tsconfig paths, eslint, imports, package names).
|
|
61
|
+
3. **Base branch** — confirm `<BASE_BRANCH>` for `nx.json` `defaultBase` + husky pre-push (default `origin/development`).
|
|
62
|
+
4. **Create** — run:
|
|
63
|
+
```bash
|
|
64
|
+
npx --yes create-nx-workspace@<NX_LINE> <name> \
|
|
65
|
+
--preset=angular-monorepo --appName=web --style=scss --ssr \
|
|
66
|
+
--e2eTestRunner=playwright --unitTestRunner=jest \
|
|
67
|
+
--packageManager=npm --nxCloud=skip --interactive=false
|
|
68
|
+
```
|
|
69
|
+
Use `--interactive=false` (not `--no-interactive`); `--nxCloud=skip`; no `--bundler` (Angular's builder
|
|
70
|
+
is esbuild by default). `CLAUDECODE=1` forces non-interactive NDJSON output. Then verify the build executor
|
|
71
|
+
is `@angular/build:application`, and if the bundled Angular differs from `<NG_VERSION>`, align `@angular/*` in Step 5.
|
|
72
|
+
5. **Patch config** — apply `references/patch-delta.md`, threading `<PREFIX>` / `<BASE_BRANCH>` / `<NG_VERSION>` / `<NODE_VERSION>`.
|
|
73
|
+
6. **App + lib** — patch `apps/web` per `references/base-app.md`; generate then patch `libs/shared/angular`
|
|
74
|
+
per `references/base-shared-lib.md`.
|
|
75
|
+
7. **.claude baseline** — write per `references/base-claude-config.md`.
|
|
76
|
+
8. **Install (gated)** — ask before `npm install`; skip during self-validation.
|
|
77
|
+
9. **Verify** — run `scripts/verify-scaffold.sh <name> <PREFIX>`; fix and re-run until it passes.
|
|
78
|
+
|
|
79
|
+
## Notes
|
|
80
|
+
|
|
81
|
+
- Prerequisites: nvm + npm and an empty target directory. The Node version is derived in Step 1
|
|
82
|
+
(`.nvmrc` ← `<NODE_VERSION>`), not fixed by this skill.
|
|
83
|
+
- Bundled `references/` + `scripts/` ship automatically (the whole `src/plugins/**` tree is copied to dist).
|
|
84
|
+
Do NOT hand-edit `plugin.json` version — it is auto-synced at build time.
|
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
# Base SSR app — `apps/web`
|
|
2
|
+
|
|
3
|
+
`create-nx-workspace --ssr` emits the SSR skeleton. Patch it to the generic shell below,
|
|
4
|
+
stripping all feature/business logic. Substitute `<PREFIX>`.
|
|
5
|
+
|
|
6
|
+
The base app keeps the SSR Express server, a runtime-env endpoint (`/env.js`), the SSRF
|
|
7
|
+
host allow-list, a minimal standalone `App`, and a catch-all server route. It depends on
|
|
8
|
+
`EnvironmentService` + `environment` from `@<PREFIX>/angular` (see `base-shared-lib.md`) —
|
|
9
|
+
this base-app↔base-lib coupling is intentional generic SSR infra.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## `apps/web/project.json` (overwrite)
|
|
14
|
+
|
|
15
|
+
Drop feature `scripts` (e.g. masonry) and prod `fileReplacements` only if the base lib provides
|
|
16
|
+
`environment.prod.ts` (it does — keep the fileReplacement). Keep build/serve/test/lint/serve-static.
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"name": "web",
|
|
21
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
22
|
+
"projectType": "application",
|
|
23
|
+
"prefix": "app",
|
|
24
|
+
"sourceRoot": "apps/web/src",
|
|
25
|
+
"tags": [],
|
|
26
|
+
"targets": {
|
|
27
|
+
"build": {
|
|
28
|
+
"executor": "@angular/build:application",
|
|
29
|
+
"outputs": ["{options.outputPath}"],
|
|
30
|
+
"options": {
|
|
31
|
+
"outputPath": "dist/apps/web",
|
|
32
|
+
"browser": "apps/web/src/main.ts",
|
|
33
|
+
"polyfills": [],
|
|
34
|
+
"tsConfig": "apps/web/tsconfig.app.json",
|
|
35
|
+
"assets": [
|
|
36
|
+
{ "glob": "**/*", "input": "apps/web/public", "output": "/" }
|
|
37
|
+
],
|
|
38
|
+
"styles": ["apps/web/src/styles.scss"],
|
|
39
|
+
"server": "apps/web/src/main.server.ts",
|
|
40
|
+
"ssr": { "entry": "apps/web/src/server.ts" },
|
|
41
|
+
"outputMode": "server"
|
|
42
|
+
},
|
|
43
|
+
"configurations": {
|
|
44
|
+
"production": {
|
|
45
|
+
"fileReplacements": [
|
|
46
|
+
{
|
|
47
|
+
"replace": "libs/shared/angular/src/lib/environments/environment.ts",
|
|
48
|
+
"with": "libs/shared/angular/src/lib/environments/environment.prod.ts"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
"budgets": [
|
|
52
|
+
{
|
|
53
|
+
"type": "initial",
|
|
54
|
+
"maximumWarning": "2mb",
|
|
55
|
+
"maximumError": "4mb"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "anyComponentStyle",
|
|
59
|
+
"maximumWarning": "4kb",
|
|
60
|
+
"maximumError": "16kb"
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"outputHashing": "all",
|
|
64
|
+
"optimization": true
|
|
65
|
+
},
|
|
66
|
+
"development": {
|
|
67
|
+
"optimization": false,
|
|
68
|
+
"extractLicenses": false,
|
|
69
|
+
"sourceMap": true
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
"defaultConfiguration": "production"
|
|
73
|
+
},
|
|
74
|
+
"serve": {
|
|
75
|
+
"continuous": true,
|
|
76
|
+
"executor": "@angular/build:dev-server",
|
|
77
|
+
"options": { "port": 4210 },
|
|
78
|
+
"configurations": {
|
|
79
|
+
"production": { "buildTarget": "web:build:production" },
|
|
80
|
+
"development": { "buildTarget": "web:build:development" }
|
|
81
|
+
},
|
|
82
|
+
"defaultConfiguration": "development"
|
|
83
|
+
},
|
|
84
|
+
"extract-i18n": {
|
|
85
|
+
"executor": "@angular/build:extract-i18n",
|
|
86
|
+
"options": { "buildTarget": "web:build" }
|
|
87
|
+
},
|
|
88
|
+
"lint": { "executor": "@nx/eslint:lint" },
|
|
89
|
+
"test": {
|
|
90
|
+
"executor": "@nx/jest:jest",
|
|
91
|
+
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
|
92
|
+
"options": {
|
|
93
|
+
"jestConfig": "apps/web/jest.config.ts",
|
|
94
|
+
"tsConfig": "apps/web/tsconfig.spec.json"
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"serve-static": {
|
|
98
|
+
"continuous": true,
|
|
99
|
+
"executor": "@nx/web:file-server",
|
|
100
|
+
"options": {
|
|
101
|
+
"buildTarget": "web:build",
|
|
102
|
+
"port": 4210,
|
|
103
|
+
"staticFilePath": "dist/apps/web/browser",
|
|
104
|
+
"spa": true
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## `apps/web/src/env-init.ts` (create)
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
/**
|
|
117
|
+
* Environment initialization for server-side rendering.
|
|
118
|
+
*
|
|
119
|
+
* This file MUST be imported FIRST in main.server.ts to ensure
|
|
120
|
+
* environment variables are loaded from process.env BEFORE any
|
|
121
|
+
* modules that depend on them are evaluated.
|
|
122
|
+
*/
|
|
123
|
+
import { EnvironmentService } from '@<PREFIX>/angular';
|
|
124
|
+
|
|
125
|
+
EnvironmentService.initFromProcessEnv();
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## `apps/web/src/main.server.ts` (overwrite)
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
/**
|
|
132
|
+
* CRITICAL: './env-init' MUST be the first import!
|
|
133
|
+
* It initializes environment variables from process.env BEFORE
|
|
134
|
+
* any modules that depend on them are evaluated.
|
|
135
|
+
*/
|
|
136
|
+
import './env-init';
|
|
137
|
+
|
|
138
|
+
import {
|
|
139
|
+
BootstrapContext,
|
|
140
|
+
bootstrapApplication,
|
|
141
|
+
} from '@angular/platform-browser';
|
|
142
|
+
|
|
143
|
+
import { App } from './app/app';
|
|
144
|
+
import { config } from './app/app.config.server';
|
|
145
|
+
|
|
146
|
+
const bootstrap = (context: BootstrapContext) =>
|
|
147
|
+
bootstrapApplication(App, config, context);
|
|
148
|
+
|
|
149
|
+
export default bootstrap;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## `apps/web/src/main.ts` (keep create-nx-workspace default)
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
import { bootstrapApplication } from '@angular/platform-browser';
|
|
156
|
+
|
|
157
|
+
import { App } from './app/app';
|
|
158
|
+
import { appConfig } from './app/app.config';
|
|
159
|
+
|
|
160
|
+
bootstrapApplication(App, appConfig).catch((err) => console.error(err));
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
## `apps/web/src/server.ts` (overwrite — generic)
|
|
166
|
+
|
|
167
|
+
Generic Express + `AngularNodeAppEngine` with SSRF host allow-list and the `/env.js`
|
|
168
|
+
runtime-env endpoint. **Drop** any feature endpoints (e.g. a `/api/translations` handler) and
|
|
169
|
+
extra env keys beyond `API_URL` / `SITE_URL` / `APP_VERSION`.
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
import {
|
|
173
|
+
AngularNodeAppEngine,
|
|
174
|
+
createNodeRequestHandler,
|
|
175
|
+
isMainModule,
|
|
176
|
+
writeResponseToNodeResponse,
|
|
177
|
+
} from '@angular/ssr/node';
|
|
178
|
+
import { config } from 'dotenv';
|
|
179
|
+
import express from 'express';
|
|
180
|
+
|
|
181
|
+
import { dirname, resolve } from 'node:path';
|
|
182
|
+
import { fileURLToPath } from 'node:url';
|
|
183
|
+
|
|
184
|
+
config({ path: resolve(process.cwd(), '.env') });
|
|
185
|
+
|
|
186
|
+
const serverDistFolder = dirname(fileURLToPath(import.meta.url));
|
|
187
|
+
const browserDistFolder = resolve(serverDistFolder, '../browser');
|
|
188
|
+
|
|
189
|
+
const app = express();
|
|
190
|
+
|
|
191
|
+
// Build allowed hosts from SITE_URL and API_URL for SSR SSRF protection
|
|
192
|
+
const allowedHosts: string[] = [];
|
|
193
|
+
const siteUrl = process.env['SITE_URL'];
|
|
194
|
+
if (siteUrl) {
|
|
195
|
+
try {
|
|
196
|
+
const host = new URL(
|
|
197
|
+
siteUrl.startsWith('http') ? siteUrl : `https://${siteUrl}`,
|
|
198
|
+
).hostname;
|
|
199
|
+
allowedHosts.push(host);
|
|
200
|
+
if (host.startsWith('www.')) {
|
|
201
|
+
allowedHosts.push(host.slice(4));
|
|
202
|
+
} else {
|
|
203
|
+
allowedHosts.push(`www.${host}`);
|
|
204
|
+
}
|
|
205
|
+
} catch {
|
|
206
|
+
// ignore invalid URL
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const apiUrl = process.env['API_URL'];
|
|
210
|
+
if (apiUrl) {
|
|
211
|
+
try {
|
|
212
|
+
allowedHosts.push(
|
|
213
|
+
new URL(apiUrl.startsWith('http') ? apiUrl : `https://${apiUrl}`)
|
|
214
|
+
.hostname,
|
|
215
|
+
);
|
|
216
|
+
} catch {
|
|
217
|
+
// ignore invalid URL
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// In development/CI, allow localhost for SSR rendering
|
|
222
|
+
if (allowedHosts.length === 0 || process.env['NODE_ENV'] !== 'production') {
|
|
223
|
+
allowedHosts.push('localhost');
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const angularApp = new AngularNodeAppEngine({ allowedHosts });
|
|
227
|
+
|
|
228
|
+
app.get('/env.js', (req, res) => {
|
|
229
|
+
const envTemplate = `(function (window) {
|
|
230
|
+
window['env'] = window['env'] || {};
|
|
231
|
+
|
|
232
|
+
// Environment variables
|
|
233
|
+
window['env']['apiUrl'] = '\${API_URL}';
|
|
234
|
+
window['env']['siteUrl'] = '\${SITE_URL}';
|
|
235
|
+
window['env']['version'] = '\${APP_VERSION}';
|
|
236
|
+
})(this);`;
|
|
237
|
+
|
|
238
|
+
const envConfig = envTemplate
|
|
239
|
+
.replace(/\$\{API_URL\}/g, process.env['API_URL'] || '')
|
|
240
|
+
.replace(/\$\{SITE_URL\}/g, process.env['SITE_URL'] || '')
|
|
241
|
+
.replace(/\$\{APP_VERSION\}/g, process.env['APP_VERSION'] || '');
|
|
242
|
+
|
|
243
|
+
res.setHeader('Content-Type', 'application/javascript; charset=utf-8');
|
|
244
|
+
res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
|
|
245
|
+
res.send(envConfig);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Serve static files from /browser
|
|
250
|
+
*/
|
|
251
|
+
app.use(
|
|
252
|
+
express.static(browserDistFolder, {
|
|
253
|
+
maxAge: '1y',
|
|
254
|
+
index: false,
|
|
255
|
+
redirect: false,
|
|
256
|
+
}),
|
|
257
|
+
);
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Handle all other requests by rendering the Angular application.
|
|
261
|
+
*/
|
|
262
|
+
app.use('/**', (req, res, next) => {
|
|
263
|
+
angularApp
|
|
264
|
+
.handle(req)
|
|
265
|
+
.then((response) =>
|
|
266
|
+
response ? writeResponseToNodeResponse(response, res) : next(),
|
|
267
|
+
)
|
|
268
|
+
.catch(next);
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Start the server if this module is the main entry point.
|
|
273
|
+
*/
|
|
274
|
+
if (isMainModule(import.meta.url)) {
|
|
275
|
+
const port = process.env['PORT'] || 4000;
|
|
276
|
+
app.listen(port, () => {
|
|
277
|
+
console.log(`Node Express server listening on http://localhost:${port}`);
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Request handler used by the Angular CLI (for dev-server and during build).
|
|
283
|
+
*/
|
|
284
|
+
export const reqHandler = createNodeRequestHandler(app);
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
---
|
|
288
|
+
|
|
289
|
+
## `apps/web/src/app/app.config.ts` (overwrite — minimal)
|
|
290
|
+
|
|
291
|
+
Strip ngrx / translate / masonry / feature modules. Keep zoneless + hydration + router +
|
|
292
|
+
http + the `EnvironmentService` initializer.
|
|
293
|
+
|
|
294
|
+
```ts
|
|
295
|
+
import {
|
|
296
|
+
provideHttpClient,
|
|
297
|
+
withFetch,
|
|
298
|
+
withInterceptorsFromDi,
|
|
299
|
+
} from '@angular/common/http';
|
|
300
|
+
import {
|
|
301
|
+
ApplicationConfig,
|
|
302
|
+
inject,
|
|
303
|
+
isDevMode,
|
|
304
|
+
provideBrowserGlobalErrorListeners,
|
|
305
|
+
provideEnvironmentInitializer,
|
|
306
|
+
provideZonelessChangeDetection,
|
|
307
|
+
} from '@angular/core';
|
|
308
|
+
import {
|
|
309
|
+
provideClientHydration,
|
|
310
|
+
withEventReplay,
|
|
311
|
+
} from '@angular/platform-browser';
|
|
312
|
+
import { provideRouter, withInMemoryScrolling } from '@angular/router';
|
|
313
|
+
|
|
314
|
+
import { EnvironmentService } from '@<PREFIX>/angular';
|
|
315
|
+
|
|
316
|
+
import { appRoutes } from './app.routes';
|
|
317
|
+
|
|
318
|
+
export const appConfig: ApplicationConfig = {
|
|
319
|
+
providers: [
|
|
320
|
+
provideClientHydration(withEventReplay()),
|
|
321
|
+
provideBrowserGlobalErrorListeners(),
|
|
322
|
+
provideZonelessChangeDetection(),
|
|
323
|
+
provideRouter(
|
|
324
|
+
appRoutes,
|
|
325
|
+
withInMemoryScrolling({ scrollPositionRestoration: 'top' }),
|
|
326
|
+
),
|
|
327
|
+
provideHttpClient(withFetch(), withInterceptorsFromDi()),
|
|
328
|
+
provideEnvironmentInitializer(() => {
|
|
329
|
+
const envService = inject(EnvironmentService);
|
|
330
|
+
envService.init();
|
|
331
|
+
}),
|
|
332
|
+
],
|
|
333
|
+
};
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## `apps/web/src/app/app.config.server.ts` (keep create-nx-workspace default)
|
|
337
|
+
|
|
338
|
+
```ts
|
|
339
|
+
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
|
340
|
+
import { provideServerRendering, withRoutes } from '@angular/ssr';
|
|
341
|
+
|
|
342
|
+
import { appConfig } from './app.config';
|
|
343
|
+
import { serverRoutes } from './app.routes.server';
|
|
344
|
+
|
|
345
|
+
const serverConfig: ApplicationConfig = {
|
|
346
|
+
providers: [provideServerRendering(withRoutes(serverRoutes))],
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
export const config = mergeApplicationConfig(appConfig, serverConfig);
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
## `apps/web/src/app/app.routes.server.ts` (overwrite — catch-all only)
|
|
353
|
+
|
|
354
|
+
```ts
|
|
355
|
+
import { RenderMode, ServerRoute } from '@angular/ssr';
|
|
356
|
+
|
|
357
|
+
export const serverRoutes: ServerRoute[] = [
|
|
358
|
+
{
|
|
359
|
+
path: '**',
|
|
360
|
+
renderMode: RenderMode.Server,
|
|
361
|
+
},
|
|
362
|
+
];
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
## `apps/web/src/app/app.routes.ts` (overwrite — empty)
|
|
366
|
+
|
|
367
|
+
```ts
|
|
368
|
+
import { Route } from '@angular/router';
|
|
369
|
+
|
|
370
|
+
export const appRoutes: Route[] = [];
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
## `apps/web/src/app/app.ts` (overwrite — minimal shell)
|
|
374
|
+
|
|
375
|
+
```ts
|
|
376
|
+
import { Component } from '@angular/core';
|
|
377
|
+
import { RouterModule } from '@angular/router';
|
|
378
|
+
|
|
379
|
+
@Component({
|
|
380
|
+
imports: [RouterModule],
|
|
381
|
+
selector: 'app-root',
|
|
382
|
+
templateUrl: './app.html',
|
|
383
|
+
styleUrl: './app.scss',
|
|
384
|
+
})
|
|
385
|
+
export class App {}
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
## `apps/web/src/app/app.html` (overwrite — minimal)
|
|
389
|
+
|
|
390
|
+
```html
|
|
391
|
+
<router-outlet></router-outlet>
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
---
|
|
395
|
+
|
|
396
|
+
## Files to keep as create-nx-workspace emitted them
|
|
397
|
+
|
|
398
|
+
`apps/web/src/styles.scss`, `apps/web/src/index.html`, `apps/web/src/test-setup.ts`,
|
|
399
|
+
`apps/web/src/app/app.scss`, `apps/web/tsconfig.app.json`, `apps/web/tsconfig.spec.json`,
|
|
400
|
+
`apps/web/tsconfig.json`, `apps/web/eslint.config.mjs`, `apps/web/jest.config.ts`,
|
|
401
|
+
`apps/web/public/**`.
|
|
402
|
+
|
|
403
|
+
> If `apps/web/jest.config.ts` carries a feature `moduleNameMapper` or a feature-scoped
|
|
404
|
+
> `transformIgnorePatterns` entry, strip it to a generic
|
|
405
|
+
> `transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)']`.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Base `.claude` config
|
|
2
|
+
|
|
3
|
+
Seed the **generic** baseline only. Drop `flow@mobilems` and all project-specific
|
|
4
|
+
permissions/MCP allow-lists from the reference. Substitute `<WORKSPACE_NAME>`.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## `.claude/settings.json` (create)
|
|
9
|
+
|
|
10
|
+
The smart-plugin hooks resolve from `node_modules/@smartsoft001/claude-plugins/...`
|
|
11
|
+
(added to devDeps in `patch-delta.md`).
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"permissions": {
|
|
16
|
+
"allow": [
|
|
17
|
+
"Bash(nx:*)",
|
|
18
|
+
"Bash(npx nx:*)",
|
|
19
|
+
"Bash(npm run format:*)",
|
|
20
|
+
"Bash(source:*)",
|
|
21
|
+
"Bash(nvm use:*)",
|
|
22
|
+
"Bash(git status:*)",
|
|
23
|
+
"Bash(git diff:*)",
|
|
24
|
+
"Bash(git log:*)",
|
|
25
|
+
"Bash(git show:*)",
|
|
26
|
+
"Bash(git add:*)",
|
|
27
|
+
"Bash(git fetch:*)",
|
|
28
|
+
"Bash(ls:*)",
|
|
29
|
+
"Bash(find:*)",
|
|
30
|
+
"Bash(grep:*)"
|
|
31
|
+
],
|
|
32
|
+
"deny": [],
|
|
33
|
+
"ask": ["Bash(git commit:*)", "Bash(git push:*)", "Bash(gh pr create:*)"]
|
|
34
|
+
},
|
|
35
|
+
"hooks": {
|
|
36
|
+
"PreToolUse": [
|
|
37
|
+
{
|
|
38
|
+
"matcher": "Bash|Write|Edit",
|
|
39
|
+
"hooks": [
|
|
40
|
+
{
|
|
41
|
+
"type": "command",
|
|
42
|
+
"command": "node_modules/@smartsoft001/claude-plugins/plugins/smart/hooks/safety_validator.py"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"matcher": "Read|Edit|Write",
|
|
48
|
+
"hooks": [
|
|
49
|
+
{
|
|
50
|
+
"type": "command",
|
|
51
|
+
"command": "FILE=$(jq -r '.tool_input.file_path // empty'); echo \"$FILE\" | grep -qE '(\\.env|secrets|credentials)' && { echo \"BLOCKED: Access denied to sensitive file: $FILE\" >&2; exit 2; } || exit 0"
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"matcher": "",
|
|
57
|
+
"hooks": [
|
|
58
|
+
{
|
|
59
|
+
"type": "command",
|
|
60
|
+
"command": "node_modules/@smartsoft001/claude-plugins/plugins/smart/hooks/audit_logger.py"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"matcher": "Write|Edit",
|
|
66
|
+
"hooks": [
|
|
67
|
+
{
|
|
68
|
+
"type": "command",
|
|
69
|
+
"command": "node_modules/@smartsoft001/claude-plugins/plugins/smart/hooks/skill_validator.py"
|
|
70
|
+
}
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
],
|
|
74
|
+
"PostToolUse": [
|
|
75
|
+
{
|
|
76
|
+
"matcher": "Write|Edit",
|
|
77
|
+
"hooks": [
|
|
78
|
+
{
|
|
79
|
+
"type": "command",
|
|
80
|
+
"command": "source ~/.nvm/nvm.sh && nvm use 24 && npm run format"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"matcher": "",
|
|
86
|
+
"hooks": [
|
|
87
|
+
{
|
|
88
|
+
"type": "command",
|
|
89
|
+
"command": "node_modules/@smartsoft001/claude-plugins/plugins/smart/hooks/audit_logger.py"
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"UserPromptSubmit": [
|
|
95
|
+
{
|
|
96
|
+
"hooks": [
|
|
97
|
+
{
|
|
98
|
+
"type": "command",
|
|
99
|
+
"command": "node_modules/@smartsoft001/claude-plugins/plugins/smart/hooks/audit_logger.py"
|
|
100
|
+
}
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
},
|
|
105
|
+
"enabledPlugins": {
|
|
106
|
+
"smart@smartsoft": true,
|
|
107
|
+
"nx@nx-claude-plugins": true
|
|
108
|
+
},
|
|
109
|
+
"extraKnownMarketplaces": {
|
|
110
|
+
"nx-claude-plugins": {
|
|
111
|
+
"source": {
|
|
112
|
+
"source": "github",
|
|
113
|
+
"repo": "nrwl/nx-ai-agents-config"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
"env": {
|
|
118
|
+
"CLAUDE_CODE_FORK_SUBAGENT": "1",
|
|
119
|
+
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
> The mobilems module skills (the `flow@mobilems` plugin) are added to `enabledPlugins`
|
|
125
|
+
> and the project-specific permissions are grown when those skills run — not here.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## `AGENTS.md` (create — generic Nx block, verbatim-usable)
|
|
130
|
+
|
|
131
|
+
```md
|
|
132
|
+
<!-- nx configuration start-->
|
|
133
|
+
<!-- Leave the start & end comments to automatically receive updates. -->
|
|
134
|
+
|
|
135
|
+
# General Guidelines for working with Nx
|
|
136
|
+
|
|
137
|
+
- For navigating/exploring the workspace, invoke the `nx-workspace` skill first - it has patterns for querying projects, targets, and dependencies
|
|
138
|
+
- When running tasks (for example build, lint, test, e2e, etc.), always prefer running the task through `nx` (i.e. `nx run`, `nx run-many`, `nx affected`) instead of using the underlying tooling directly
|
|
139
|
+
- Prefix nx commands with the workspace's package manager (e.g., `npm exec nx build`) - avoids using globally installed CLI
|
|
140
|
+
- You have access to the Nx MCP server and its tools, use them to help the user
|
|
141
|
+
- For Nx plugin best practices, check `node_modules/@nx/<plugin>/PLUGIN.md`. Not all plugins have this file - proceed without it if unavailable.
|
|
142
|
+
- NEVER guess CLI flags - always check nx_docs or `--help` first when unsure
|
|
143
|
+
|
|
144
|
+
## Scaffolding & Generators
|
|
145
|
+
|
|
146
|
+
- For scaffolding tasks (creating apps, libs, project structure, setup), ALWAYS invoke the `nx-generate` skill FIRST before exploring or calling MCP tools
|
|
147
|
+
|
|
148
|
+
## When to use nx_docs
|
|
149
|
+
|
|
150
|
+
- USE for: advanced config options, unfamiliar flags, migration guides, plugin configuration, edge cases
|
|
151
|
+
- DON'T USE for: basic generator syntax (`nx g @nx/react:app`), standard commands, things you already know
|
|
152
|
+
- The `nx-generate` skill handles generator discovery internally - don't call nx_docs just to look up generator syntax
|
|
153
|
+
|
|
154
|
+
<!-- nx configuration end-->
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## `CLAUDE.md` (create — trimmed generic skeleton)
|
|
160
|
+
|
|
161
|
+
```md
|
|
162
|
+
# CLAUDE.md
|
|
163
|
+
|
|
164
|
+
Guidance for Claude Code when working in the **<WORKSPACE_NAME>** workspace.
|
|
165
|
+
|
|
166
|
+
## Project Overview
|
|
167
|
+
|
|
168
|
+
Nx + Angular SSR monorepo scaffolded with the smartsoft `scaffold-nx-workspace` skill.
|
|
169
|
+
A base shell only — feature modules are added by the mobilems module skills.
|
|
170
|
+
|
|
171
|
+
## Structure
|
|
172
|
+
|
|
173
|
+
- `apps/web` — Angular SSR app (Express server + runtime-env).
|
|
174
|
+
- `libs/shared/angular` — shared library (`@<PREFIX>/angular`).
|
|
175
|
+
|
|
176
|
+
## Conventions
|
|
177
|
+
|
|
178
|
+
- **Node** per `.nvmrc` via nvm; npm package manager.
|
|
179
|
+
- Run tasks through Nx: `nx build`, `nx test`, `nx lint`, `nx serve web`.
|
|
180
|
+
- Format with `/smart:format-code` (Prettier + ESLint flat config, `eslint.config.mjs`).
|
|
181
|
+
- Conventional commits (commitlint); husky pre-push runs affected lint/test/build.
|
|
182
|
+
- For smartsoft conventions, see the `/smart:project-conventions` skill.
|
|
183
|
+
|
|
184
|
+
## Boundaries
|
|
185
|
+
|
|
186
|
+
- Styling defaults to **scss** everywhere (app, libs, and components).
|
|
187
|
+
- Do not add feature npm packages or feature modules by hand — use the module skills.
|
|
188
|
+
```
|