.agents/skills/how-to-write-component/SKILL.md
Use this skill to route component architecture decisions to its bundled references. Read only the references required by the current change.
| Question | Default | Promote only when |
|---|---|---|
| Where should code live? | In the product workflow, route, or feature owner. | Several verticals need the same stable contract. |
| Who owns state and handlers? | The lowest visual owner that consumes them. | A parent coordinates one workflow or consistent snapshot. |
| Should state enter Jotai? | Keep component and form state local. | Siblings need one source of truth or scoped workflow persistence. |
| Who owns URL state? | Next.js route APIs and nuqs. | Atoms require a read-only route-identity bridge. |
| Who owns remote state? | TanStack Query at the lowest consumer. | Atom state drives the query or shared derivations consume it. |
| Is a wrapper needed? | Use the primitive or direct code. | The wrapper owns behavior, validation, state, or semantics. |
| Is an Effect needed? | Derive during render or handle the user action. | A named external system must be synchronized. |
references/ownership.md.references/state.md.references/data.md.references/interactions.md and the overlay guide it references when applicable.references/runtime.md.web/docs/test.md or web/docs/lint.md for Web, and the packages/dify-ui/README.md Development section for Dify UI.