DEV Community

Pawel Jozefiak
Pawel Jozefiak

Posted on • Originally published at thoughts.jock.pl

When Your AI Agent Starts Fixing Itself: A Week of Rebuilding Wiz

When Your AI Agent Starts Fixing Itself: A Week of Rebuilding Wiz

Originally published on Digital Thoughts


I spent a week dismantling my personal AI agent and reconstructing it from the ground up. Not because something broke — because I wanted to see how far I could push it.

The result: Wiz now creates new capabilities when it identifies gaps. It systematically logs and resolves its own errors. It executes multiple tasks simultaneously instead of sequentially. And it transitioned from a custom folder architecture to Claude Code's native system.

This post shares real code, actual file paths, and genuine architectural decisions.

The Starting Point: What Was Broken

I previously documented building Wiz as a personal AI agent with memory and sub-agents. That version functioned, but weeks of daily usage exposed friction:

Skill system inefficiency: Custom folders required explicit loading each session. Claude Code's native ~/.claude/skills/ directory with YAML frontmatter auto-loads contextually — but I wasn't using it.

Memory bloat: I'd engineered: memory.md (short-term, ~50 lines), multiple topic files, daily archives, keyword mappings, and semantic search with local embeddings. Sophisticated engineering. Ultimately unnecessary.

Sequential task execution: Researching across three job boards meant waiting ~30 seconds between each source. Claude Code's Task tool spawns parallel sub-agents, but my architecture didn't leverage this.

I was managing infrastructure rather than using the tool effectively. Time for a complete rebuild.

The Architecture Migration: Custom to Native

Claude Code's native system uses two directories: ~/.claude/skills/ for capabilities and ~/.claude/agents/ for sub-agents. YAML frontmatter acts as the critical connector.

Here's an actual skill file (from ~/.claude/skills/typefully/SKILL.md):

---
name: typefully
description: >
  Create, schedule, and manage social media posts via Typefully.
  ALWAYS use this skill when asked to draft, schedule, post, or
  check tweets, posts, threads, or social media content.
last-updated: 2026-01-29
allowed-tools: Bash(./scripts/typefully.js:*)
---
Enter fullscreen mode Exit fullscreen mode

The description field provides the pattern-matching mechanism. When you mention "post a tweet" or "schedule something for LinkedIn," Claude Code matches against skill descriptions and auto-loads the relevant file.

I migrated 13 skills: email-automation, deployment, image-generation, notion-actions, firecrawl, web-research, content-creation, peekaboo (macOS automation), unified-recall, typefully, x-direct, shopify, and artur-jobs.

Self-Extension: Teaching the Agent to Grow Itself

This is the interesting part. I didn't just want to migrate existing skills — I wanted Wiz to construct new ones autonomously when needed.

The implementation resides in ~/.claude/CLAUDE.md. Here's the actual instruction block:

## Self-Extension (Automatic Skill Creation)

I extend my own capabilities by creating new skills. This is core to evolution.

### When to Create a Skill AUTOMATICALLY

Create a new skill when ALL of these are true:
1. Capability gap - User requests something no existing skill covers
2. Reusable - Pattern will likely be useful again (not one-off)
3. Structured - Involves clear process, API, or tool usage
4. User benefit - Saves time on future similar requests
Enter fullscreen mode Exit fullscreen mode

Real example: when asked to post to X/Twitter, no existing skill addressed this. Instead of declining, Wiz:

  1. Identified the capability gap
  2. Researched options (direct API vs Typefully for anti-bot protection)
  3. Created ~/.claude/skills/typefully/SKILL.md with complete API documentation
  4. Immediately used it for the requested task
  5. Informed me: "Created social-posting skill for future use"

The essential insight: this isn't magical. It's Claude Code plus explicit instructions plus file system access. But the behavioral outcome differs qualitatively — the agent develops new abilities when necessary rather than hitting walls.

Self-Fixing: The Error Registry System

This emerged from genuine frustration. Wiz would encounter errors and navigate around them. Same error, different day.

The solution: an error registry at /wiz/automation/self-fix/error-registry.json. Here's a real entry:

