actions
Fungsinya
Skill ini menjelaskan cara membuat actions di aplikasi Agent-Native. Actions adalah operasi bersama yang dipanggil agen sebagai alat dan dipanggil layar melalui hook. Skill ini ditujukan untuk pengembang yang membangun atau memperluas aplikasi ini.
Kapan dipakai
- βSaat Anda menambahkan operasi baru yang dibutuhkan agen dan layar sekaligus.
- βSaat Anda menghubungkan aplikasi ke API eksternal.
- βSaat Anda menyiapkan pengambilan data untuk layar di aplikasi Agent-Native.
Link skill
https://github.com/BuilderIO/agent-native/blob/main/.agents/skills/actions/SKILL.mdSalin lalu tempelkan ke AI Anda (Claude, ChatGPT, atau Cursor) dan minta AI mengikuti instruksinya.
Cara pakai
Cara paling mudah: salin pesan ini dan tempelkan ke AI Anda. AI akan membaca skill dan mengikuti instruksinya.
Pesan siap tempel
Untuk Claude Code, Codex, atau Cursor: jalankan di folder proyek, lalu skill langsung terpasang.
Unduh SKILL.md lalu taruh di folder skill agen Anda.
Contoh permintaan ke AI
βBisakah Anda menambahkan action yang mengambil faktur terbuka saya dari API penagihan kami dan menampilkannya di dasbor?β
5 skill baru setiap minggu. 1 menit baca.
Cara kerjanya
Agent pertama-tama memeriksa apakah ada action yang sudah ada. Jika tidak ada yang cocok, agent menulis action baru yang dapat dipanggil oleh agen dan frontend, tanpa rute web terpisah.
Konten teknis (SKILL.md asli)
Teks asli dari pembuat, dalam bahasa Inggris, langsung dari GitHub.
Agent Actions
Rule
Actions in actions/ are the single source of truth for app operations. The agent calls them as tools, the frontend calls them through useActionQuery / useActionMutation, and the framework owns the HTTP transport behind those hooks β no duplicate /api/ routes.
Before creating any custom route for app data, check actions/ and the action table in AGENTS.md. An action already exists? Call it directly. Missing? Create or update a defineAction. Stop trigger: about to add a file under server/routes/api/ (or middleware to guard one)? Check it against the exception list in Custom /api/ Routes below first β even if you already started the route.
Keep Actions Deterministic
An action may call a provider API, validate data, and persist records without being an AI feature β keep it deterministic, focused, and independently useful to the agent. Don't put LLM calls or a second model runtime in app actions.
The sanctioned model-backed exception is @agent-native/core/decisions for capability-aware classification and scoring, and it returns a result without performing or authorizing the selected action.
When a workflow is research, analysis, generation, recommendation, or synthesis β or spans several provider calls and writes β route it to the AgentSidebar via sendToAgentChat({ openSidebar: true }) and let the agent orchestrate focused actions instead of hiding an AI-shaped workflow behind one opaque generate-*/create-* action just because its implementation happens to be deterministic.
How to Create an Action
One action per file, default-exported. The filename is the action name (kebab-case): actions/list-meals.ts is the list-meals action. Don't put several defineActions as named exports in one file β the registry keys actions by filename and only the default export is registered, so extra named exports never become callable and won't match .generated/action-types.d.ts.
// actions/list-meals.ts
import { z } from "zod";
import { defineAction } from "@agent-native/core/action";
import { getDb } from "../server/db/index.js";
import { meals } from "../server/db/schema.js";
export default defineAction({
description: "List all meals",
schema: z.object({}),
http: { method: "GET" },
run: async () => {
const db = getDb();
const rows = await db.select().from(meals);
return rows; // Return objects/arrays, NOT JSON.stringify()
},
});
schema (Zod or Standard Schema-compatible) gives runtime validation, TS inference for run() args, and an auto-generated JSON Schema for the tool. Write it so an agent can call the tool correctly on the first try: .describe() every param and state enum values and the default in that text (z.enum(["open","closed"]).default("open").describe('Filter status: "open" or "closed"; defaults to "open"')); mark a field .optional() only when the action truly tolerates its absence β a silent default the caller cannot see is a required field in disguise; name the primary id the same way across a family (create-/get-/update-/delete-<thing> all take id, not a mix of id and <thing>Id), and if one action must differ, accept both with .or(); give nested objects a real schema, never a prose description; keep the one-line description complete enough to call the tool without a second lookup, because compact catalogs and tool-search show only that line. Use z.coerce.number() for numeric HTTP params, but write an explicit boolean parser instead of z.coerce.boolean(), which treats "false" as truthy.
Use Drizzle's PostgreSQL query builder, not raw SQL/getDbExec() or direct driver imports, unless Drizzle can't express the query. Never hardcode API keys/tokens/secrets - read via readAppSecret / resolveCredential / OAuth helpers; process.env is deploy-level config only.
Decision order: existing action β extend/create a defineAction β custom route as last resort (Custom /api/ Routes below). Actions are already callable by agents, CLIs, hooks, HTTP, and MCP/A2A β don't wrap them in an umbrella REST API.
Keep the Action Surface Small and Orthogonal
Every agent-exposed action is a tool in the model's context window; more tools degrades tool-selection quality. Add the fewest, most orthogonal actions that cover the capability.
- One orthogonal
updateper resource, not one per field βupdate-<thing>taking an optional-fields patch, notupdate-<thing>-name+ `update-<t
Pertanyaan umum
Mengapa tidak menulis rute API terpisah?
Action sudah menyediakan endpoint web, sehingga rute duplikat akan menjadi sumber kebenaran kedua.
Haruskah actions memakai model AI?
Skill ini menyarankan actions bersifat deterministik, dan pekerjaan yang digerakkan model dikirim ke sidebar agen.
Di mana actions disimpan?
Actions disimpan di folder actions aplikasi.
Detail
Deskripsi asli dari pembuat
How to create and run agent actions. Actions are the single source of truth for app operations β the agent calls them as tools and frontend code calls them through client hooks. Use when creating a new action, adding an API integration, or wiring up frontend data fetching.
repo: BuilderIO/agent-native
Popularitas
- Bintang GitHub
- 7.6k
- Peringkat
- #13129
- Lisensi
- MIT
- Diperbarui
- 2/11/2026
Komentar
- β¦
Skill lain dari repositori ini
design-exploration
7.6kMembantu agent Anda mengeksplorasi beberapa arah desain UI secara berdampingan, membiarkan Anda memilih satu, lalu menyempurnakan desain yang dipilih.
visual-edit
7.6kMembantu agent Anda membuka aplikasi lokal yang sedang berjalan di editor visual agar Anda dapat meninjau dan mengedit layar aslinya bersama-sama.
turn-into-app
7.6kMengubah alur kerja, spreadsheet, atau proyek menjadi aplikasi visual yang rapi, dengan layar yang terisi dan agent yang bekerja di balik kontrol.
visual-plan
7.6kMengubah rencana teks biasa menjadi rencana visual interaktif dengan diagram, peta file, cuplikan kode, dan pertanyaan terbuka.
Skill serupa
diffs
394kMemungkinkan agent Anda menghasilkan diff perubahan yang nyata dan dapat dibagikan sebagai tautan viewer atau file gambar, bukan ringkasan yang ditulis manual.
coding-agent
394kMembantu agent Anda menyerahkan pekerjaan pemrograman besar ke Codex, Claude Code, atau OpenCode di latar belakang, lalu memeriksa kemajuannya.
gh-issues
394kMembantu agent Anda menemukan issue GitHub, memilih yang dikerjakan, dan membuka pull request perbaikan, termasuk tindak lanjut komentar tinjauan.