agentleFS
LazyAGILazyAGI/LazyMind/skills/.curated/ui-safe-form-patterns/SKILL.md

ui-safe-form-patterns

Skill78 starsChanged 5 months agoApache-2.0View on GitHub

Implement or refactor UI forms with defense-in-depth validation, safe input handling, reliable submission behavior, and privacy-aware error handling. Use when building login, registration, profile, payment, admin, or file-upload forms.

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill to build forms that are both secure and dependable in real user conditions.

    line 8
  2. Distinctive:

    Treat client validation as UX, not security control.

    line 17
  3. Distinctive:

    Use clear loading, success, retry, and failure states.

    line 20
  4. Distinctive:

    Never leak secrets or raw backend traces in UI errors.

    line 21
  5. Distinctive:

    Add submit lock, timeout handling, and cancel or retry behavior where relevant.

    line 27
  6. Distinctive:

    Add tests for invalid input, race conditions, and repeated clicks.

    line 29
  7. Distinctive:

    Avoid stale success state after failed retries.

    line 49

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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

UI Safe Form Patterns

Use this skill to build forms that are both secure and dependable in real user conditions.

When to use

  • Creating new forms or refactoring existing form logic.
  • Hardening forms that process credentials, PII, money, or privileged actions.
  • Fixing flaky submission flows and duplicate-submit bugs.

Reliability and safety baseline

  • Validate on both client and server.
  • Treat client validation as UX, not security control.
  • Normalize input before validation when format ambiguity is common.
  • Prevent duplicate submissions with in-flight state and idempotent APIs.
  • Use clear loading, success, retry, and failure states.
  • Never leak secrets or raw backend traces in UI errors.

Implementation workflow

  1. Define schema and constraints per field, including max lengths and allowed character sets.
  2. Build controlled input handling with immediate low-cost validation and deferred heavy checks.
  3. Sanitize or encode displayed user-provided content in previews and confirmation screens.
  4. Add submit lock, timeout handling, and cancel or retry behavior where relevant.
  5. Map backend errors into safe user-facing messages without exposing internals.
  6. Add tests for invalid input, race conditions, and repeated clicks.

Sensitive field rules

  • Password fields: enforce minimum policy and avoid logging or analytics capture.
  • Email and phone: normalize before validation to reduce false negatives.
  • File uploads: enforce MIME and size checks client-side and server-side.
  • Rich text inputs: sanitize on server and encode on render.
  • Numeric money fields: use decimal-safe parsing and range checks.

Suggested checks

rg -n "onSubmit|handleSubmit|Form|formik|react-hook-form|yup|zod" frontend/src
rg -n "localStorage|sessionStorage|console\.log\(|Sentry|analytics" frontend/src
rg -n "type=\"file\"|upload|multipart|FormData" frontend/src

Test minimum

  • Reject malformed input with stable messaging.
  • Ignore rapid double click while request is in flight.
  • Preserve user input when recoverable errors occur.
  • Avoid stale success state after failed retries.
  • Confirm no sensitive values appear in logs or telemetry payloads.

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.