mirror of
https://github.com/luxfi/safe-wallet.git
synced 2026-10-30 15:19:21 +00:00
* chore: split AGENTS.md across the monorepo to fix size warning Root AGENTS.md was 41.7k chars, exceeding agent's 40k performance threshold. Per the agents.md spec for monorepos, split into nested files that agents auto-load from each subtree: - apps/web/AGENTS.md (new): feature architecture, Storybook, web testing, web-specific pitfalls, debugging tips - apps/mobile/AGENTS.md (new): Expo + Tamagui guidance - packages/AGENTS.md (new): shared-package conventions, dual env vars - apps/web/docs/code-style.md: appended Code Complexity Guidelines - apps/mobile/docs/code-style.md: cross-reference to complexity rules - root AGENTS.md: trimmed to cross-cutting rules + Nested guidance index Root drops 41.7k -> 23.8k chars (no warning, ~16k headroom). All content preserved in the new layout; existing nested files (cypress, .storybook) unchanged. README, CLAUDE.md, PR template, and specs/** still reference the (still-existing) root file. * chore: gitignore docs/brainstorms/ like docs/plans/ Brainstorms are local working artifacts, same as plans. Remove the accidentally-committed brainstorm file and prevent future leaks.
2.2 KiB
2.2 KiB
Code Style Guidelines
Cyclomatic-complexity guidelines (lookup tables, early returns, switch for type discrimination, function-length limits) live in
../../web/docs/code-style.mdand apply equally here.
Code Structure
General Components
- Components that are used across multiple features should reside in the
src/components/folder. - Each component should have its own folder, structured as follows:
Alert/ - Alert.tsx - Alert.test.tsx - Alert.stories.tsx - index.tsx - The main component implementation should be in a named file (e.g.,
Alert.tsx), andindex.tsxshould only be used for exporting the component. - Reason: Using
index.tsxallows for cleaner imports, e.g.,instead of:import { Alert } from 'src/components/Alert';import { Alert } from 'src/components/Alert/Alert';
Exporting Components
- Always prefer named exports over default exports.
- Named exports make it easier to refactor and identify exports in a codebase.
Features and Screens
- Feature-specific components and screens should be implemented inside the
src/features/folder.
Example: Feature File Structure
For a feature called Assets, the file structure might look like this:
// src/features/Assets
- Assets.container.tsx
- index.tsx
index.tsxshould only export the Assets component/container.
Subcomponents for Features
- If a feature depends on multiple subcomponents unique to that feature, place them in a
componentssubfolder. For example:
// src/features/Assets/components/AssetHeader
- AssetHeader.tsx
- AssetHeader.container.tsx
- index.tsx
Presentation vs. Container Components
-
Presentation Components:
- Responsible only for rendering the UI.
- Receive data and callbacks via props.
- Avoid direct manipulation of business logic.
- Simple business logic can be included but should generally be extracted into hooks.
-
Container Components:
- Handle business logic (e.g., state management, API calls, etc.).
- Pass necessary data and callbacks to the corresponding Presentation component.