@for-yeyu/evm-dapp-skills 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/package.json +21 -0
- package/skills/api-conventions/SKILL.md +61 -0
- package/skills/app-router-conventions/SKILL.md +56 -0
- package/skills/configs-conventions/SKILL.md +45 -0
- package/skills/evm-dapp-standard-coding/SKILL.md +58 -0
- package/skills/evm-dapp-standard-coding/references/MIGRATION_GUIDE.md +220 -0
- package/skills/hooks-conventions/SKILL.md +53 -0
- package/skills/lib-infrastructure-conventions/SKILL.md +55 -0
- package/skills/styles-conventions/SKILL.md +41 -0
- package/skills/ui-conventions/SKILL.md +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# @for-yeyu/evm-dapp-skills
|
|
2
|
+
|
|
3
|
+
Standard skills package for the EVM DApp layered architecture.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @for-yeyu/evm-dapp-skills
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Use In Your Project
|
|
12
|
+
|
|
13
|
+
Copy skills into your local agent skills directory:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
rsync -a node_modules/@for-yeyu/evm-dapp-skills/skills/ .agents/skills/
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Included Skills
|
|
20
|
+
|
|
21
|
+
- `evm-dapp-standard-coding`
|
|
22
|
+
- `app-router-conventions`
|
|
23
|
+
- `ui-conventions`
|
|
24
|
+
- `api-conventions`
|
|
25
|
+
- `hooks-conventions`
|
|
26
|
+
- `configs-conventions`
|
|
27
|
+
- `lib-infrastructure-conventions`
|
|
28
|
+
- `styles-conventions`
|
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@for-yeyu/evm-dapp-skills",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Standard AI coding skills for the EVM DApp layered architecture.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"private": false,
|
|
7
|
+
"files": [
|
|
8
|
+
"skills/**"
|
|
9
|
+
],
|
|
10
|
+
"keywords": [
|
|
11
|
+
"skills",
|
|
12
|
+
"agents",
|
|
13
|
+
"ai",
|
|
14
|
+
"codex",
|
|
15
|
+
"evm",
|
|
16
|
+
"nextjs"
|
|
17
|
+
],
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: api-conventions
|
|
3
|
+
description: Use when creating or updating src/api request functions, domain exports, query/mutation separation, and HTTP transport choices.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# API Conventions
|
|
7
|
+
|
|
8
|
+
## Scope
|
|
9
|
+
|
|
10
|
+
Applies to `src/api/**`.
|
|
11
|
+
|
|
12
|
+
## Domain Structure
|
|
13
|
+
|
|
14
|
+
Each domain follows:
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
src/api/<domain>/
|
|
18
|
+
mutation/
|
|
19
|
+
query/
|
|
20
|
+
types/
|
|
21
|
+
index.ts
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Use `index.ts` barrels at subfolder and domain level.
|
|
25
|
+
|
|
26
|
+
## Hard Request Rules
|
|
27
|
+
|
|
28
|
+
All request functions must use wrapped ky helpers from `@/lib/http/ky`:
|
|
29
|
+
|
|
30
|
+
1. Use `apiRequest` for endpoints under `src/app/api/**`.
|
|
31
|
+
2. Use `httpRequest` for non-`src/app/api/**` endpoints.
|
|
32
|
+
3. Do not use direct `fetch`, raw `ky`, or ad-hoc transport logic.
|
|
33
|
+
|
|
34
|
+
## Client Boundary Rule
|
|
35
|
+
|
|
36
|
+
Client components must not call API endpoints directly.
|
|
37
|
+
|
|
38
|
+
Required chain:
|
|
39
|
+
|
|
40
|
+
`Client Component -> src/hooks -> src/api -> apiRequest/httpRequest`
|
|
41
|
+
|
|
42
|
+
## Workflow
|
|
43
|
+
|
|
44
|
+
1. Add function under `query/` or `mutation/` by behavior.
|
|
45
|
+
2. Add/update shared contracts under `types/`.
|
|
46
|
+
3. Export through local and domain `index.ts`.
|
|
47
|
+
4. Ensure transport helper choice is correct (`apiRequest` vs `httpRequest`).
|
|
48
|
+
|
|
49
|
+
## Review Checklist
|
|
50
|
+
|
|
51
|
+
- Function is in correct `query` or `mutation` folder.
|
|
52
|
+
- Shared contracts exist in `types`.
|
|
53
|
+
- `index.ts` barrels are updated.
|
|
54
|
+
- `apiRequest` is used for Next route handlers; `httpRequest` for others.
|
|
55
|
+
- No direct client-side API requests are introduced.
|
|
56
|
+
|
|
57
|
+
## References
|
|
58
|
+
|
|
59
|
+
- `src/api/README.md`
|
|
60
|
+
- `src/hooks/README.md`
|
|
61
|
+
- `src/lib/README.md`
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: app-router-conventions
|
|
3
|
+
description: Use when creating or modifying src/app route entries, page/layout wrappers, route handlers, and app-to-ui route mapping.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# App Router Conventions
|
|
7
|
+
|
|
8
|
+
## Scope
|
|
9
|
+
|
|
10
|
+
Applies to `src/app/**`.
|
|
11
|
+
|
|
12
|
+
## Hard Rules
|
|
13
|
+
|
|
14
|
+
1. Keep `src/app` as a thin route-entry layer.
|
|
15
|
+
2. Avoid page UI implementation details in route files.
|
|
16
|
+
3. For non-static pages, do not write page-specific styles in `src/app`.
|
|
17
|
+
4. Route entries export only `default function Page()` or `default function Layout()`.
|
|
18
|
+
5. Route entries return named components imported from mirrored `src/ui/app` paths.
|
|
19
|
+
|
|
20
|
+
Example:
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { ServerTimePage } from '@/ui/app/examples/server-time'
|
|
24
|
+
|
|
25
|
+
export default function Page() {
|
|
26
|
+
return <ServerTimePage />
|
|
27
|
+
}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Folder Mapping Rule
|
|
31
|
+
|
|
32
|
+
Keep route path and UI path aligned:
|
|
33
|
+
|
|
34
|
+
```text
|
|
35
|
+
src/app/examples/server-time/page.tsx
|
|
36
|
+
src/ui/app/examples/server-time/index.tsx
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Workflow
|
|
40
|
+
|
|
41
|
+
1. Add route entry in `src/app/<route>/page.tsx` or `layout.tsx`.
|
|
42
|
+
2. Add/update mirrored UI in `src/ui/app/<route>/index.tsx`.
|
|
43
|
+
3. Keep route entry minimal: import + return.
|
|
44
|
+
4. Keep shared layout pieces in `src/ui/app/layout` or route-local `layout/`.
|
|
45
|
+
|
|
46
|
+
## Review Checklist
|
|
47
|
+
|
|
48
|
+
- Route file uses `Page`/`Layout` export naming.
|
|
49
|
+
- Route file returns route-named UI component from `@/ui/app/...`.
|
|
50
|
+
- Non-static styles are not introduced in `src/app/**`.
|
|
51
|
+
- `src/app` <-> `src/ui/app` mapping remains one-to-one.
|
|
52
|
+
|
|
53
|
+
## References
|
|
54
|
+
|
|
55
|
+
- `src/app/README.md`
|
|
56
|
+
- `src/ui/README.md`
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: configs-conventions
|
|
3
|
+
description: Use when adding or updating runtime configuration schemas and shared/server config modules in src/configs.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Configs Conventions
|
|
7
|
+
|
|
8
|
+
## Scope
|
|
9
|
+
|
|
10
|
+
Applies to `src/configs/**`.
|
|
11
|
+
|
|
12
|
+
## Structure Rules
|
|
13
|
+
|
|
14
|
+
```text
|
|
15
|
+
src/configs/
|
|
16
|
+
schema/ # schema + config types only
|
|
17
|
+
shared/ # non-secret runtime config (client+server safe)
|
|
18
|
+
server/ # secret runtime config (server-only)
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Hard Rules
|
|
22
|
+
|
|
23
|
+
1. `schema/` defines schemas/types only and does not read `process.env`.
|
|
24
|
+
2. `shared/` reads non-secret env values and validates via `schema`.
|
|
25
|
+
3. `server/` reads secret env values and must include `import 'server-only'`.
|
|
26
|
+
4. `shared` modules must not depend on `server` modules.
|
|
27
|
+
5. `schema/index.ts` is the unified schema export entry.
|
|
28
|
+
|
|
29
|
+
## Workflow
|
|
30
|
+
|
|
31
|
+
1. Add schema in `schema/<name>.ts`.
|
|
32
|
+
2. Export schema from `schema/index.ts`.
|
|
33
|
+
3. Add runtime parser in `shared/<name>.ts` or `server/<name>.ts`.
|
|
34
|
+
4. Use explicit imports from `@/configs/shared/*` or `@/configs/server/*`.
|
|
35
|
+
|
|
36
|
+
## Review Checklist
|
|
37
|
+
|
|
38
|
+
- New config has schema in `schema/`.
|
|
39
|
+
- `schema/index.ts` is updated.
|
|
40
|
+
- Secret config uses `server-only`.
|
|
41
|
+
- Import boundaries remain explicit and safe.
|
|
42
|
+
|
|
43
|
+
## References
|
|
44
|
+
|
|
45
|
+
- `src/configs/README.md`
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: evm-dapp-standard-coding
|
|
3
|
+
description: Use for any coding task in this repository to enforce layered architecture across src/app, src/ui, src/api, src/hooks, src/configs, src/lib, and src/styles.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# EVM DApp Standard Coding
|
|
7
|
+
|
|
8
|
+
## When To Use This Skill
|
|
9
|
+
|
|
10
|
+
Use this skill for any implementation, refactor, or review task in this repository.
|
|
11
|
+
|
|
12
|
+
## Architecture Contract
|
|
13
|
+
|
|
14
|
+
1. `src/app` is route-entry only.
|
|
15
|
+
2. `src/ui` implements pages and reusable UI.
|
|
16
|
+
3. `src/api` owns request functions.
|
|
17
|
+
4. `src/hooks` is the only client-facing API call layer.
|
|
18
|
+
5. Client components must not request APIs directly.
|
|
19
|
+
6. `src/configs` owns runtime config schema/shared/server boundaries.
|
|
20
|
+
7. `src/lib` is infrastructure and should remain stable.
|
|
21
|
+
8. `src/styles` owns global style entry and CSS import wiring.
|
|
22
|
+
|
|
23
|
+
## Skill Routing
|
|
24
|
+
|
|
25
|
+
- `src/app/**` -> `app-router-conventions`
|
|
26
|
+
- `src/ui/**` -> `ui-conventions`
|
|
27
|
+
- `src/api/**` -> `api-conventions`
|
|
28
|
+
- `src/hooks/**` -> `hooks-conventions`
|
|
29
|
+
- `src/configs/**` -> `configs-conventions`
|
|
30
|
+
- `src/lib/**` -> `lib-infrastructure-conventions`
|
|
31
|
+
- `src/styles/**` -> `styles-conventions`
|
|
32
|
+
|
|
33
|
+
## Standard Workflow
|
|
34
|
+
|
|
35
|
+
1. Identify changed layer(s).
|
|
36
|
+
2. Load matching layer skills and apply hard rules.
|
|
37
|
+
3. Keep naming/export patterns consistent with conventions.
|
|
38
|
+
4. Run checks relevant to the change (`pnpm lint`, `pnpm typecheck`, tests when needed).
|
|
39
|
+
5. Verify no layer boundary violations are introduced.
|
|
40
|
+
|
|
41
|
+
## Definition Of Done
|
|
42
|
+
|
|
43
|
+
- Layer boundaries are preserved.
|
|
44
|
+
- Import paths and file layout follow conventions.
|
|
45
|
+
- No direct client-side network requests are introduced.
|
|
46
|
+
- Infra edits outside `src/lib/utils` or `src/lib/abis` are explicitly justified.
|
|
47
|
+
|
|
48
|
+
## References
|
|
49
|
+
|
|
50
|
+
- `README.md`
|
|
51
|
+
- `src/app/README.md`
|
|
52
|
+
- `src/ui/README.md`
|
|
53
|
+
- `src/api/README.md`
|
|
54
|
+
- `src/hooks/README.md`
|
|
55
|
+
- `src/configs/README.md`
|
|
56
|
+
- `src/lib/README.md`
|
|
57
|
+
- `src/styles/README.md`
|
|
58
|
+
- `references/MIGRATION_GUIDE.md` (Detailed migration playbook for humans and AI tools)
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# Migration Guide (To This Repository Architecture)
|
|
2
|
+
|
|
3
|
+
This guide explains how to quickly migrate a messy project into the layered architecture used in this repository.
|
|
4
|
+
It is designed for both human developers and AI tools.
|
|
5
|
+
|
|
6
|
+
Source of truth:
|
|
7
|
+
- Root architecture doc: `README.md`
|
|
8
|
+
- Layer docs: `src/*/README.md`
|
|
9
|
+
- Executable skills: `.agents/skills/*/SKILL.md`
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## 1. Target Architecture (Required)
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
src/
|
|
17
|
+
app/ # Route entry layer (thin)
|
|
18
|
+
ui/ # Page and component implementation layer
|
|
19
|
+
api/ # Request function layer (query/mutation/types)
|
|
20
|
+
hooks/ # Client-only calling layer (React Query)
|
|
21
|
+
configs/ # Config layer (schema/shared/server)
|
|
22
|
+
lib/ # Infrastructure layer (errors/http/runtime/web3/utils)
|
|
23
|
+
styles/ # Global style entry layer
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Hard boundaries:
|
|
27
|
+
1. Client page components must not request APIs directly.
|
|
28
|
+
2. Components can call data only through `src/hooks`.
|
|
29
|
+
3. `src/hooks` calls `src/api`.
|
|
30
|
+
4. `src/api` must use wrapped request functions only:
|
|
31
|
+
- `apiRequest` for `src/app/api/**`
|
|
32
|
+
- `httpRequest` for non-`src/app/api/**`
|
|
33
|
+
5. `src/app` is route entry only, not page implementation.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 2. Fast Migration Strategy (Recommended)
|
|
38
|
+
|
|
39
|
+
Do not rewrite everything at once. Use **vertical-slice migration + dual track**:
|
|
40
|
+
|
|
41
|
+
1. Build the target structure first, without deleting old logic.
|
|
42
|
+
2. Migrate one business slice at a time (one route/page feature).
|
|
43
|
+
3. New work must go to the new architecture only.
|
|
44
|
+
4. Old code is migration-only (no new features), until fully removed.
|
|
45
|
+
|
|
46
|
+
Benefits:
|
|
47
|
+
- Controlled risk and continuous delivery.
|
|
48
|
+
- Small change sets and clearer regression scope.
|
|
49
|
+
- Consistent execution for both teams and AI tools.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
## 3. Pre-Migration Setup (Day 0)
|
|
54
|
+
|
|
55
|
+
1. Freeze architecture rules: treat `README.md + src/*/README.md + .agents/skills` as the only standard.
|
|
56
|
+
2. Create target folders first: `src/app|ui|api|hooks|configs|lib|styles`.
|
|
57
|
+
3. Enable quality gates in CI: lint/typecheck/test cannot be skipped.
|
|
58
|
+
4. Define no-go zones:
|
|
59
|
+
- No direct client-side API requests.
|
|
60
|
+
- Do not modify `src/lib/common|http|runtime` by default (unless infra-level requirement).
|
|
61
|
+
- Do not manually edit `src/styles/shadcn.css`.
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 4. Single Slice Migration SOP (Core Template)
|
|
66
|
+
|
|
67
|
+
For an old page `legacy/<feature>`, always use this order:
|
|
68
|
+
|
|
69
|
+
1. Route entry migration (`src/app`)
|
|
70
|
+
- Create `src/app/<route>/page.tsx`
|
|
71
|
+
- Keep it as a thin wrapper only:
|
|
72
|
+
- `export default function Page() { return <FeaturePage /> }`
|
|
73
|
+
|
|
74
|
+
2. UI implementation migration (`src/ui/app`)
|
|
75
|
+
- Create `src/ui/app/<route>/index.tsx`
|
|
76
|
+
- Move page UI, interaction, and child components here
|
|
77
|
+
- Use kebab-case for child files (for example `filter-panel.tsx`)
|
|
78
|
+
|
|
79
|
+
3. Request function migration (`src/api`)
|
|
80
|
+
- Create `src/api/<domain>/{query,mutation,types}/`
|
|
81
|
+
- Move request logic out of page/service into `query` or `mutation`
|
|
82
|
+
- Use `@/lib/http/ky` only:
|
|
83
|
+
- `apiRequest` for Next route handlers
|
|
84
|
+
- `httpRequest` for external endpoints
|
|
85
|
+
|
|
86
|
+
4. Hook wrapper migration (`src/hooks/api`)
|
|
87
|
+
- Create `src/hooks/api/<domain>/{query,mutation,types}/`
|
|
88
|
+
- Wrap `src/api` with React Query:
|
|
89
|
+
- `useQuery` for reads
|
|
90
|
+
- `useMutation` for writes
|
|
91
|
+
- Pages call hooks only, never request functions directly
|
|
92
|
+
|
|
93
|
+
5. Config and constants migration (`src/configs`)
|
|
94
|
+
- Put config schema in `schema/`
|
|
95
|
+
- Put client-safe config in `shared/`
|
|
96
|
+
- Put secrets in `server/` with `import 'server-only'`
|
|
97
|
+
|
|
98
|
+
6. Infrastructure dependency check (`src/lib`)
|
|
99
|
+
- Reuse existing infra utilities whenever possible
|
|
100
|
+
- Avoid editing `src/lib/common|http|runtime` unless strictly necessary
|
|
101
|
+
|
|
102
|
+
7. Style migration (`src/styles` + `src/ui`)
|
|
103
|
+
- Keep page styles in the corresponding `src/ui` module
|
|
104
|
+
- Create dedicated global `.css` files and import from `src/styles/index.css`
|
|
105
|
+
- Do not edit `src/styles/shadcn.css`
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## 5. How AI Tools Should Execute
|
|
110
|
+
|
|
111
|
+
### 5.1 Skill Entry
|
|
112
|
+
|
|
113
|
+
Load the global skill first:
|
|
114
|
+
- `.agents/skills/evm-dapp-standard-coding/SKILL.md`
|
|
115
|
+
|
|
116
|
+
Then load layer skill(s) by changed path:
|
|
117
|
+
- `src/app/**` -> `app-router-conventions`
|
|
118
|
+
- `src/ui/**` -> `ui-conventions`
|
|
119
|
+
- `src/api/**` -> `api-conventions`
|
|
120
|
+
- `src/hooks/**` -> `hooks-conventions`
|
|
121
|
+
- `src/configs/**` -> `configs-conventions`
|
|
122
|
+
- `src/lib/**` -> `lib-infrastructure-conventions`
|
|
123
|
+
- `src/styles/**` -> `styles-conventions`
|
|
124
|
+
|
|
125
|
+
### 5.2 Standard Task Prompt For AI
|
|
126
|
+
|
|
127
|
+
```text
|
|
128
|
+
Follow .agents/skills/evm-dapp-standard-coding/SKILL.md.
|
|
129
|
+
Changed paths: <fill paths>.
|
|
130
|
+
You must enforce all corresponding sub-skill rules and keep layer boundaries intact.
|
|
131
|
+
Migration target: move <old module/page> into the app/ui/api/hooks/configs/lib/styles architecture.
|
|
132
|
+
Output:
|
|
133
|
+
1) actual code changes
|
|
134
|
+
2) migration mapping table (old path -> new path)
|
|
135
|
+
3) verification results (lint/typecheck/test)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 6. Migration Scan Commands (Find Common Issues Fast)
|
|
141
|
+
|
|
142
|
+
1. Find direct client requests:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
rg -n "fetch\\(|axios\\(|ky\\(" src/ui src/app
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
2. Find pages using APIs without hooks:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
rg -n "@/api/" src/ui src/app
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
3. Find overweight route files (line-count heuristic):
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
find src/app -type f \\( -name "page.tsx" -o -name "layout.tsx" \\) -print0 | xargs -0 wc -l | sort -nr
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
4. Find server-config boundary violations:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
rg -n "@/configs/server/" src/ui src/hooks src/app
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## 7. Definition Of Done (DoD)
|
|
169
|
+
|
|
170
|
+
A migrated business slice is complete only if all conditions are met:
|
|
171
|
+
|
|
172
|
+
1. Route layer is thin and UI is in `src/ui/app`.
|
|
173
|
+
2. Request functions are in `src/api` and organized by `query/mutation/types`.
|
|
174
|
+
3. Pages use `src/hooks`; no direct client requests exist.
|
|
175
|
+
4. Config is split by `schema/shared/server` with correct boundaries.
|
|
176
|
+
5. No unnecessary infra-core changes in `src/lib`.
|
|
177
|
+
6. Style changes follow `src/styles/index.css` import-entry rules.
|
|
178
|
+
7. `pnpm lint`, `pnpm typecheck`, and required tests pass.
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 8. Common Failure Modes And Fixes
|
|
183
|
+
|
|
184
|
+
1. Failure: business logic inside `src/app/page.tsx`
|
|
185
|
+
- Fix: move it to `src/ui/app/<route>/index.tsx`; keep `src/app` as wrapper only.
|
|
186
|
+
|
|
187
|
+
2. Failure: page directly uses `fetch`/`ky`
|
|
188
|
+
- Fix: move request to `src/api`, then expose via `src/hooks`.
|
|
189
|
+
|
|
190
|
+
3. Failure: `src/api` not split by `query/mutation/types`
|
|
191
|
+
- Fix: reorganize by domain and add barrel exports (`index.ts`).
|
|
192
|
+
|
|
193
|
+
4. Failure: secret config placed in `shared`
|
|
194
|
+
- Fix: move to `src/configs/server` and add `server-only`.
|
|
195
|
+
|
|
196
|
+
5. Failure: arbitrary edits in `src/lib/common|http|runtime`
|
|
197
|
+
- Fix: revert to existing infra patterns; change only for explicit infra requirements.
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## 9. Recommended Migration Order (Best Cost/Benefit)
|
|
202
|
+
|
|
203
|
+
1. High-traffic pages (highest business impact)
|
|
204
|
+
2. Highly reused components (reduce duplicate migration effort)
|
|
205
|
+
3. Most chaotic data domains (clean boundaries earlier)
|
|
206
|
+
4. Config and infra consolidation (last, lower risk)
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## 10. References
|
|
211
|
+
|
|
212
|
+
- `README.md`
|
|
213
|
+
- `src/app/README.md`
|
|
214
|
+
- `src/ui/README.md`
|
|
215
|
+
- `src/api/README.md`
|
|
216
|
+
- `src/hooks/README.md`
|
|
217
|
+
- `src/configs/README.md`
|
|
218
|
+
- `src/lib/README.md`
|
|
219
|
+
- `src/styles/README.md`
|
|
220
|
+
- `.agents/skills/*/SKILL.md`
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: hooks-conventions
|
|
3
|
+
description: Use when building src/hooks hooks, especially src/hooks/api React Query wrappers mapped to src/api domains.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Hooks Conventions
|
|
7
|
+
|
|
8
|
+
## Scope
|
|
9
|
+
|
|
10
|
+
Applies to `src/hooks/**`.
|
|
11
|
+
|
|
12
|
+
## Structure Rules
|
|
13
|
+
|
|
14
|
+
1. `src/hooks/api` mirrors `src/api` domains and subfolders.
|
|
15
|
+
2. Query hooks live in `query/` and use `useQuery`.
|
|
16
|
+
3. Mutation hooks live in `mutation/` and use `useMutation`.
|
|
17
|
+
4. Hook-level helper types live in `types/` when needed.
|
|
18
|
+
5. Use `index.ts` barrels for folder and domain exports.
|
|
19
|
+
|
|
20
|
+
## Hard Boundary Rule
|
|
21
|
+
|
|
22
|
+
Client components must call APIs through hooks only.
|
|
23
|
+
|
|
24
|
+
Not allowed:
|
|
25
|
+
|
|
26
|
+
- Direct `fetch`/`ky` usage in client components.
|
|
27
|
+
- Calling route handlers directly from components.
|
|
28
|
+
|
|
29
|
+
## Non-API Hooks
|
|
30
|
+
|
|
31
|
+
Other hooks should be grouped by function/business categories under `src/hooks`.
|
|
32
|
+
Current base architecture does not provide non-API folder examples.
|
|
33
|
+
|
|
34
|
+
## Workflow
|
|
35
|
+
|
|
36
|
+
1. Confirm API function exists in `src/api/<domain>/query|mutation`.
|
|
37
|
+
2. Create corresponding hook in `src/hooks/api/<domain>/query|mutation`.
|
|
38
|
+
3. Use stable `queryKey` design for queries.
|
|
39
|
+
4. Add invalidation/update behavior for mutations.
|
|
40
|
+
5. Export through local and domain `index.ts`.
|
|
41
|
+
|
|
42
|
+
## Review Checklist
|
|
43
|
+
|
|
44
|
+
- Hook path mirrors API path.
|
|
45
|
+
- Query and mutation hooks use proper React Query primitives.
|
|
46
|
+
- `index.ts` barrels are updated.
|
|
47
|
+
- Client code consumes hooks instead of direct request calls.
|
|
48
|
+
- Non-API hooks (if added) are categorized clearly.
|
|
49
|
+
|
|
50
|
+
## References
|
|
51
|
+
|
|
52
|
+
- `src/hooks/README.md`
|
|
53
|
+
- `src/api/README.md`
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lib-infrastructure-conventions
|
|
3
|
+
description: Use when modifying src/lib infrastructure modules, request/error/runtime wiring, utility helpers, or ABI assets.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Lib Infrastructure Conventions
|
|
7
|
+
|
|
8
|
+
## Scope
|
|
9
|
+
|
|
10
|
+
Applies to `src/lib/**`.
|
|
11
|
+
|
|
12
|
+
## Key Directories
|
|
13
|
+
|
|
14
|
+
- `abis/`: contract ABI assets.
|
|
15
|
+
- `common/errors`: error model and typed errors.
|
|
16
|
+
- `common/web3`: wagmi config and EVM store.
|
|
17
|
+
- `http`: `apiRequest/httpRequest`, `withResponse`, React Query client.
|
|
18
|
+
- `runtime`: store/listener initialization.
|
|
19
|
+
- `utils`: pure utility helpers.
|
|
20
|
+
|
|
21
|
+
## Hard Modification Policy
|
|
22
|
+
|
|
23
|
+
By default, only `src/lib/utils/**` and `src/lib/abis/**` should be modified.
|
|
24
|
+
|
|
25
|
+
For `src/lib/common/**`, `src/lib/http/**`, and `src/lib/runtime/**`:
|
|
26
|
+
|
|
27
|
+
- Treat as foundational infrastructure.
|
|
28
|
+
- Change only for explicit new cross-layer business requirements.
|
|
29
|
+
- Keep edits minimal and validate broad impact.
|
|
30
|
+
|
|
31
|
+
## Usage Rules
|
|
32
|
+
|
|
33
|
+
1. API layer transport should use `@/lib/http/ky` wrappers.
|
|
34
|
+
2. Next route handlers should use `withResponse` from `@/lib/http/next`.
|
|
35
|
+
3. Shared errors should prefer `BaseError` hierarchy.
|
|
36
|
+
4. Runtime initialization should go through `runtime/*` initializers.
|
|
37
|
+
|
|
38
|
+
## Workflow
|
|
39
|
+
|
|
40
|
+
1. If change is utility-like, prefer `utils/`.
|
|
41
|
+
2. If change is ABI-like, use `abis/`.
|
|
42
|
+
3. If infra core must change, document reason and verify behavior across API/hooks/ui.
|
|
43
|
+
4. Add or update tests for non-trivial utility logic.
|
|
44
|
+
|
|
45
|
+
## Review Checklist
|
|
46
|
+
|
|
47
|
+
- Edit location respects modification policy.
|
|
48
|
+
- Transport/error/response wiring stays consistent.
|
|
49
|
+
- Infra-core changes (if any) are justified and scoped.
|
|
50
|
+
- Utility changes include tests when regression risk exists.
|
|
51
|
+
|
|
52
|
+
## References
|
|
53
|
+
|
|
54
|
+
- `src/lib/README.md`
|
|
55
|
+
- `src/api/README.md`
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: styles-conventions
|
|
3
|
+
description: Use when adding global styles, font setup, or CSS imports under src/styles.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Styles Conventions
|
|
7
|
+
|
|
8
|
+
## Scope
|
|
9
|
+
|
|
10
|
+
Applies to `src/styles/**`.
|
|
11
|
+
|
|
12
|
+
## Hard Rules
|
|
13
|
+
|
|
14
|
+
1. Do not manually modify `src/styles/shadcn.css`.
|
|
15
|
+
2. Configure fonts through `src/styles/fonts.ts`.
|
|
16
|
+
3. For custom CSS, create a new `.css` file in `src/styles`.
|
|
17
|
+
4. Import custom style files from `src/styles/index.css`.
|
|
18
|
+
|
|
19
|
+
Example:
|
|
20
|
+
|
|
21
|
+
```css
|
|
22
|
+
@import "./scrollbar.css";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Workflow
|
|
26
|
+
|
|
27
|
+
1. Add dedicated style file for new global behavior.
|
|
28
|
+
2. Keep style concerns separated by file purpose.
|
|
29
|
+
3. Wire file through `index.css` import list.
|
|
30
|
+
4. Avoid mixing framework base styles and custom app styles.
|
|
31
|
+
|
|
32
|
+
## Review Checklist
|
|
33
|
+
|
|
34
|
+
- `shadcn.css` is unchanged.
|
|
35
|
+
- Font changes are in `fonts.ts`.
|
|
36
|
+
- New CSS is added in a dedicated file.
|
|
37
|
+
- New CSS file is imported by `index.css`.
|
|
38
|
+
|
|
39
|
+
## References
|
|
40
|
+
|
|
41
|
+
- `src/styles/README.md`
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ui-conventions
|
|
3
|
+
description: Use when implementing or refactoring src/ui page modules, shared components, providers, shadcn wrappers, or SVG components.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# UI Conventions
|
|
7
|
+
|
|
8
|
+
## Scope
|
|
9
|
+
|
|
10
|
+
Applies to `src/ui/**`.
|
|
11
|
+
|
|
12
|
+
## Structure Rules
|
|
13
|
+
|
|
14
|
+
1. `src/ui/app` mirrors `src/app` route structure.
|
|
15
|
+
2. Page implementation entry file is `index.tsx` in each route folder.
|
|
16
|
+
3. Internal child files use lowercase kebab-case (for example `server-config.tsx`).
|
|
17
|
+
4. Shared route layout components live in `src/ui/app/layout`.
|
|
18
|
+
5. Route-group-local layout components may live in route-local `layout/` folders.
|
|
19
|
+
|
|
20
|
+
## Component Authoring Rules
|
|
21
|
+
|
|
22
|
+
Default component declaration style:
|
|
23
|
+
|
|
24
|
+
```tsx
|
|
25
|
+
export const Loader: FC<ComponentProps<'div'>> = () => {}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Hard constraints:
|
|
29
|
+
|
|
30
|
+
- Except `src/ui/svgs/**`, components should not consume `props`/`className` by default.
|
|
31
|
+
- For non-`svgs` components, keep empty parameter signatures unless explicitly required.
|
|
32
|
+
- Treat `src/ui/shadcn/**` as vendor-like primitives; avoid edits unless necessary.
|
|
33
|
+
|
|
34
|
+
## Workflow
|
|
35
|
+
|
|
36
|
+
1. Implement real pages under `src/ui/app/<route>/index.tsx`.
|
|
37
|
+
2. Keep mapping with `src/app/<route>/page.tsx`.
|
|
38
|
+
3. Put shared/global pieces under `components/providers` or `components/shared`.
|
|
39
|
+
4. Place modal-specific code under `components/modal`.
|
|
40
|
+
|
|
41
|
+
## Review Checklist
|
|
42
|
+
|
|
43
|
+
- Route UI entry files use `index.tsx`.
|
|
44
|
+
- Internal file names follow kebab-case.
|
|
45
|
+
- Non-`svgs` components avoid `props`/`className` by default.
|
|
46
|
+
- `shadcn` components are not modified without a clear reason.
|
|
47
|
+
|
|
48
|
+
## References
|
|
49
|
+
|
|
50
|
+
- `src/ui/README.md`
|
|
51
|
+
- `src/app/README.md`
|