{
  "id": "err-20260130-001",
  "severity": "high",
  "category": "data_loss",
  "title": "Social Commenter data replacement instead of merge",
  "description": "When refreshing data, replaced all existing entries instead of merging.",
  "solution": "ALWAYS merge new data: newData.d = [...newEntries, ...oldData.d]. Never replace the entire array.",
  "logged_at": "2026-01-30T01:30:00Z",
  "status": "resolved"
}
Enter fullscreen mode Exit fullscreen mode

Every morning at 7:15 AM, a scheduled self-improve task runs. It reads the registry, identifies the highest-severity unfixed errors, and attempts resolution. The cycle: error occurs → gets logged with context → self-improve discovers it → fixes it → marks resolved.

Parallel Execution: Sub-Agents That Actually Work

Sub-agents represent Claude Code's mechanism for spawning parallel workers.

The concrete problem: researching across multiple job boards. Sequential execution meant each source blocked the next. Three boards at 30 seconds each = 90+ seconds total.

The solution: sub-agents in ~/.claude/agents/. Each is a markdown file with YAML frontmatter specifying: name, description, allowed tools, and model. The critical detail: model: haiku. Sub-agents don't require full Claude Sonnet — they're specialized workers. Haiku operates faster and costs less.

When spawning three scrapers simultaneously, they all execute in parallel. Results aggregate when complete. Total time = max single task (~30s), not sum (~90s). 3x faster.

Memory Simplification: Deleting What Didn't Work

The old memory system: memory.md (50+ lines), multiple topic files, daily archives, keyword mappings, and semantic search with local embeddings.

What I actually used: almost none of it.

I deleted the semantic search, embedding generation, and topic files. Current memory.md is 50 lines. Contains: preferences, current focus, and last 2-3 days of significant work. That's it.

Native architecture beats custom systems. I spent months building custom skill folders, memory structures, and context loading. Claude Code already has ~/.claude/skills/ with YAML frontmatter auto-loading. Fighting the framework costs more than learning it.

Always-On: Discord, Email, and Launchd

The rebuild also addressed availability. 11 services running via macOS launchd:

  • Discord bot — Real-time DMs. I message Wiz on Discord from my phone; it responds with full Claude processing.
  • Email watcher — IMAP IDLE connection to Gmail. Messages labeled "Agent" get processed automatically.
  • NoSleep daemon — Prevents Mac from sleeping while services run.

Plus scheduled tasks: job finder (6 AM), daily planner (6:30 AM), self-improve (7:15 AM), blog pipeline (9 AM Mon/Wed), social manager (10 AM), and hourly wake checks.

The Numbers

  • 13 skills with YAML frontmatter auto-loading
  • 6 sub-agents (Haiku-powered for cost efficiency)
  • 11 services running via launchd
  • ~50 lines of memory instead of 500+
  • 3x faster multi-source research (parallel vs sequential)
  • 1 self-created skill this week
  • 1 self-fixed error via registry

What I Actually Learned

Self-modification requires explicit instructions. The agent won't create skills or log errors unless you tell it to. But once you do, it's categorically different.

Parallel execution should be the default. Once you have sub-agents running simultaneously, sequential execution feels broken.

Simplicity beats complexity. My elaborate memory system wasn't better than a 30-line file and a task manager. The rebuild forced me to keep only what I actually used.

Always-on changes the relationship. Discord DMs and email monitoring mean Wiz is available like a coworker, not a tool.

The goal was an agent I could trust to operate independently. I'm closer than I expected.

If you want to build something similar: start with Claude Code's native architecture. Don't fight the framework. Use ~/.claude/skills/ with YAML frontmatter. Use ~/.claude/agents/ for parallel workers. Keep memory simple. Add self-extension and self-fixing instructions to your identity file.

The pieces are all there — you just have to connect them.


Building AI agents? Check out the AI Agent Blueprint — the full build guide with templates from this system.

Top comments (1)

Collapse
 
theycallmeswift profile image
Swift

Deleting the elaborate memory system you spent months on is the hardest kind of progress 😅 What was the moment you realized it wasn't pulling its weight?

Also, curious if you're worried about skill bloat leading to decreased successful outcomes over time