Form building

From BuilderIO/agent-native · View interactive version

Form building is an AI agent skill from the GitHub repository BuilderIO/agent-native. How to create and structure forms. Use when creating a new form, adding fields, modifying form structure, or understanding field types and their JSON schema.

How to use this skill

Skill file

Form Building

Creating a Form

Use the create-form script to create forms from natural language:

pnpm action create-form --title "Contact Form" --fields '[...]'

The script generates a unique ID, creates a URL slug, and stores the form in SQL as draft status.

One request, one form

Every form the user describes is its own form. Use create-form for each new

form request even when a form is already open on screen or you created one

earlier in the same conversation — the open form is context, not a default

target. Reach for update-form / patch-form-fields only when the user is

changing that specific form.

| The user says | Call |

| --- | --- |

| "Create a customer feedback form..." | create-form |

| "Now build an event registration form..." | create-form (a second form) |

| "Add a phone field to it" | patch-form-fields |

| "Rename this form / publish it" | update-form |

| "Rewrite this form as a signup form" | update-form with confirmReplaceFields: true |

update-form rejects a fields replacement that drops most of the form's

existing questions with unconfirmed_field_loss. That error means the call was

about to overwrite a form the user still wants: create the new form instead,

unless they explicitly asked to rewrite this one in place.

Field Types

| Type | Description | Options needed | Example use |

| ------------- | ------------------------------ | -------------- | --------------------- |

| text | Single-line text input | No | Name, company |

| email | Email input with validation | No | Contact email |

| number | Numeric input | No | Age, quantity |

| textarea | Multi-line text | No | Message, comments |

| select | Single-choice dropdown | Yes | Country, department |

| multiselect | Multi-choice dropdown | Yes | Skills, interests |

| checkbox | Boolean toggle | No | Consent, opt-in |

| radio | Single-choice radio buttons | Yes | Gender, preference |

| date | Date picker | No | Birthday, deadline |

| rating | Star rating (1-5) | No | Satisfaction, quality |

| scale | Numeric scale (e.g., 1-10) | No | NPS, likelihood |

| file | File upload | No | Resume, attachment |

Field JSON Schema

Each field is a JSON object:

{
  "id": "field_name",
  "type": "text",
  "label": "Your Name",
  "placeholder": "Enter your name",
  "description": "Help text shown below the field",
  "required": true,
  "options": ["Option A", "Option B"],
  "validation": {
    "min": 1,
    "max": 100,
    "pattern": "^[a-zA-Z]+$",
    "message": "Custom error message"
  },
  "conditional": {
    "fieldId": "other_field_id",
    "operator": "equals",
    "value": "show_this_field"
  },
  "width": "full"
}

Required properties

Always pass fields as these complete objects. Never encode a field as shorthand

text such as text: Enter a name; patch-form-fields upserts also require the

field id so they cannot be ambiguous.

Optional properties

Updating a Form

Use update-form to modify any form property:

# Change title
pnpm action update-form --id <id> --title "New Title"

# Update fields, sending the revision you read
pnpm action update-form --id <id> --expectedRevision <revision> --fields '[...]'

# Change status
pnpm action update-form --id <id> --status published

view-screen, get-form, create-form, update-form and patch-form-fields

return a revision. Send it as expectedRevision when you replace fields or

when you upsert an existing field, remove a field or reorder. A save_conflict

means someone changed the fields after your read and nothing was saved: redo

your edit on details.current (call get-form if it was left out) with

details.currentRevision. Title, status and settings changes and new fields

don't need a revision.

A rename moves the slug only on a draft still using the slug generated from its

title. A custom slug or a published form keeps its link.

Common Form Templates

When a user asks for a common form type, use these field patterns:

Contact form:

[
  {"id":"name","type":"text","label":"Name","required":true},
  {"id":"email","type":"email","label":"Email","required":true},
  {"id":"message","type":"textarea","label":"Message","required":true}
]

Survey/feedback:

[
  {"id":"rating","type":"rating","label":"Overall satisfaction","required":true},
  {"id":"recommend","type":"scale","label":"How likely to recommend? (1-10)","required":true},
  {"id":"feedback","type":"textarea","label":"Additional feedback","required":false}
]

Registration/signup:

[
  {"id":"first_name","type":"text","label":"First Name","required":true,"width":"half"},
  {"id":"last_name","type":"text","label":"Last Name","required":true,"width":"half"},
  {"id":"email","type":"email","label":"Email","required":true},
  {"id":"role","type":"select","label":"Role","options":["Student","Professional","Other"],"required":true}
]

Workflow

  1. create-form with title and fields
  2. Preview in the GUI (agent + user iterate)
  3. update-form --status published to go live
  4. Share the public URL: /f/<slug>

Related Skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.