feature-structure
Build Feature Structure
Overview
Use this skill to reorganize code around features or scaffold a new feature without embedding business logic. Treat a feature as a composition boundary, not just a place to move one large smart component. Infer the local pattern first, preserve established repository naming and wiring when they already exist, and keep changes minimal-diff unless the user asks for broader restructuring.
A feature file should compose child features and leaf UI directly. Do not default to one large screen-shaped UI component that receives the whole feature state and callback surface as props. Features may import other features. UI is not a dumping ground for screen orchestration.
Layer Roles and Import Boundaries
When normalizing or creating a feature-based structure, prefer at most four library types: data-access, feature or feature-<app>, ui or ui-<app>, and optional util. If the repository already uses names such as features/ for folders, keep the naming and apply the same responsibilities.
data-access: own adapters, fetching, invalidation, mutations, mutation-side effects, persistence, platform checks, and other side-effectful integration work. It may import from otherdata-accessmodules. It must not importfeatureorui. Prefer one exported thing per file, one hook per file when hooks are used, one query or mutation per hook when possible, and concrete imports over barrels unless the repository already standardizes a different pattern. Mutation hooks should own error handling, invalidation, and side effects.featureorfeature-<app>: act as the smart or orchestration layer. It should own routed screen logic and route params, decide whichdata-accesscalls run, compose child features when a workflow or screen subsection has distinct phases, prerequisites, or hook orchestration, and pass only minimal resolved data or imperative domain actions intoui. In file-based routing repos, framework-owned route files stay as thin wrappers outside the feature tree. It may import fromdata-access,ui, and narrowerfeaturefiles.uiorui-<app>: stay presentational or dumb. It may import from otheruimodules and passive pieces fromdata-access, such as pure helpers or types, but it must not own route parsing, API calls, mutations, or other side-effectful workflow orchestration. Prefer granular leaf components over a single large screen component whenfeatureis orchestrating multiple states or workflows. Keep ephemeral form or input state local to the leaf UI component unless multiple siblings genuinely need it. Do not turnuiinto a screen-shaped prop bag sink.util: stay optional and rare. Use it for pure helpers, usually on the backend, and keep it free of rendering, route handling, and side-effectful orchestration.
File Shape Defaults
More from beeman/skills
gh-pr-review-comments
Address GitHub pull request review comments on an existing feature branch. Use when Codex needs to fetch live PR review comments with gh, classify each comment as actionable, optional, or rejectable, apply only accepted fixes on the same branch, run a self-review pass for contradictions introduced by those fixes, and then either create a new commit or follow an explicitly approved history-rewrite path before pushing, resolving threads, and re-requesting review.
8gh-pr-create
Create a GitHub pull request from local repo changes. Use when Codex must get feature-branch setup and local commit packaging from `gh-commit`, get approval before pushing, show the exact PR title and body that will be sent, handle single-commit and multi-commit branch flows explicitly, and open or update the PR with gh.
7gh-issue-kickoff
Kick off work on a GitHub issue with gh. Use when Codex needs to start from the authoritative issue state and local codebase, fix only material issue gaps, and produce the first execution-ready implementation plan. For a deeper critique or tradeoff review of an existing plan, use `gh-plan-review`.
5gh-plan-review
Review, challenge, pressure-test, or refine an implementation plan tied to a GitHub issue, GitHub PR, or active branch. Use when Codex needs to inspect the authoritative GitHub state and local repo context, run a scope challenge, identify material plan risks, surface real tradeoffs, and finish with a fixed review summary without mutating code or git state.
5gh-pr-rebase
Rebase an existing GitHub PR branch onto the repository default branch. Use when Codex needs to fetch the latest default-branch history, keep the local default branch current when that is safe, rebase the current feature branch, resolve straightforward conflicts carefully, ask the user to decide ambiguous conflicts, and update the remote PR branch with `git push --force-with-lease` after any required approval.
5gh-commit
Prepare a local Git commit from repo changes. Use when Codex needs to get onto the correct feature branch if needed, inspect `git status --short`, the current diff, and branch history, run the smallest relevant verification, add any required changeset, and package the tracked work into either a new commit or an explicitly approved amend flow before any push or PR step.
4