Agent native engineering inverts traditional software architecture. Instead of writing code that the agent executes, you define outcomes in prompts and let the agent figure out HOW to achieve them.
The Foundational Principle
Whatever the user can do, the agent can do. Many things the developer can do, the agent can do.
Don't artificially limit the agent. If a user could read files, write code, browse the web, deploy an app—the agent should be able to do those things too. The agent figures out HOW to achieve an outcome; it doesn't just call your pre-written functions.
Features Are Prompts
Each feature is a prompt that defines an outcome and gives the agent the tools it needs. The agent then figures out how to accomplish it.
Traditional: Feature = function in codebase that agent calls
Prompt-native: Feature = prompt defining desired outcome + primitive tools
The agent doesn't execute your code. It uses primitives to achieve outcomes you describe.
Tools Provide Capability, Not Behavior
Tools should be primitives that enable capability. The prompt defines what to do with that capability.
Wrong: generate_dashboard(data, layout, filters) — agent executes your workflow
Right: read_file, write_file, list_files — agent figures out how to build a dashboard
Pure primitives are better, but domain primitives (like store_feedback) are OK if they don't encode logic—just storage/retrieval.
The Development Lifecycle
- Start in the prompt - New features begin as natural language defining outcomes
- Iterate rapidly - Change behavior by editing prose, not refactoring code
- Graduate when stable - Harden to code when requirements stabilize AND speed/reliability matter
- Many features stay as prompts - Not everything needs to become code
Self-Modification (Advanced)
The advanced tier: agents that can evolve their own code, prompts, and behavior. Not required for every app, but a big part of the future.
When implementing:
- Approval gates for code changes
- Auto-commit before modifications (rollback capability)
- Health checks after changes
- Build verification before restart
When NOT to Use This Approach
- High-frequency operations - thousands of calls per second
- Deterministic requirements - exact same output every time
- Cost-sensitive scenarios - when API costs would be prohibitive
- High security - though this is overblown for most apps
- Design architecture - Plan a new prompt-native agent system
- Create MCP tools - Build primitive tools following the philosophy
- Write system prompts - Define agent behavior in prompts
- Self-modification - Enable agents to safely evolve themselves
- Review/refactor - Make existing code more prompt-native
- Context injection - Inject runtime app state into agent prompts
- Action parity - Ensure agents can do everything users can do
- Shared workspace - Set up agents and users in the same data space
- Testing - Test agent-native apps for capability and parity
- Mobile patterns - Handle background execution, permissions, cost
- API integration - Connect to external APIs (HealthKit, HomeKit, GraphQL)
Wait for response before proceeding.
After reading the reference, apply those patterns to the user's specific context.
When designing an agent-native system, verify these before implementation:
Tool Design
Action Parity
UI Integration
Context Injection
Mobile (if applicable)
When designing architecture, explicitly address each checkbox in your plan.
Step 1: Define primitive tools
const tools = [
tool("read_file", "Read any file", { path: z.string() }, ...),
tool("write_file", "Write any file", { path: z.string(), content: z.string() }, ...),
tool("list_files", "List directory", { path: z.string() }, ...),
];
Step 2: Write behavior in the system prompt
## Your Responsibilities
When asked to organize content, you should:
1. Read existing files to understand the structure
2. Analyze what organization makes sense
3. Create appropriate pages using write_file
4. Use your judgment about layout and formatting
You decide the structure. Make it good.
Step 3: Let the agent work
query({
prompt: userMessage,
options: {
systemPrompt,
mcpServers: { files: fileServer },
permissionMode: "acceptEdits",
}
});
All references in references/:
Core Patterns:
Agent-Native Disciplines:
The positive rules above (essential principles + architecture checklist)
already state what to do. For the inverse — what each rule looks like when
violated, with a paired ❌/✅ code or prose example for each — see
EXAMPLES.md.
The pairs cover: the cardinal sin (agent executes your workflow), artificial
capability limits, encoding decisions in tools, over-specifying in prompts,
context starvation, orphan features, sandbox isolation, silent actions,
capability hiding, static tool mapping, and incomplete CRUD.
Core Prompt-Native Criteria:
Tool Design Criteria:
Agent-Native Criteria:
Mobile-Specific Criteria (if applicable):
1---2name: agent-native-architecture3description: This skill should be used when building AI agents using prompt-native architecture where features are defined in prompts, not code. Use it when creating autonomous agents, designing MCP servers, implementing self-modifying systems, or adopting the "trust the agent's intelligence" philosophy.4---56<pointer>7> See [EXAMPLES.md](./EXAMPLES.md) for ❌/✅ pairs illustrating every8> anti-pattern named below.9</pointer>1011<essential_principles>12## The Prompt-Native Philosophy1314Agent native engineering inverts traditional software architecture. Instead of writing code that the agent executes, you define outcomes in prompts and let the agent figure out HOW to achieve them.1516### The Foundational Principle1718**Whatever the user can do, the agent can do. Many things the developer can do, the agent can do.**1920Don't artificially limit the agent. If a user could read files, write code, browse the web, deploy an app—the agent should be able to do those things too. The agent figures out HOW to achieve an outcome; it doesn't just call your pre-written functions.2122### Features Are Prompts2324Each feature is a prompt that defines an outcome and gives the agent the tools it needs. The agent then figures out how to accomplish it.2526**Traditional:** Feature = function in codebase that agent calls27**Prompt-native:** Feature = prompt defining desired outcome + primitive tools2829The agent doesn't execute your code. It uses primitives to achieve outcomes you describe.3031### Tools Provide Capability, Not Behavior3233Tools should be primitives that enable capability. The prompt defines what to do with that capability.3435**Wrong:** `generate_dashboard(data, layout, filters)` — agent executes your workflow36**Right:** `read_file`, `write_file`, `list_files` — agent figures out how to build a dashboard3738Pure primitives are better, but domain primitives (like `store_feedback`) are OK if they don't encode logic—just storage/retrieval.3940### The Development Lifecycle41421. **Start in the prompt** - New features begin as natural language defining outcomes432. **Iterate rapidly** - Change behavior by editing prose, not refactoring code443. **Graduate when stable** - Harden to code when requirements stabilize AND speed/reliability matter454. **Many features stay as prompts** - Not everything needs to become code4647### Self-Modification (Advanced)4849The advanced tier: agents that can evolve their own code, prompts, and behavior. Not required for every app, but a big part of the future.5051When implementing:52- Approval gates for code changes53- Auto-commit before modifications (rollback capability)54- Health checks after changes55- Build verification before restart5657### When NOT to Use This Approach5859- **High-frequency operations** - thousands of calls per second60- **Deterministic requirements** - exact same output every time61- **Cost-sensitive scenarios** - when API costs would be prohibitive62- **High security** - though this is overblown for most apps63</essential_principles>6465<intake>66What aspect of agent native architecture do you need help with?67681. **Design architecture** - Plan a new prompt-native agent system692. **Create MCP tools** - Build primitive tools following the philosophy703. **Write system prompts** - Define agent behavior in prompts714. **Self-modification** - Enable agents to safely evolve themselves725. **Review/refactor** - Make existing code more prompt-native736. **Context injection** - Inject runtime app state into agent prompts747. **Action parity** - Ensure agents can do everything users can do758. **Shared workspace** - Set up agents and users in the same data space769. **Testing** - Test agent-native apps for capability and parity7710. **Mobile patterns** - Handle background execution, permissions, cost7811. **API integration** - Connect to external APIs (HealthKit, HomeKit, GraphQL)7980**Wait for response before proceeding.**81</intake>8283<routing>84| Response | Action |85|----------|--------|86| 1, "design", "architecture", "plan" | Read [architecture-patterns.md](./references/architecture-patterns.md), then apply Architecture Checklist below |87| 2, "tool", "mcp", "primitive" | Read [mcp-tool-design.md](./references/mcp-tool-design.md) |88| 3, "prompt", "system prompt", "behavior" | Read [system-prompt-design.md](./references/system-prompt-design.md) |89| 4, "self-modify", "evolve", "git" | Read [self-modification.md](./references/self-modification.md) |90| 5, "review", "refactor", "existing" | Read [refactoring-to-prompt-native.md](./references/refactoring-to-prompt-native.md) |91| 6, "context", "inject", "runtime", "dynamic" | Read [dynamic-context-injection.md](./references/dynamic-context-injection.md) |92| 7, "parity", "ui action", "capability map" | Read [action-parity-discipline.md](./references/action-parity-discipline.md) |93| 8, "workspace", "shared", "files", "filesystem" | Read [shared-workspace-architecture.md](./references/shared-workspace-architecture.md) |94| 9, "test", "testing", "verify", "validate" | Read [agent-native-testing.md](./references/agent-native-testing.md) |95| 10, "mobile", "ios", "android", "background" | Read [mobile-patterns.md](./references/mobile-patterns.md) |96| 11, "api", "healthkit", "homekit", "graphql", "external" | Read [mcp-tool-design.md](./references/mcp-tool-design.md) (Dynamic Capability Discovery section) |9798**After reading the reference, apply those patterns to the user's specific context.**99</routing>100101<architecture_checklist>102## Architecture Review Checklist (Apply During Design)103104When designing an agent-native system, verify these **before implementation**:105106### Tool Design107- [ ] **Dynamic vs Static:** For external APIs where agent should have full user-level access (HealthKit, HomeKit, GraphQL), use Dynamic Capability Discovery. Only use static mapping if intentionally limiting agent scope.108- [ ] **CRUD Completeness:** Every entity has create, read, update, AND delete tools109- [ ] **Primitives not Workflows:** Tools enable capability, they don't encode business logic110- [ ] **API as Validator:** Use `z.string()` inputs when the API validates, not `z.enum()`111112### Action Parity113- [ ] **Capability Map:** Every UI action has a corresponding agent tool114- [ ] **Edit/Delete:** If UI can edit or delete, agent must be able to too115- [ ] **The Write Test:** "Write something to [app location]" must work for all locations116117### UI Integration118- [ ] **Agent → UI:** Define how agent changes reflect in UI (shared service, file watching, or event bus)119- [ ] **No Silent Actions:** Agent writes should trigger UI updates immediately120- [ ] **Capability Discovery:** Users can learn what agent can do (onboarding, hints)121- [ ] **Shared Workspace:** Agent and user operate on the same files/data. No isolated `agent_output/` sandbox — see [`shared-workspace-architecture.md`](./references/shared-workspace-architecture.md).122123### Context Injection124- [ ] **Available Resources:** System prompt includes what exists (files, data, types)125- [ ] **Available Capabilities:** System prompt documents what agent can do with user vocabulary126- [ ] **Dynamic Context:** Context refreshes for long sessions (or provide `refresh_context` tool)127128### Mobile (if applicable)129- [ ] **Background Execution:** Checkpoint/resume pattern for iOS app suspension130- [ ] **Permissions:** Just-in-time permission requests in tools131- [ ] **Cost Awareness:** Model tier selection (Haiku/Sonnet/Opus)132133**When designing architecture, explicitly address each checkbox in your plan.**134</architecture_checklist>135136<quick_start>137Build a prompt-native agent in three steps:138139**Step 1: Define primitive tools**140```typescript141const tools = [142 tool("read_file", "Read any file", { path: z.string() }, ...),143 tool("write_file", "Write any file", { path: z.string(), content: z.string() }, ...),144 tool("list_files", "List directory", { path: z.string() }, ...),145];146```147148**Step 2: Write behavior in the system prompt**149```markdown150## Your Responsibilities151When asked to organize content, you should:1521. Read existing files to understand the structure1532. Analyze what organization makes sense1543. Create appropriate pages using write_file1554. Use your judgment about layout and formatting156157You decide the structure. Make it good.158```159160**Step 3: Let the agent work**161```typescript162query({163 prompt: userMessage,164 options: {165 systemPrompt,166 mcpServers: { files: fileServer },167 permissionMode: "acceptEdits",168 }169});170```171</quick_start>172173<reference_index>174## Domain Knowledge175176All references in `references/`:177178**Core Patterns:**179- **Architecture:** [architecture-patterns.md](./references/architecture-patterns.md)180- **Tool Design:** [mcp-tool-design.md](./references/mcp-tool-design.md) - includes Dynamic Capability Discovery, CRUD Completeness181- **Prompts:** [system-prompt-design.md](./references/system-prompt-design.md)182- **Self-Modification:** [self-modification.md](./references/self-modification.md)183- **Refactoring:** [refactoring-to-prompt-native.md](./references/refactoring-to-prompt-native.md)184185**Agent-Native Disciplines:**186- **Context Injection:** [dynamic-context-injection.md](./references/dynamic-context-injection.md)187- **Action Parity:** [action-parity-discipline.md](./references/action-parity-discipline.md)188- **Shared Workspace:** [shared-workspace-architecture.md](./references/shared-workspace-architecture.md)189- **Testing:** [agent-native-testing.md](./references/agent-native-testing.md)190- **Mobile Patterns:** [mobile-patterns.md](./references/mobile-patterns.md)191</reference_index>192193<anti_patterns>194## What NOT to Do195196The positive rules above (essential principles + architecture checklist)197already state what to do. For the inverse — what each rule looks like when198violated, with a paired ❌/✅ code or prose example for each — see199[EXAMPLES.md](./EXAMPLES.md).200201The pairs cover: the cardinal sin (agent executes your workflow), artificial202capability limits, encoding decisions in tools, over-specifying in prompts,203context starvation, orphan features, sandbox isolation, silent actions,204capability hiding, static tool mapping, and incomplete CRUD.205</anti_patterns>206207<success_criteria>208You've built a prompt-native agent when:209210**Core Prompt-Native Criteria:**211- [ ] The agent figures out HOW to achieve outcomes, not just calls your functions212- [ ] Whatever a user could do, the agent can do (no artificial limits)213- [ ] Features are prompts that define outcomes, not code that defines workflows214- [ ] Tools are primitives (read, write, store, call API) that enable capability215- [ ] Changing behavior means editing prose, not refactoring code216- [ ] The agent can surprise you with clever approaches you didn't anticipate217- [ ] You could add a new feature by writing a new prompt section, not new code218219**Tool Design Criteria:**220- [ ] External APIs (where agent should have full access) use Dynamic Capability Discovery221- [ ] Every entity has full CRUD (Create, Read, Update, Delete)222- [ ] API validates inputs, not your enum definitions223- [ ] Discovery tools exist for each API surface (`list_*`, `discover_*`)224225**Agent-Native Criteria:**226- [ ] System prompt includes dynamic context about app state (available resources, recent activity)227- [ ] Every UI action has a corresponding agent tool (action parity)228- [ ] Agent tools are documented in the system prompt with user vocabulary229- [ ] Agent and user work in the same data space (shared workspace)230- [ ] Agent actions are immediately reflected in the UI (shared service, file watching, or event bus)231- [ ] The "write something to [app location]" test passes for all locations232- [ ] Users can discover what the agent can do (capability hints, onboarding)233- [ ] Context refreshes for long sessions (or `refresh_context` tool exists)234235**Mobile-Specific Criteria (if applicable):**236- [ ] Background execution handling implemented (checkpoint/resume)237- [ ] Permission requests handled gracefully in tools238- [ ] Cost-aware design (appropriate model tiers, batching)239</success_criteria>