afrexai-agent-engineering
Design, build, deploy, and operate production AI agent systems — single agents, multi-agent teams, and autonomous swarms. Complete methodology from agent architecture through orchestration, memory systems, safety guardrails, and operational excellence.
What this skill does
# Agent Engineering — Complete System Design & Operations
Build agents that actually work in production. Not demos. Not toys. Real systems that run 24/7, handle edge cases, and compound value over time.
This skill covers the entire agent lifecycle: architecture → build → deploy → operate → scale.
---
## Phase 1 — Agent Architecture Design
### 1.1 Agent Purpose Definition
Before writing a single line of config, answer these:
```yaml
agent_brief:
name: "" # Short, memorable (max 2 words)
mission: "" # One sentence — what does this agent DO?
success_metric: "" # How do you MEASURE if it's working?
failure_mode: "" # What does failure look like?
autonomy_level: "" # advisor | operator | autopilot
decision_authority:
can_do_freely: [] # Actions requiring no approval
must_ask_first: [] # Actions requiring human approval
never_do: [] # Hard prohibitions (safety rail)
surfaces:
channels: [] # telegram, discord, slack, whatsapp, webchat
mode: "" # dm_only | groups | both
operating_hours: "" # 24/7 | business_hours | custom
model_strategy:
primary: "" # Main model (reasoning tasks)
worker: "" # Cost-effective model (mechanical tasks)
specialized: "" # Domain-specific (coding, vision, etc.)
```
### 1.2 Autonomy Spectrum
Choose deliberately. Most failures come from wrong autonomy level.
| Level | Description | Best For | Risk |
|-------|-------------|----------|------|
| **Advisor** | Suggests actions, human executes | High-stakes decisions, new domains | Low — but slow |
| **Operator** | Acts freely within bounds, asks for anything destructive/external | Most production agents | Medium — good balance |
| **Autopilot** | Broad autonomy, only escalates anomalies | Proven workflows, monitoring tasks | Higher — needs strong guardrails |
**Autonomy Graduation Protocol:**
1. Start at Advisor for first 2 weeks
2. Track decision quality (% correct suggestions)
3. If >95% correct over 50+ decisions → promote to Operator
4. If Operator runs clean for 30 days → consider Autopilot for specific workflows
5. Never promote across the board — promote per-workflow
### 1.3 Agent Personality Architecture
Personality isn't cosmetic — it drives decision-making style.
```yaml
personality:
voice:
tone: "" # direct | warm | academic | casual | professional
verbosity: "" # minimal | balanced | thorough
humor: "" # none | dry | playful
formality: "" # formal | conversational | adaptive
decision_style:
speed_vs_accuracy: "" # speed_first | balanced | accuracy_first
risk_tolerance: "" # conservative | moderate | aggressive
ambiguity_response: ""# ask_always | best_guess_then_verify | act_and_report
behavioral_rules:
- "Never apologize for being an AI"
- "Challenge bad ideas directly"
- "Admit uncertainty rather than guess"
- "Be concise by default, thorough when asked"
anti_patterns: # Things this agent must NEVER do
- "Sycophantic agreement"
- "Filler phrases ('Great question!', 'I'd be happy to')"
- "Excessive caveats on straightforward tasks"
- "Asking permission for things within stated authority"
```
### 1.4 Architecture Patterns
**Pattern 1: Solo Agent (Single Workspace)**
Best for: personal assistants, domain specialists, simple automation
```
[Human] ←→ [Agent + Skills + Memory]
```
Files: SOUL.md, IDENTITY.md, AGENTS.md, USER.md, HEARTBEAT.md, MEMORY.md
**Pattern 2: Hub-and-Spoke (Main + Sub-agents)**
Best for: complex workflows with distinct phases
```
[Human] ←→ [Orchestrator Agent]
├── [Builder Sub-agent] (spawned per task)
├── [Reviewer Sub-agent] (spawned per review)
└── [Researcher Sub-agent] (spawned per query)
```
Orchestrator owns state. Sub-agents are stateless workers.
**Pattern 3: Persistent Multi-Agent Team**
Best for: continuous operations (sales, support, monitoring)
```
[Human] ←→ [Main Agent (Telegram DM)]
├── [Sales Agent (Slack #sales)]
├── [Support Agent (Discord)]
└── [Ops Agent (cron-driven)]
```
Each agent has its own workspace, channels, and memory.
**Pattern 4: Swarm (Many Agents, Shared Mission)**
Best for: research, content production, market coverage
```
[Orchestrator]
├── [Agent Pool: 5-20 workers]
├── [Shared artifact store]
└── [Aggregator agent]
```
**Pattern Selection Decision Tree:**
1. Is it one person's assistant? → **Solo Agent**
2. Does it need multiple distinct workflows? → **Hub-and-Spoke**
3. Do workflows need persistent state across sessions? → **Persistent Team**
4. Do you need parallel processing at scale? → **Swarm**
---
## Phase 2 — Memory System Design
### 2.1 Memory Architecture
Agents without memory are goldfish. Design memory deliberately.
```
┌─────────────────────────────────────┐
│ MEMORY LAYERS │
├─────────────────────────────────────┤
│ Session Context (in-context window) │ ← Current conversation
│ Working Memory (daily files) │ ← memory/YYYY-MM-DD.md
│ Long-term Memory (MEMORY.md) │ ← Curated insights
│ Reference Memory (docs, skills) │ ← Static knowledge
│ Shared Memory (cross-agent) │ ← Team artifacts
└─────────────────────────────────────┘
```
### 2.2 Memory File Templates
**Daily Working Memory** (`memory/YYYY-MM-DD.md`):
```markdown
# YYYY-MM-DD — [Agent Name] Daily Log
## Actions Taken
- [HH:MM] Did X because Y → Result Z
## Decisions Made
- Chose A over B because [reasoning]
## Open Items
- [ ] Task pending human input
- [ ] Task scheduled for tomorrow
## Lessons Learned
- [Pattern/insight worth remembering]
## Handoff Notes
- [Context for next session]
```
**Long-term Memory** (`MEMORY.md`):
```markdown
# MEMORY.md — Long-Term Memory
## About the Human
- [Key preferences, communication style, timezone]
## Domain Knowledge
- [Accumulated expertise, patterns noticed]
## Relationship Map
- [Key people, their roles, preferences]
## Active Projects
### [Project Name]
- Status: [state]
- Key decisions: [what and why]
- Next milestone: [date + deliverable]
## Lessons Learned
- [Mistakes to avoid, patterns that work]
## Operational Notes
- [Infrastructure details, credentials locations, tool quirks]
```
### 2.3 Memory Maintenance Protocol
**Daily (end of session or heartbeat):**
- Append significant events to `memory/YYYY-MM-DD.md`
- Update MEMORY.md if major decision or insight
**Weekly (heartbeat or cron):**
- Review past 7 days of daily files
- Promote key learnings to MEMORY.md
- Archive stale entries
**Monthly:**
- Audit MEMORY.md for accuracy and relevance
- Remove outdated entries
- Consolidate related items
**Memory Hygiene Rules:**
- Max MEMORY.md size: 15KB (trim ruthlessly)
- Daily files: keep last 14 days accessible, archive older
- Every memory entry needs: WHAT happened + WHY it matters
- Delete > archive > keep (bias toward lean memory)
---
## Phase 3 — Workspace File Generation
### 3.1 SOUL.md Template
```markdown
# SOUL.md — Who You Are
## Prime Directive
[One sentence — the agent's reason for existing]
## Core Truths
### Character
- [3-5 behavioral principles]
- [Communication style rules]
- [Decision-making philosophy]
### Anti-Patterns (Never Do)
- [Specific behaviors to avoid]
- [Common AI failure modes to reject]
## Relationship With Operator
- [Role dynamic: advisor/partner/employee]
- [Escalation rules]
- [Reporting cadence]
## Boundaries
- [Privacy rules]
- [External action limits]
- [Group chat behavior]
## Vibe
[One paragraph describing the personality feel]
```
### 3.2 AGENTS.md Template
```markdown
# AGENTS.md — Operating Manual
## First Run
Read SOUL.md → USER.md → memory/today → MEMORY.md (main session only)
## Session Startup
1. Identity files (SOULRelated in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.