@mindfoldhq/trellis 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/LICENSE +110 -0
- package/README.md +149 -0
- package/bin/trellis.js +3 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +42 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/commands/init.d.ts +11 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +236 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/configurators/claude.d.ts +35 -0
- package/dist/configurators/claude.d.ts.map +1 -0
- package/dist/configurators/claude.js +83 -0
- package/dist/configurators/claude.js.map +1 -0
- package/dist/configurators/cursor.d.ts +8 -0
- package/dist/configurators/cursor.d.ts.map +1 -0
- package/dist/configurators/cursor.js +22 -0
- package/dist/configurators/cursor.js.map +1 -0
- package/dist/configurators/templates.d.ts +40 -0
- package/dist/configurators/templates.d.ts.map +1 -0
- package/dist/configurators/templates.js +67 -0
- package/dist/configurators/templates.js.map +1 -0
- package/dist/configurators/workflow.d.ts +16 -0
- package/dist/configurators/workflow.d.ts.map +1 -0
- package/dist/configurators/workflow.js +169 -0
- package/dist/configurators/workflow.js.map +1 -0
- package/dist/constants/paths.d.ts +69 -0
- package/dist/constants/paths.d.ts.map +1 -0
- package/dist/constants/paths.js +80 -0
- package/dist/constants/paths.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/templates/agents/check.txt +120 -0
- package/dist/templates/agents/debug.txt +121 -0
- package/dist/templates/agents/dispatch.txt +201 -0
- package/dist/templates/agents/implement.txt +114 -0
- package/dist/templates/agents/index.d.ts +35 -0
- package/dist/templates/agents/index.d.ts.map +1 -0
- package/dist/templates/agents/index.js +71 -0
- package/dist/templates/agents/index.js.map +1 -0
- package/dist/templates/agents/research.txt +258 -0
- package/dist/templates/commands/claude/start.md.txt +127 -0
- package/dist/templates/commands/common/before-backend-dev.txt +13 -0
- package/dist/templates/commands/common/before-frontend-dev.txt +13 -0
- package/dist/templates/commands/common/break-loop.txt +107 -0
- package/dist/templates/commands/common/check-backend.txt +13 -0
- package/dist/templates/commands/common/check-cross-layer.txt +153 -0
- package/dist/templates/commands/common/check-frontend.txt +13 -0
- package/dist/templates/commands/common/create-command.txt +154 -0
- package/dist/templates/commands/common/finish-work.txt +129 -0
- package/dist/templates/commands/common/integrate-skill.txt +219 -0
- package/dist/templates/commands/common/onboard-developer.txt +355 -0
- package/dist/templates/commands/common/record-agent-flow.txt +62 -0
- package/dist/templates/commands/cursor/start.md.txt +94 -0
- package/dist/templates/commands/index.d.ts +46 -0
- package/dist/templates/commands/index.d.ts.map +1 -0
- package/dist/templates/commands/index.js +151 -0
- package/dist/templates/commands/index.js.map +1 -0
- package/dist/templates/extract.d.ts +22 -0
- package/dist/templates/extract.d.ts.map +1 -0
- package/dist/templates/extract.js +34 -0
- package/dist/templates/extract.js.map +1 -0
- package/dist/templates/hooks/index.d.ts +33 -0
- package/dist/templates/hooks/index.d.ts.map +1 -0
- package/dist/templates/hooks/index.js +53 -0
- package/dist/templates/hooks/index.js.map +1 -0
- package/dist/templates/hooks/inject-subagent-context.py +620 -0
- package/dist/templates/hooks/settings.json +16 -0
- package/dist/templates/markdown/agent-traces-index.md.txt +124 -0
- package/dist/templates/markdown/agents.md.txt +18 -0
- package/dist/templates/markdown/gitignore.txt +3 -0
- package/dist/templates/markdown/index.d.ts +26 -0
- package/dist/templates/markdown/index.d.ts.map +1 -0
- package/dist/templates/markdown/index.js +33 -0
- package/dist/templates/markdown/index.js.map +1 -0
- package/dist/templates/markdown/init-agent.md.txt +315 -0
- package/dist/templates/markdown/structure/backend/database-guidelines.md.txt +51 -0
- package/dist/templates/markdown/structure/backend/directory-structure.md.txt +54 -0
- package/dist/templates/markdown/structure/backend/error-handling.md.txt +51 -0
- package/dist/templates/markdown/structure/backend/index.md.txt +38 -0
- package/dist/templates/markdown/structure/backend/logging-guidelines.md.txt +51 -0
- package/dist/templates/markdown/structure/backend/quality-guidelines.md.txt +51 -0
- package/dist/templates/markdown/structure/frontend/component-guidelines.md.txt +59 -0
- package/dist/templates/markdown/structure/frontend/directory-structure.md.txt +54 -0
- package/dist/templates/markdown/structure/frontend/hook-guidelines.md.txt +51 -0
- package/dist/templates/markdown/structure/frontend/index.md.txt +39 -0
- package/dist/templates/markdown/structure/frontend/quality-guidelines.md.txt +51 -0
- package/dist/templates/markdown/structure/frontend/state-management.md.txt +51 -0
- package/dist/templates/markdown/structure/frontend/type-safety.md.txt +51 -0
- package/dist/templates/markdown/structure/guides/code-reuse-thinking-guide.md.txt +92 -0
- package/dist/templates/markdown/structure/guides/cross-layer-thinking-guide.md.txt +94 -0
- package/dist/templates/markdown/structure/guides/index.md.txt +79 -0
- package/dist/templates/markdown/workflow.md.txt +335 -0
- package/dist/templates/scripts/add-session.sh.txt +384 -0
- package/dist/templates/scripts/common/developer.sh.txt +130 -0
- package/dist/templates/scripts/common/git-context.sh.txt +237 -0
- package/dist/templates/scripts/common/paths.sh.txt +201 -0
- package/dist/templates/scripts/create-bootstrap.sh.txt +298 -0
- package/dist/templates/scripts/feature.sh.txt +700 -0
- package/dist/templates/scripts/get-context.sh.txt +7 -0
- package/dist/templates/scripts/get-developer.sh.txt +15 -0
- package/dist/templates/scripts/index.d.ts +25 -0
- package/dist/templates/scripts/index.d.ts.map +1 -0
- package/dist/templates/scripts/index.js +28 -0
- package/dist/templates/scripts/index.js.map +1 -0
- package/dist/templates/scripts/init-developer.sh.txt +34 -0
- package/dist/types/ai-tools.d.ts +35 -0
- package/dist/types/ai-tools.d.ts.map +1 -0
- package/dist/types/ai-tools.js +31 -0
- package/dist/types/ai-tools.js.map +1 -0
- package/dist/utils/file-writer.d.ts +23 -0
- package/dist/utils/file-writer.d.ts.map +1 -0
- package/dist/utils/file-writer.js +140 -0
- package/dist/utils/file-writer.js.map +1 -0
- package/dist/utils/project-detector.d.ts +16 -0
- package/dist/utils/project-detector.d.ts.map +1 -0
- package/dist/utils/project-detector.js +186 -0
- package/dist/utils/project-detector.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Backend Development Guidelines
|
|
2
|
+
|
|
3
|
+
> Best practices for backend development in this project.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This directory contains guidelines for backend development. Fill in each file with your project's specific conventions.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Guidelines Index
|
|
14
|
+
|
|
15
|
+
| Guide | Description | Status |
|
|
16
|
+
|-------|-------------|--------|
|
|
17
|
+
| [Directory Structure](./directory-structure.md) | Module organization and file layout | ⬜ To fill |
|
|
18
|
+
| [Database Guidelines](./database-guidelines.md) | ORM patterns, queries, migrations | ⬜ To fill |
|
|
19
|
+
| [Error Handling](./error-handling.md) | Error types, handling strategies | ⬜ To fill |
|
|
20
|
+
| [Quality Guidelines](./quality-guidelines.md) | Code standards, forbidden patterns | ⬜ To fill |
|
|
21
|
+
| [Logging Guidelines](./logging-guidelines.md) | Structured logging, log levels | ⬜ To fill |
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## How to Fill These Guidelines
|
|
26
|
+
|
|
27
|
+
For each guideline file:
|
|
28
|
+
|
|
29
|
+
1. Document your project's **actual conventions** (not ideals)
|
|
30
|
+
2. Include **code examples** from your codebase
|
|
31
|
+
3. List **forbidden patterns** and why
|
|
32
|
+
4. Add **common mistakes** your team has made
|
|
33
|
+
|
|
34
|
+
The goal is to help AI assistants and new team members understand how YOUR project works.
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
**Language**: All documentation should be written in **English**.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Logging Guidelines
|
|
2
|
+
|
|
3
|
+
> How logging is done in this project.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
<!--
|
|
10
|
+
Document your project's logging conventions here.
|
|
11
|
+
|
|
12
|
+
Questions to answer:
|
|
13
|
+
- What logging library do you use?
|
|
14
|
+
- What log levels are available?
|
|
15
|
+
- What context should be included in logs?
|
|
16
|
+
- Where are logs stored/shipped?
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
(To be filled by the team)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Log Levels
|
|
24
|
+
|
|
25
|
+
<!-- When to use each log level -->
|
|
26
|
+
|
|
27
|
+
(To be filled by the team)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Log Format
|
|
32
|
+
|
|
33
|
+
<!-- Structure of log messages -->
|
|
34
|
+
|
|
35
|
+
(To be filled by the team)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## What to Log
|
|
40
|
+
|
|
41
|
+
<!-- Events that should always be logged -->
|
|
42
|
+
|
|
43
|
+
(To be filled by the team)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## What NOT to Log
|
|
48
|
+
|
|
49
|
+
<!-- Sensitive data, PII, etc. -->
|
|
50
|
+
|
|
51
|
+
(To be filled by the team)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Quality Guidelines
|
|
2
|
+
|
|
3
|
+
> Code quality standards for backend development.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
<!--
|
|
10
|
+
Document your project's quality standards here.
|
|
11
|
+
|
|
12
|
+
Questions to answer:
|
|
13
|
+
- What patterns are forbidden?
|
|
14
|
+
- What linting rules do you enforce?
|
|
15
|
+
- What are your testing requirements?
|
|
16
|
+
- What code review standards apply?
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
(To be filled by the team)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Forbidden Patterns
|
|
24
|
+
|
|
25
|
+
<!-- Patterns that should never be used and why -->
|
|
26
|
+
|
|
27
|
+
(To be filled by the team)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Required Patterns
|
|
32
|
+
|
|
33
|
+
<!-- Patterns that must always be used -->
|
|
34
|
+
|
|
35
|
+
(To be filled by the team)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Testing Requirements
|
|
40
|
+
|
|
41
|
+
<!-- What level of testing is expected -->
|
|
42
|
+
|
|
43
|
+
(To be filled by the team)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Code Review Checklist
|
|
48
|
+
|
|
49
|
+
<!-- What reviewers should check -->
|
|
50
|
+
|
|
51
|
+
(To be filled by the team)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Component Guidelines
|
|
2
|
+
|
|
3
|
+
> How components are built in this project.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
<!--
|
|
10
|
+
Document your project's component conventions here.
|
|
11
|
+
|
|
12
|
+
Questions to answer:
|
|
13
|
+
- What component patterns do you use?
|
|
14
|
+
- How are props defined?
|
|
15
|
+
- How do you handle composition?
|
|
16
|
+
- What accessibility standards apply?
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
(To be filled by the team)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Component Structure
|
|
24
|
+
|
|
25
|
+
<!-- Standard structure of a component file -->
|
|
26
|
+
|
|
27
|
+
(To be filled by the team)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Props Conventions
|
|
32
|
+
|
|
33
|
+
<!-- How props should be defined and typed -->
|
|
34
|
+
|
|
35
|
+
(To be filled by the team)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Styling Patterns
|
|
40
|
+
|
|
41
|
+
<!-- How styles are applied (CSS modules, styled-components, Tailwind, etc.) -->
|
|
42
|
+
|
|
43
|
+
(To be filled by the team)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Accessibility
|
|
48
|
+
|
|
49
|
+
<!-- A11y requirements and patterns -->
|
|
50
|
+
|
|
51
|
+
(To be filled by the team)
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Common Mistakes
|
|
56
|
+
|
|
57
|
+
<!-- Component-related mistakes your team has made -->
|
|
58
|
+
|
|
59
|
+
(To be filled by the team)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Directory Structure
|
|
2
|
+
|
|
3
|
+
> How frontend code is organized in this project.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
<!--
|
|
10
|
+
Document your project's frontend directory structure here.
|
|
11
|
+
|
|
12
|
+
Questions to answer:
|
|
13
|
+
- Where do components live?
|
|
14
|
+
- How are features/modules organized?
|
|
15
|
+
- Where are shared utilities?
|
|
16
|
+
- How are assets organized?
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
(To be filled by the team)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Directory Layout
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
<!-- Replace with your actual structure -->
|
|
27
|
+
src/
|
|
28
|
+
├── ...
|
|
29
|
+
└── ...
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Module Organization
|
|
35
|
+
|
|
36
|
+
<!-- How should new features be organized? -->
|
|
37
|
+
|
|
38
|
+
(To be filled by the team)
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Naming Conventions
|
|
43
|
+
|
|
44
|
+
<!-- File and folder naming rules -->
|
|
45
|
+
|
|
46
|
+
(To be filled by the team)
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## Examples
|
|
51
|
+
|
|
52
|
+
<!-- Link to well-organized modules as examples -->
|
|
53
|
+
|
|
54
|
+
(To be filled by the team)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Hook Guidelines
|
|
2
|
+
|
|
3
|
+
> How hooks are used in this project.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
<!--
|
|
10
|
+
Document your project's hook conventions here.
|
|
11
|
+
|
|
12
|
+
Questions to answer:
|
|
13
|
+
- What custom hooks do you have?
|
|
14
|
+
- How do you handle data fetching?
|
|
15
|
+
- What are the naming conventions?
|
|
16
|
+
- How do you share stateful logic?
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
(To be filled by the team)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Custom Hook Patterns
|
|
24
|
+
|
|
25
|
+
<!-- How to create and structure custom hooks -->
|
|
26
|
+
|
|
27
|
+
(To be filled by the team)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Data Fetching
|
|
32
|
+
|
|
33
|
+
<!-- How data fetching is handled (React Query, SWR, etc.) -->
|
|
34
|
+
|
|
35
|
+
(To be filled by the team)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Naming Conventions
|
|
40
|
+
|
|
41
|
+
<!-- Hook naming rules (use*, etc.) -->
|
|
42
|
+
|
|
43
|
+
(To be filled by the team)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Common Mistakes
|
|
48
|
+
|
|
49
|
+
<!-- Hook-related mistakes your team has made -->
|
|
50
|
+
|
|
51
|
+
(To be filled by the team)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Frontend Development Guidelines
|
|
2
|
+
|
|
3
|
+
> Best practices for frontend development in this project.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
This directory contains guidelines for frontend development. Fill in each file with your project's specific conventions.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Guidelines Index
|
|
14
|
+
|
|
15
|
+
| Guide | Description | Status |
|
|
16
|
+
|-------|-------------|--------|
|
|
17
|
+
| [Directory Structure](./directory-structure.md) | Module organization and file layout | ⬜ To fill |
|
|
18
|
+
| [Component Guidelines](./component-guidelines.md) | Component patterns, props, composition | ⬜ To fill |
|
|
19
|
+
| [Hook Guidelines](./hook-guidelines.md) | Custom hooks, data fetching patterns | ⬜ To fill |
|
|
20
|
+
| [State Management](./state-management.md) | Local state, global state, server state | ⬜ To fill |
|
|
21
|
+
| [Quality Guidelines](./quality-guidelines.md) | Code standards, forbidden patterns | ⬜ To fill |
|
|
22
|
+
| [Type Safety](./type-safety.md) | Type patterns, validation | ⬜ To fill |
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## How to Fill These Guidelines
|
|
27
|
+
|
|
28
|
+
For each guideline file:
|
|
29
|
+
|
|
30
|
+
1. Document your project's **actual conventions** (not ideals)
|
|
31
|
+
2. Include **code examples** from your codebase
|
|
32
|
+
3. List **forbidden patterns** and why
|
|
33
|
+
4. Add **common mistakes** your team has made
|
|
34
|
+
|
|
35
|
+
The goal is to help AI assistants and new team members understand how YOUR project works.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
**Language**: All documentation should be written in **English**.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Quality Guidelines
|
|
2
|
+
|
|
3
|
+
> Code quality standards for frontend development.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
<!--
|
|
10
|
+
Document your project's quality standards here.
|
|
11
|
+
|
|
12
|
+
Questions to answer:
|
|
13
|
+
- What patterns are forbidden?
|
|
14
|
+
- What linting rules do you enforce?
|
|
15
|
+
- What are your testing requirements?
|
|
16
|
+
- What code review standards apply?
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
(To be filled by the team)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Forbidden Patterns
|
|
24
|
+
|
|
25
|
+
<!-- Patterns that should never be used and why -->
|
|
26
|
+
|
|
27
|
+
(To be filled by the team)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Required Patterns
|
|
32
|
+
|
|
33
|
+
<!-- Patterns that must always be used -->
|
|
34
|
+
|
|
35
|
+
(To be filled by the team)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Testing Requirements
|
|
40
|
+
|
|
41
|
+
<!-- What level of testing is expected -->
|
|
42
|
+
|
|
43
|
+
(To be filled by the team)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Code Review Checklist
|
|
48
|
+
|
|
49
|
+
<!-- What reviewers should check -->
|
|
50
|
+
|
|
51
|
+
(To be filled by the team)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# State Management
|
|
2
|
+
|
|
3
|
+
> How state is managed in this project.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
<!--
|
|
10
|
+
Document your project's state management conventions here.
|
|
11
|
+
|
|
12
|
+
Questions to answer:
|
|
13
|
+
- What state management solution do you use?
|
|
14
|
+
- How is local vs global state decided?
|
|
15
|
+
- How do you handle server state?
|
|
16
|
+
- What are the patterns for derived state?
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
(To be filled by the team)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## State Categories
|
|
24
|
+
|
|
25
|
+
<!-- Local state, global state, server state, URL state -->
|
|
26
|
+
|
|
27
|
+
(To be filled by the team)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## When to Use Global State
|
|
32
|
+
|
|
33
|
+
<!-- Criteria for promoting state to global -->
|
|
34
|
+
|
|
35
|
+
(To be filled by the team)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Server State
|
|
40
|
+
|
|
41
|
+
<!-- How server data is cached and synchronized -->
|
|
42
|
+
|
|
43
|
+
(To be filled by the team)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Common Mistakes
|
|
48
|
+
|
|
49
|
+
<!-- State management mistakes your team has made -->
|
|
50
|
+
|
|
51
|
+
(To be filled by the team)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Type Safety
|
|
2
|
+
|
|
3
|
+
> Type safety patterns in this project.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
<!--
|
|
10
|
+
Document your project's type safety conventions here.
|
|
11
|
+
|
|
12
|
+
Questions to answer:
|
|
13
|
+
- What type system do you use?
|
|
14
|
+
- How are types organized?
|
|
15
|
+
- What validation library do you use?
|
|
16
|
+
- How do you handle type inference?
|
|
17
|
+
-->
|
|
18
|
+
|
|
19
|
+
(To be filled by the team)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Type Organization
|
|
24
|
+
|
|
25
|
+
<!-- Where types are defined, shared types vs local types -->
|
|
26
|
+
|
|
27
|
+
(To be filled by the team)
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Validation
|
|
32
|
+
|
|
33
|
+
<!-- Runtime validation patterns (Zod, Yup, io-ts, etc.) -->
|
|
34
|
+
|
|
35
|
+
(To be filled by the team)
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## Common Patterns
|
|
40
|
+
|
|
41
|
+
<!-- Type utilities, generics, type guards -->
|
|
42
|
+
|
|
43
|
+
(To be filled by the team)
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Forbidden Patterns
|
|
48
|
+
|
|
49
|
+
<!-- any, type assertions, etc. -->
|
|
50
|
+
|
|
51
|
+
(To be filled by the team)
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Code Reuse Thinking Guide
|
|
2
|
+
|
|
3
|
+
> **Purpose**: Stop and think before creating new code - does it already exist?
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## The Problem
|
|
8
|
+
|
|
9
|
+
**Duplicated code is the #1 source of inconsistency bugs.**
|
|
10
|
+
|
|
11
|
+
When you copy-paste or rewrite existing logic:
|
|
12
|
+
- Bug fixes don't propagate
|
|
13
|
+
- Behavior diverges over time
|
|
14
|
+
- Codebase becomes harder to understand
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Before Writing New Code
|
|
19
|
+
|
|
20
|
+
### Step 1: Search First
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Search for similar function names
|
|
24
|
+
grep -r "functionName" .
|
|
25
|
+
|
|
26
|
+
# Search for similar logic
|
|
27
|
+
grep -r "keyword" .
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Step 2: Ask These Questions
|
|
31
|
+
|
|
32
|
+
| Question | If Yes... |
|
|
33
|
+
|----------|-----------|
|
|
34
|
+
| Does a similar function exist? | Use or extend it |
|
|
35
|
+
| Is this pattern used elsewhere? | Follow the existing pattern |
|
|
36
|
+
| Could this be a shared utility? | Create it in the right place |
|
|
37
|
+
| Am I copying code from another file? | **STOP** - extract to shared |
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Common Duplication Patterns
|
|
42
|
+
|
|
43
|
+
### Pattern 1: Copy-Paste Functions
|
|
44
|
+
|
|
45
|
+
**Bad**: Copying a validation function to another file
|
|
46
|
+
|
|
47
|
+
**Good**: Extract to shared utilities, import where needed
|
|
48
|
+
|
|
49
|
+
### Pattern 2: Similar Components
|
|
50
|
+
|
|
51
|
+
**Bad**: Creating a new component that's 80% similar to existing
|
|
52
|
+
|
|
53
|
+
**Good**: Extend existing component with props/variants
|
|
54
|
+
|
|
55
|
+
### Pattern 3: Repeated Constants
|
|
56
|
+
|
|
57
|
+
**Bad**: Defining the same constant in multiple files
|
|
58
|
+
|
|
59
|
+
**Good**: Single source of truth, import everywhere
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## When to Abstract
|
|
64
|
+
|
|
65
|
+
**Abstract when**:
|
|
66
|
+
- Same code appears 3+ times
|
|
67
|
+
- Logic is complex enough to have bugs
|
|
68
|
+
- Multiple people might need this
|
|
69
|
+
|
|
70
|
+
**Don't abstract when**:
|
|
71
|
+
- Only used once
|
|
72
|
+
- Trivial one-liner
|
|
73
|
+
- Abstraction would be more complex than duplication
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## After Batch Modifications
|
|
78
|
+
|
|
79
|
+
When you've made similar changes to multiple files:
|
|
80
|
+
|
|
81
|
+
1. **Review**: Did you catch all instances?
|
|
82
|
+
2. **Search**: Run grep to find any missed
|
|
83
|
+
3. **Consider**: Should this be abstracted?
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Checklist Before Commit
|
|
88
|
+
|
|
89
|
+
- [ ] Searched for existing similar code
|
|
90
|
+
- [ ] No copy-pasted logic that should be shared
|
|
91
|
+
- [ ] Constants defined in one place
|
|
92
|
+
- [ ] Similar patterns follow same structure
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# Cross-Layer Thinking Guide
|
|
2
|
+
|
|
3
|
+
> **Purpose**: Think through data flow across layers before implementing.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## The Problem
|
|
8
|
+
|
|
9
|
+
**Most bugs happen at layer boundaries**, not within layers.
|
|
10
|
+
|
|
11
|
+
Common cross-layer bugs:
|
|
12
|
+
- API returns format A, frontend expects format B
|
|
13
|
+
- Database stores X, service transforms to Y, but loses data
|
|
14
|
+
- Multiple layers implement the same logic differently
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Before Implementing Cross-Layer Features
|
|
19
|
+
|
|
20
|
+
### Step 1: Map the Data Flow
|
|
21
|
+
|
|
22
|
+
Draw out how data moves:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
Source → Transform → Store → Retrieve → Transform → Display
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For each arrow, ask:
|
|
29
|
+
- What format is the data in?
|
|
30
|
+
- What could go wrong?
|
|
31
|
+
- Who is responsible for validation?
|
|
32
|
+
|
|
33
|
+
### Step 2: Identify Boundaries
|
|
34
|
+
|
|
35
|
+
| Boundary | Common Issues |
|
|
36
|
+
|----------|---------------|
|
|
37
|
+
| API ↔ Service | Type mismatches, missing fields |
|
|
38
|
+
| Service ↔ Database | Format conversions, null handling |
|
|
39
|
+
| Backend ↔ Frontend | Serialization, date formats |
|
|
40
|
+
| Component ↔ Component | Props shape changes |
|
|
41
|
+
|
|
42
|
+
### Step 3: Define Contracts
|
|
43
|
+
|
|
44
|
+
For each boundary:
|
|
45
|
+
- What is the exact input format?
|
|
46
|
+
- What is the exact output format?
|
|
47
|
+
- What errors can occur?
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Common Cross-Layer Mistakes
|
|
52
|
+
|
|
53
|
+
### Mistake 1: Implicit Format Assumptions
|
|
54
|
+
|
|
55
|
+
**Bad**: Assuming date format without checking
|
|
56
|
+
|
|
57
|
+
**Good**: Explicit format conversion at boundaries
|
|
58
|
+
|
|
59
|
+
### Mistake 2: Scattered Validation
|
|
60
|
+
|
|
61
|
+
**Bad**: Validating the same thing in multiple layers
|
|
62
|
+
|
|
63
|
+
**Good**: Validate once at the entry point
|
|
64
|
+
|
|
65
|
+
### Mistake 3: Leaky Abstractions
|
|
66
|
+
|
|
67
|
+
**Bad**: Component knows about database schema
|
|
68
|
+
|
|
69
|
+
**Good**: Each layer only knows its neighbors
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Checklist for Cross-Layer Features
|
|
74
|
+
|
|
75
|
+
Before implementation:
|
|
76
|
+
- [ ] Mapped the complete data flow
|
|
77
|
+
- [ ] Identified all layer boundaries
|
|
78
|
+
- [ ] Defined format at each boundary
|
|
79
|
+
- [ ] Decided where validation happens
|
|
80
|
+
|
|
81
|
+
After implementation:
|
|
82
|
+
- [ ] Tested with edge cases (null, empty, invalid)
|
|
83
|
+
- [ ] Verified error handling at each boundary
|
|
84
|
+
- [ ] Checked data survives round-trip
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## When to Create Flow Documentation
|
|
89
|
+
|
|
90
|
+
Create detailed flow docs when:
|
|
91
|
+
- Feature spans 3+ layers
|
|
92
|
+
- Multiple teams are involved
|
|
93
|
+
- Data format is complex
|
|
94
|
+
- Feature has caused bugs before
|