forgecraft-mcp 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 +251 -0
- package/dist/analyzers/anti-pattern.d.ts +21 -0
- package/dist/analyzers/anti-pattern.d.ts.map +1 -0
- package/dist/analyzers/anti-pattern.js +130 -0
- package/dist/analyzers/anti-pattern.js.map +1 -0
- package/dist/analyzers/completeness.d.ts +15 -0
- package/dist/analyzers/completeness.d.ts.map +1 -0
- package/dist/analyzers/completeness.js +207 -0
- package/dist/analyzers/completeness.js.map +1 -0
- package/dist/analyzers/folder-structure.d.ts +35 -0
- package/dist/analyzers/folder-structure.d.ts.map +1 -0
- package/dist/analyzers/folder-structure.js +151 -0
- package/dist/analyzers/folder-structure.js.map +1 -0
- package/dist/analyzers/package-json.d.ts +22 -0
- package/dist/analyzers/package-json.d.ts.map +1 -0
- package/dist/analyzers/package-json.js +229 -0
- package/dist/analyzers/package-json.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/registry/composer.d.ts +32 -0
- package/dist/registry/composer.d.ts.map +1 -0
- package/dist/registry/composer.js +169 -0
- package/dist/registry/composer.js.map +1 -0
- package/dist/registry/loader.d.ts +37 -0
- package/dist/registry/loader.d.ts.map +1 -0
- package/dist/registry/loader.js +278 -0
- package/dist/registry/loader.js.map +1 -0
- package/dist/registry/renderer.d.ts +53 -0
- package/dist/registry/renderer.d.ts.map +1 -0
- package/dist/registry/renderer.js +275 -0
- package/dist/registry/renderer.js.map +1 -0
- package/dist/shared/config/index.d.ts +15 -0
- package/dist/shared/config/index.d.ts.map +1 -0
- package/dist/shared/config/index.js +16 -0
- package/dist/shared/config/index.js.map +1 -0
- package/dist/shared/errors/index.d.ts +30 -0
- package/dist/shared/errors/index.d.ts.map +1 -0
- package/dist/shared/errors/index.js +44 -0
- package/dist/shared/errors/index.js.map +1 -0
- package/dist/shared/logger/index.d.ts +27 -0
- package/dist/shared/logger/index.d.ts.map +1 -0
- package/dist/shared/logger/index.js +59 -0
- package/dist/shared/logger/index.js.map +1 -0
- package/dist/shared/types.d.ts +212 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +30 -0
- package/dist/shared/types.js.map +1 -0
- package/dist/tools/add-hook.d.ts +26 -0
- package/dist/tools/add-hook.d.ts.map +1 -0
- package/dist/tools/add-hook.js +82 -0
- package/dist/tools/add-hook.js.map +1 -0
- package/dist/tools/add-module.d.ts +29 -0
- package/dist/tools/add-module.d.ts.map +1 -0
- package/dist/tools/add-module.js +244 -0
- package/dist/tools/add-module.js.map +1 -0
- package/dist/tools/audit.d.ts +26 -0
- package/dist/tools/audit.d.ts.map +1 -0
- package/dist/tools/audit.js +111 -0
- package/dist/tools/audit.js.map +1 -0
- package/dist/tools/classify.d.ts +23 -0
- package/dist/tools/classify.d.ts.map +1 -0
- package/dist/tools/classify.js +73 -0
- package/dist/tools/classify.js.map +1 -0
- package/dist/tools/configure-mcp.d.ts +49 -0
- package/dist/tools/configure-mcp.d.ts.map +1 -0
- package/dist/tools/configure-mcp.js +127 -0
- package/dist/tools/configure-mcp.js.map +1 -0
- package/dist/tools/convert.d.ts +27 -0
- package/dist/tools/convert.d.ts.map +1 -0
- package/dist/tools/convert.js +154 -0
- package/dist/tools/convert.js.map +1 -0
- package/dist/tools/generate-claude-md.d.ts +29 -0
- package/dist/tools/generate-claude-md.d.ts.map +1 -0
- package/dist/tools/generate-claude-md.js +116 -0
- package/dist/tools/generate-claude-md.js.map +1 -0
- package/dist/tools/get-nfr.d.ts +20 -0
- package/dist/tools/get-nfr.d.ts.map +1 -0
- package/dist/tools/get-nfr.js +53 -0
- package/dist/tools/get-nfr.js.map +1 -0
- package/dist/tools/list.d.ts +33 -0
- package/dist/tools/list.d.ts.map +1 -0
- package/dist/tools/list.js +155 -0
- package/dist/tools/list.js.map +1 -0
- package/dist/tools/refresh-project.d.ts +34 -0
- package/dist/tools/refresh-project.d.ts.map +1 -0
- package/dist/tools/refresh-project.js +257 -0
- package/dist/tools/refresh-project.js.map +1 -0
- package/dist/tools/review.d.ts +31 -0
- package/dist/tools/review.d.ts.map +1 -0
- package/dist/tools/review.js +62 -0
- package/dist/tools/review.js.map +1 -0
- package/dist/tools/scaffold.d.ts +32 -0
- package/dist/tools/scaffold.d.ts.map +1 -0
- package/dist/tools/scaffold.js +160 -0
- package/dist/tools/scaffold.js.map +1 -0
- package/dist/tools/setup-project.d.ts +37 -0
- package/dist/tools/setup-project.d.ts.map +1 -0
- package/dist/tools/setup-project.js +270 -0
- package/dist/tools/setup-project.js.map +1 -0
- package/package.json +69 -0
- package/templates/analytics/claude-md.yaml +37 -0
- package/templates/analytics/structure.yaml +25 -0
- package/templates/api/claude-md.yaml +85 -0
- package/templates/api/nfr.yaml +23 -0
- package/templates/api/review.yaml +103 -0
- package/templates/api/structure.yaml +34 -0
- package/templates/cli/claude-md.yaml +31 -0
- package/templates/cli/review.yaml +53 -0
- package/templates/cli/structure.yaml +16 -0
- package/templates/data-pipeline/claude-md.yaml +42 -0
- package/templates/data-pipeline/nfr.yaml +39 -0
- package/templates/data-pipeline/structure.yaml +23 -0
- package/templates/fintech/claude-md.yaml +42 -0
- package/templates/fintech/nfr.yaml +46 -0
- package/templates/game/claude-md.yaml +42 -0
- package/templates/healthcare/claude-md.yaml +42 -0
- package/templates/healthcare/nfr.yaml +47 -0
- package/templates/infra/claude-md.yaml +104 -0
- package/templates/infra/nfr.yaml +46 -0
- package/templates/infra/review.yaml +65 -0
- package/templates/infra/structure.yaml +25 -0
- package/templates/library/claude-md.yaml +36 -0
- package/templates/library/review.yaml +56 -0
- package/templates/library/structure.yaml +19 -0
- package/templates/ml/claude-md.yaml +42 -0
- package/templates/ml/nfr.yaml +39 -0
- package/templates/ml/structure.yaml +25 -0
- package/templates/mobile/claude-md.yaml +44 -0
- package/templates/mobile/nfr.yaml +49 -0
- package/templates/mobile/structure.yaml +27 -0
- package/templates/realtime/claude-md.yaml +42 -0
- package/templates/social/claude-md.yaml +43 -0
- package/templates/state-machine/claude-md.yaml +42 -0
- package/templates/universal/claude-md.yaml +477 -0
- package/templates/universal/hooks.yaml +196 -0
- package/templates/universal/nfr.yaml +197 -0
- package/templates/universal/review.yaml +164 -0
- package/templates/universal/structure.yaml +52 -0
- package/templates/web-react/claude-md.yaml +110 -0
- package/templates/web-react/hooks.yaml +44 -0
- package/templates/web-react/nfr.yaml +27 -0
- package/templates/web-react/review.yaml +94 -0
- package/templates/web-react/structure.yaml +46 -0
- package/templates/web-static/claude-md.yaml +73 -0
- package/templates/web3/claude-md.yaml +44 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
tag: WEB-REACT
|
|
2
|
+
section: review
|
|
3
|
+
blocks:
|
|
4
|
+
- id: react-architecture-review
|
|
5
|
+
tier: recommended
|
|
6
|
+
dimension: architecture
|
|
7
|
+
title: "React Architecture Review"
|
|
8
|
+
description: |
|
|
9
|
+
Evaluate component hierarchy, state management, and rendering patterns.
|
|
10
|
+
checklist:
|
|
11
|
+
- id: component-hierarchy
|
|
12
|
+
description: "Atomic Design followed: atoms → molecules → organisms → templates → pages."
|
|
13
|
+
severity: important
|
|
14
|
+
- id: component-purity
|
|
15
|
+
description: "Components are pure UI. No API calls or business logic inside components."
|
|
16
|
+
severity: critical
|
|
17
|
+
- id: state-management
|
|
18
|
+
description: "State management follows hierarchy: local → context → global store. No prop drilling > 2 levels."
|
|
19
|
+
severity: important
|
|
20
|
+
- id: route-structure
|
|
21
|
+
description: "Routes organized by feature. Lazy loading for non-critical routes."
|
|
22
|
+
severity: nice-to-have
|
|
23
|
+
|
|
24
|
+
- id: react-code-quality-review
|
|
25
|
+
tier: recommended
|
|
26
|
+
dimension: code-quality
|
|
27
|
+
title: "React Code Quality Review"
|
|
28
|
+
description: |
|
|
29
|
+
Evaluate component patterns, hooks usage, and i18n compliance.
|
|
30
|
+
checklist:
|
|
31
|
+
- id: i18n-compliance
|
|
32
|
+
description: "Every user-facing string goes through the i18n system. No hardcoded text in JSX."
|
|
33
|
+
severity: critical
|
|
34
|
+
- id: accessibility
|
|
35
|
+
description: "WCAG 2.1 AA compliance: semantic HTML, ARIA labels, keyboard navigation, focus management."
|
|
36
|
+
severity: critical
|
|
37
|
+
- id: hooks-patterns
|
|
38
|
+
description: "Custom hooks extract reusable logic. No complex useEffect chains. Dependencies arrays are correct."
|
|
39
|
+
severity: important
|
|
40
|
+
- id: key-props
|
|
41
|
+
description: "List renderings use stable, unique keys. No array index as key for dynamic lists."
|
|
42
|
+
severity: important
|
|
43
|
+
- id: error-boundaries
|
|
44
|
+
description: "Feature areas wrapped in Error Boundaries. Crash in one widget doesn’t take down the page."
|
|
45
|
+
severity: critical
|
|
46
|
+
- id: suspense-loading
|
|
47
|
+
description: "Every async operation has loading, success, and error states. No blank screens. Skeleton loaders for layout stability."
|
|
48
|
+
severity: important
|
|
49
|
+
|
|
50
|
+
- id: react-performance-review
|
|
51
|
+
tier: recommended
|
|
52
|
+
dimension: performance
|
|
53
|
+
title: "React Performance Review"
|
|
54
|
+
description: |
|
|
55
|
+
Evaluate rendering efficiency, bundle size, and lazy loading.
|
|
56
|
+
checklist:
|
|
57
|
+
- id: unnecessary-rerenders
|
|
58
|
+
description: "No unnecessary re-renders. React.memo, useMemo, useCallback used where measurably impactful."
|
|
59
|
+
severity: important
|
|
60
|
+
- id: bundle-size
|
|
61
|
+
description: "Bundle size monitored. No full-library imports (use tree-shakeable named imports)."
|
|
62
|
+
severity: important
|
|
63
|
+
- id: image-optimization
|
|
64
|
+
description: "Images optimized: lazy loading, responsive srcset, modern formats (WebP/AVIF)."
|
|
65
|
+
severity: nice-to-have
|
|
66
|
+
- id: core-web-vitals
|
|
67
|
+
description: "Core Web Vitals tracked: LCP < 2.5s, FID < 100ms, CLS < 0.1."
|
|
68
|
+
severity: important
|
|
69
|
+
- id: bundle-budget
|
|
70
|
+
description: "JavaScript bundle within budget. Initial load under 200 KB compressed. Lighthouse CI enforced in pipeline."
|
|
71
|
+
severity: important
|
|
72
|
+
- id: preview-deployments
|
|
73
|
+
description: "PR preview deployments enabled. URL posted in PR comments for stakeholder review."
|
|
74
|
+
severity: nice-to-have
|
|
75
|
+
- id: cache-headers
|
|
76
|
+
description: "Hashed assets use immutable cache headers. HTML uses short-lived cache with stale-while-revalidate."
|
|
77
|
+
severity: important
|
|
78
|
+
|
|
79
|
+
- id: react-test-review
|
|
80
|
+
tier: recommended
|
|
81
|
+
dimension: tests
|
|
82
|
+
title: "React Test Review"
|
|
83
|
+
description: |
|
|
84
|
+
Evaluate React-specific testing patterns.
|
|
85
|
+
checklist:
|
|
86
|
+
- id: error-boundary-coverage
|
|
87
|
+
description: "Error boundaries tested: verify fallback UI renders on component errors. Error reporting verified."
|
|
88
|
+
severity: important
|
|
89
|
+
- id: loading-error-states
|
|
90
|
+
description: "All async operations tested in three states: loading, success, error. No untested blank screens."
|
|
91
|
+
severity: critical
|
|
92
|
+
- id: user-interaction-tests
|
|
93
|
+
description: "Key user flows tested via integration tests (Testing Library). Tests interact as a user would, not via implementation details."
|
|
94
|
+
severity: critical
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
tag: WEB-REACT
|
|
2
|
+
section: structure
|
|
3
|
+
language: typescript
|
|
4
|
+
entries:
|
|
5
|
+
- path: src/app
|
|
6
|
+
type: directory
|
|
7
|
+
description: "App shell, providers, router config"
|
|
8
|
+
- path: src/app/App.tsx
|
|
9
|
+
type: file
|
|
10
|
+
description: "Root component with providers"
|
|
11
|
+
- path: src/app/router.tsx
|
|
12
|
+
type: file
|
|
13
|
+
description: "ALL routes defined here as config"
|
|
14
|
+
- path: src/app/providers
|
|
15
|
+
type: directory
|
|
16
|
+
description: "Context providers (auth, theme, i18n)"
|
|
17
|
+
- path: src/app/layouts
|
|
18
|
+
type: directory
|
|
19
|
+
description: "Layout components (sidebar, header, etc.)"
|
|
20
|
+
- path: src/features
|
|
21
|
+
type: directory
|
|
22
|
+
description: "Feature modules (self-contained)"
|
|
23
|
+
- path: src/shared/api
|
|
24
|
+
type: directory
|
|
25
|
+
description: "Centralized API client"
|
|
26
|
+
- path: src/shared/components
|
|
27
|
+
type: directory
|
|
28
|
+
description: "Reusable UI components (atoms, molecules)"
|
|
29
|
+
- path: src/shared/hooks
|
|
30
|
+
type: directory
|
|
31
|
+
description: "Shared hooks (useDebounce, useMediaQuery, etc.)"
|
|
32
|
+
- path: src/shared/config
|
|
33
|
+
type: directory
|
|
34
|
+
description: "Nav config, env access, constants"
|
|
35
|
+
- path: src/locales
|
|
36
|
+
type: directory
|
|
37
|
+
description: "i18n translation files"
|
|
38
|
+
- path: src/locales/en
|
|
39
|
+
type: directory
|
|
40
|
+
description: "English translations"
|
|
41
|
+
- path: src/styles
|
|
42
|
+
type: directory
|
|
43
|
+
description: "Global styles, theme, tokens"
|
|
44
|
+
- path: tests/e2e
|
|
45
|
+
type: directory
|
|
46
|
+
description: "Playwright tests"
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
tag: WEB-STATIC
|
|
2
|
+
section: claude-md
|
|
3
|
+
blocks:
|
|
4
|
+
- id: static-site-architecture
|
|
5
|
+
tier: recommended
|
|
6
|
+
title: "Static Site Architecture"
|
|
7
|
+
content: |
|
|
8
|
+
## Static Site & Jamstack Patterns
|
|
9
|
+
|
|
10
|
+
- Use Static Site Generation (SSG) as the default rendering strategy; reserve SSR or ISR only for pages requiring dynamic data at request time.
|
|
11
|
+
- Pre-render all content pages at build time. Ensure the build pipeline fails fast on broken links, missing assets, or template errors.
|
|
12
|
+
- Separate content from presentation: store structured content in Markdown, MDX, or a headless CMS, and consume it via build-time data fetching.
|
|
13
|
+
- Implement incremental builds where supported to keep build times under 60 seconds for content-heavy sites.
|
|
14
|
+
- Use content hashing for all emitted assets (JS, CSS, images) to enable aggressive, immutable caching (`Cache-Control: public, max-age=31536000, immutable`).
|
|
15
|
+
- Serve the site behind a CDN. Configure cache invalidation on deploy so users never see stale HTML entry points.
|
|
16
|
+
- Generate a `sitemap.xml` and `robots.txt` at build time. Include canonical URLs and Open Graph meta tags on every page.
|
|
17
|
+
- Keep JavaScript payload minimal. Audit bundle size on every PR; set a performance budget (e.g., < 100 KB compressed JS for the critical path).
|
|
18
|
+
|
|
19
|
+
- id: asset-optimization
|
|
20
|
+
tier: recommended
|
|
21
|
+
title: "Asset Optimization"
|
|
22
|
+
content: |
|
|
23
|
+
## Asset Optimization & Performance
|
|
24
|
+
|
|
25
|
+
- Serve images in modern formats (WebP/AVIF) with `<picture>` fallbacks. Use responsive `srcset` and `sizes` attributes to deliver appropriately sized images.
|
|
26
|
+
- Inline critical CSS for above-the-fold content and defer non-critical stylesheets. Avoid render-blocking resources.
|
|
27
|
+
- Enable Brotli or gzip compression on the CDN/server for all text-based assets (HTML, CSS, JS, SVG, JSON).
|
|
28
|
+
- Lazy-load below-the-fold images and iframes using `loading="lazy"` or Intersection Observer.
|
|
29
|
+
- Preload key resources (`<link rel="preload">`) such as fonts and hero images. Use `font-display: swap` to prevent FOIT.
|
|
30
|
+
- Minimize third-party scripts. Load analytics and tracking asynchronously and after the main content is interactive.
|
|
31
|
+
- Run Lighthouse CI in the build pipeline; fail the build if performance score drops below the agreed threshold (e.g., 90).
|
|
32
|
+
|
|
33
|
+
- id: html-css-best-practices
|
|
34
|
+
tier: recommended
|
|
35
|
+
title: "HTML & CSS Best Practices"
|
|
36
|
+
content: |
|
|
37
|
+
## HTML & CSS Quality Standards
|
|
38
|
+
|
|
39
|
+
- Write semantic HTML5 markup. Use `<header>`, `<nav>`, `<main>`, `<article>`, `<section>`, and `<footer>` to convey document structure.
|
|
40
|
+
- Ensure all pages pass WCAG 2.1 AA. Provide alt text for images, proper heading hierarchy, sufficient color contrast, and keyboard navigability.
|
|
41
|
+
- Use CSS custom properties (variables) for theming. Maintain a design-token file as the single source of truth for colors, spacing, and typography.
|
|
42
|
+
- Prefer utility-first or modular CSS methodologies (e.g., Tailwind, CSS Modules) to avoid specificity conflicts and dead CSS accumulation.
|
|
43
|
+
- Validate HTML output with the W3C validator in CI. Fix all errors; treat warnings as errors in new code.
|
|
44
|
+
- Support dark mode via `prefers-color-scheme` media query or a user-togglable theme that persists in `localStorage`.
|
|
45
|
+
|
|
46
|
+
- id: static-deployment
|
|
47
|
+
tier: recommended
|
|
48
|
+
title: "Static Site Deployment"
|
|
49
|
+
content: |
|
|
50
|
+
## Static Site Deployment
|
|
51
|
+
|
|
52
|
+
### Platforms
|
|
53
|
+
- **Netlify**: Git-push deploy, instant rollbacks, form handling, edge functions, split testing.
|
|
54
|
+
Free tier generous for static sites. Build plugins for Lighthouse, broken link detection.
|
|
55
|
+
- **Vercel**: Zero-config for Next.js/Astro/SvelteKit. Preview deployments per PR.
|
|
56
|
+
- **Cloudflare Pages**: Unlimited bandwidth, global edge network, Pages Functions for dynamic routes.
|
|
57
|
+
- **GitHub Pages**: Free for open-source. Limited (no server functions, no redirects file natively).
|
|
58
|
+
Suitable for docs sites and project landing pages only.
|
|
59
|
+
- **AWS S3 + CloudFront**: Maximum control, lowest cost at scale. Use `aws-cdk` or Terraform
|
|
60
|
+
to define the stack: S3 bucket (private) → CloudFront distribution → Route53 DNS → ACM cert.
|
|
61
|
+
|
|
62
|
+
### Build Pipeline
|
|
63
|
+
- Build locally mirrors CI exactly (same Node version, same env vars). Use `.nvmrc` or `.node-version`.
|
|
64
|
+
- Build output is a static directory (`dist/`, `out/`, `public/`). No server process.
|
|
65
|
+
- Atomic deploys: new version fully uploaded before traffic switches. No partial states.
|
|
66
|
+
- Rollback = redeploy previous build artifact. Must complete in < 30 seconds.
|
|
67
|
+
|
|
68
|
+
### Cache Strategy
|
|
69
|
+
- HTML: `Cache-Control: public, max-age=300, stale-while-revalidate=86400`.
|
|
70
|
+
Short-lived so deploys take effect quickly.
|
|
71
|
+
- Hashed assets (JS, CSS, images): `Cache-Control: public, max-age=31536000, immutable`.
|
|
72
|
+
Filename changes on content change — cache forever.
|
|
73
|
+
- Invalidate CDN cache on deploy (automatic on Netlify/Vercel/CF Pages; manual on CloudFront).
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
tag: WEB3
|
|
2
|
+
section: claude-md
|
|
3
|
+
blocks:
|
|
4
|
+
- id: smart-contract-patterns
|
|
5
|
+
tier: recommended
|
|
6
|
+
title: "Smart Contract Design"
|
|
7
|
+
content: |
|
|
8
|
+
## Smart Contract Design Patterns
|
|
9
|
+
|
|
10
|
+
- Follow the Checks-Effects-Interactions pattern in every state-mutating function: validate inputs, update state, then make external calls. This prevents reentrancy attacks.
|
|
11
|
+
- Use the proxy pattern (UUPS or Transparent Proxy) for upgradeable contracts. Separate storage layout from logic, and never change the order of existing storage variables.
|
|
12
|
+
- Minimize on-chain storage. Store large data off-chain (IPFS, Arweave) and keep only content hashes on-chain for verification.
|
|
13
|
+
- Emit events for every significant state change. Events are the primary mechanism for off-chain indexers and UIs to track contract activity.
|
|
14
|
+
- Use OpenZeppelin's audited base contracts for standard functionality (ERC-20, ERC-721, ERC-1155, AccessControl, ReentrancyGuard) rather than writing from scratch.
|
|
15
|
+
- Implement access control with role-based patterns. Use multi-sig or timelocks for admin operations to prevent single points of compromise.
|
|
16
|
+
- Write comprehensive Solidity NatSpec comments for every public and external function, including `@param`, `@return`, and `@notice` tags.
|
|
17
|
+
- Target 100% branch coverage in contract tests. Test edge cases: zero values, max uint values, unauthorized callers, reentrancy attempts, and contract self-destruction scenarios.
|
|
18
|
+
|
|
19
|
+
- id: gas-optimization
|
|
20
|
+
tier: recommended
|
|
21
|
+
title: "Gas Optimization"
|
|
22
|
+
content: |
|
|
23
|
+
## Gas Optimization Strategies
|
|
24
|
+
|
|
25
|
+
- Pack struct fields by size to minimize storage slots. Group `uint128` pairs, `bool` clusters, and `address` + smaller types into single 32-byte slots.
|
|
26
|
+
- Use `calldata` instead of `memory` for read-only function parameters in external functions to avoid unnecessary copying.
|
|
27
|
+
- Prefer mappings over arrays for lookups. If iteration is needed, maintain a separate array of keys alongside the mapping.
|
|
28
|
+
- Batch operations where possible: multi-transfer, batch minting, and batch approvals reduce per-transaction overhead.
|
|
29
|
+
- Use custom errors (`error InsufficientBalance(uint256 available, uint256 required)`) instead of `require` strings to save deployment and runtime gas.
|
|
30
|
+
- Cache storage variables in local `memory` or `stack` variables when accessed multiple times within a function.
|
|
31
|
+
- Profile gas usage in tests using Hardhat's gas reporter. Set gas budgets per function and fail CI if a change exceeds the budget.
|
|
32
|
+
|
|
33
|
+
- id: wallet-offchain
|
|
34
|
+
tier: recommended
|
|
35
|
+
title: "Wallet Integration & Off-Chain Patterns"
|
|
36
|
+
content: |
|
|
37
|
+
## Wallet Integration & Off-Chain Architecture
|
|
38
|
+
|
|
39
|
+
- Support multiple wallet providers (MetaMask, WalletConnect, Coinbase Wallet) via a unified connector abstraction. Never hard-code a single provider.
|
|
40
|
+
- Handle chain switching and network mismatch gracefully. Prompt users to switch networks and display clear error messages for unsupported chains.
|
|
41
|
+
- Use EIP-712 typed structured data for off-chain signature requests so users can read and understand what they are signing.
|
|
42
|
+
- Implement an off-chain indexer (The Graph, custom) to serve query-heavy read operations. Never query the blockchain directly from the frontend for list or aggregate views.
|
|
43
|
+
- Design for L2 and multi-chain: abstract chain-specific logic behind an interface so the application can deploy to new chains without rewriting business logic.
|
|
44
|
+
- Validate all inputs on-chain even if they were validated off-chain. Off-chain validation is a UX convenience; on-chain validation is the security boundary.
|