Universal Agent + Skills Tutorial: Build Your 10-Person Team from Scratch
Universal Agent + Skills Tutorial: Build Your 10-Person Team from Scratch
Imagine this:
You tell your AI Agent: "Write me technical documentation." It instantly loads technical-writer.skill and transforms into a tech writer.
Next moment: "Analyze our competitors' ad strategies." It swaps in marketing-analyst.skill and starts crawling data.
Even better: Need an expert in a niche domain—say, "SQL performance tuning"—but can't find one? Let the Agent write a skill for itself.
This isn't sci-fi. And it's ridiculously simple to build.
This guide shows you how to build a Universal Agent:
- ✅ Load any skill - Drop in a
.skillfile, Agent instantly gains new capabilities - ✅ Self-authoring skills - Agent can create specialized skill packages for itself
- ✅ Persistent work - Files survive across conversations—code from morning, iterate in afternoon
- ✅ Zero infrastructure - No Docker, no K8s. Just a Next.js project.
Think of it as assembling a 10-person founding team: each skill is a specialist, the Agent is the PM, you're the CEO.
Architecture
Key components:
bash-tool- In-memory filesystem with bash, readFile, writeFile- Skills in
sandbox/user/{id}/skills/(read-only, from S3) - Workspace in
sandbox/user/{id}/workspace/(read-write, persisted) - AI SDK handles streaming, tool calls, token tracking
Core Implementation
1. Skill Structure
Each skill is a .skill file (zip format) with a simple structure:
Example SKILL.md:
Upload flow: User uploads zip → Store in S3 → Reference in database → Agent loads on demand.
2. Core Route Handler
File: app/api/chat/universal/route.ts
Key points:
- Load both skills and workspace at start
- Skills isolated under
skills/prefix (read-only) - Workspace in root (read-write, persisted)
onFinishsaves all changes back to disk
3. Workspace Persistence
File: lib/skill/workspace.ts
How it works:
- Load: Read all files from disk into memory
- Agent works: Creates/modifies files in sandbox
- Save: Extract non-skill files, write back to disk
- Next request: Files reappear in sandbox
4. System Prompt
File: app/prompt/index.ts
Critical design:
- Skills as XML (Claude-native format)
- Clear workspace vs. skills separation
- Emphasize persistence behavior
- Simple, actionable instructions
Real-World Usage
Example 1: Technical Documentation
Example 2: Cross-Session Work
Example 3: Agent Creates Own Skill
Key Design Decisions
1. Why bash-tool?
Alternatives considered:
- Direct filesystem access → Security risk
- Code interpreter (Python) → Too narrow
- Full VM (@vercel/sandbox) → Overkill for file operations
Why bash-tool wins:
- In-memory, isolated sandbox
- Familiar bash commands (ls, cat, grep, find)
- No script execution (security)
- Perfect for file manipulation + exploration
2. Why Separate Skills and Workspace?
3. Why Full Workspace Sync (Not Delta)?
Reasoning:
- Simpler implementation (no change tracking needed)
- Handles deletions naturally (file missing → deleted)
- Performance: Workspace typically < 100 files, sync is fast
- Reliability: Avoids sync drift issues
4. Why Skills as Claude XML?
Claude models are trained on XML structures for tools and artifacts. This format:
- Native to Claude's training
- Easy to parse
- Extensible (add metadata without breaking)
- Familiar to Claude for skill discovery
Deployment Considerations
Docker Configuration
Challenge: bash-tool uses native modules (@mongodb-js/zstd, node-liblzma) for compression.
Solution: Don't copy native modules—they're optional.
next.config.ts:
Storage Management
Performance Benchmarks
Tested on M1 Mac, 50 skills, 200 workspace files:
| Operation | Time | Notes |
|---|---|---|
| Load skills + workspace | 120ms | Parallel I/O |
| Create 10 files | 5ms | In-memory |
| Save workspace | 80ms | Write to disk |
| Export folder (50 files) | 150ms | Zip creation |
Optimization tips:
- Cache skill files across requests (same user, same skills)
- Use streaming for large file exports
- Compress workspace with zstd if > 1MB
What's Next?
Extend the system:
- Version control: Git integration for workspace
- Skill marketplace: Share skills between users
- Collaborative workspaces: Multiple agents, one workspace
- Skill composition: Agent loads multiple skills simultaneously
- Skill inheritance: Base skills + specialized variants
The power: Every user becomes a founder with a full engineering team. Each skill is a specialist. The Agent orchestrates. The workspace persists. The possibilities compound.
Code References
- Main route:
src/app/(universal)/api/chat/universal/route.ts - Workspace persistence:
src/lib/skill/workspace.ts - Skill loading:
src/lib/skill/loadToMemory.ts - Export tool:
src/app/(universal)/tools/exportFolder.ts - System prompt:
src/app/(universal)/prompt/index.ts - README:
src/app/(universal)/README.md
Built with Next.js 15, Vercel AI SDK, bash-tool, and Claude 4.5 Sonnet.