agentleFS
ingsergiovtingsergiovt/claude-code-hexagonal-kit/.claude/skills/connect-ui/SKILL.md

connect-ui

Skill1 starsChanged 36 days agoMITView on GitHub

Wire a use case to a Next.js page through a server action with Zod validation, field errors and pending state. Use when the user wants a form or button in src/app that triggers a use case.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Make sure the use case is exposed in src/composition/<module>.ts.

    line 13
  2. Very specific:

    Run pnpm check, then pnpm build (server actions and Suspense rules are enforced at build time).

    line 20

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Connect UI

src/app is the driving adapter: it translates HTTP/form input into use-case calls and results into UI. It holds no business rules.

Steps

  1. Make sure the use case is exposed in src/composition/<module>.ts. The UI imports @/composition/<module> for use cases and @/modules/<module> for types and DomainError. Never import module internals.
  2. In src/app/<route>/schemas.ts write the Zod schema for the form. Messages are user-facing. Convert units here (for example dollars to cents), not in the use case.
  3. In src/app/<route>/actions.ts ("use server") follow templates/action.ts.tpl: parse with safeParse, return { status: "error", fieldErrors } on failure, call the use case inside try, map DomainError to its message and everything else to a generic message, then revalidatePath.
  4. Shared form state type lives in form-state.ts (a "use server" file may only export async functions).
  5. Client form: useActionState(action, initialFormState); submit button uses useFormStatus for pending; render each field error next to its input with role="alert".
  6. Reads: a server component that awaits connection() (or other runtime data) inside <Suspense> with a loading fallback and an explicit empty state.
  7. Next.js here has breaking changes: check node_modules/next/dist/docs/ for anything you are unsure about (see AGENTS.md).
  8. Run pnpm check, then pnpm build (server actions and Suspense rules are enforced at build time).

UI states checklist

loading, empty, error (field and form level), success, pending-disabled button.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.