1
---
2
name: react-container-presentation-component
3
description: "Create a React component using the Container/Presentation pattern in src/components by asking for the component name and type (ui or features), then scaffold files that follow this repository's TypeScript, Storybook, and SCSS conventions. Use when the user explicitly asks for a Container/Presentation-based component or runs /react-container-presentation-component."
4
argument-hint: "componentName type(ui|features)"
5
user-invocable: true
6
---
7
8
# Container/Presentation Component
9
10
Use this skill to create a React component under `src/components` that follows the Container/Presentation pattern.
11
12
Refer to this skill's bundled references for detailed rules.
13
14
- `references/component-architecture.md`
15
- `references/typescript-and-scss-rules.md`
16
17
If the `/react-container-presentation-component` input is incomplete, ask questions first before creating files.
18
19
## When To Use
20
21
- When the user runs `/react-container-presentation-component`
22
- When the user explicitly asks for a React component that follows the Container/Presentation pattern
23
- When the user wants help deciding or implementing `ui` vs `features` classification within the Container/Presentation pattern
24
25
## Required Questions
26
27
If any of the following information is missing, ask the user using `ask_user`.
28
29
1. Component name
30
2. Type (`ui` or `features`)
31
3. Whether to replace existing components (only when creating `ui`)
32
33
Question requirements:
34
35
- Provide the type as options (`ui`, `features`)
36
- Require the component name to be in PascalCase
37
- For `ui`, ask whether direct usage of Mantine or other UI libraries in existing `features` should be replaced with the new component
38
39
## Procedure
40
41
1. Check existing components
42
43
- Check whether `src/components/ui/<ComponentName>` or `src/components/features/<ComponentName>` already exists.
44
- If it exists, do not overwrite; confirm the preferred approach with the user.
45
46
2. Decide target directory
47
48
- `ui`: `src/components/ui/<ComponentName>`
49
- `features`: `src/components/features/<ComponentName>`
50
51
3. Re-check classification (only when `ui` is specified)
52
53
- Even when `ui` is specified, before creating files, review `Reclassification Rule` in `references/component-architecture.md`.
54
- If the implementation includes state management, side effects, async processing, context/store updates, or business logic, treat it as `features`.
55
- If the result is closer to `features`, do not proceed as `ui`; use `ask_user` and confirm one of the following before continuing.
56
- `Create as features`
57
- `Keep ui and move state/logic to parent or features`
58
59
4. Create required files
60
61
- `ui`: `index.tsx`, `index.module.scss`, `index.stories.tsx`
62
- `features`: `index.tsx`, `use<ComponentName>.tsx`, `presentation.tsx`, `types.ts`, `presentation.module.scss`, `presentation.stories.tsx`
63
64
5. Replace existing usages (only when creating `ui`)
65
66
- Only when the user approves, replace equivalent direct implementations using Mantine or other UI libraries in existing `features` with the new `ui` component.
67
68
6. Validate
69
70
- Run build and lint commands, and ensure both pass; if issues are introduced by newly added or updated files, fix them.
71
- Follow `Storybook Minimum` in `references/component-architecture.md` for story state decisions.
72
- Ask the user via `ask_user` whether to run a Storybook check (for example: "Run" / "Skip for now").
73
- Run `npm run storybook` only if the user selects "Run".
74
- If the user selects "Skip for now", explicitly mention in the final report that Storybook execution was skipped.
75
76
## Output Contract
77
78
- Report the list of files created.
79
- If replacements were performed, report the list of changed files and replacement details.
80
- Provide one usage example of the created component.
81
- Report whether Storybook verification was executed (run/skip), and if run, include the command used.
82
- Explain why the component was classified as `ui` or `features`.
83
- Summarize where state, side effects, and rendering responsibilities were placed.
84
- Confirm whether there were any dependency direction violations.
85
- Clearly state any unresolved items.
86