S01E05 · Building Workflows, Not Tool Stacks: MEGA lesson
MEGA’s written lesson explores using agents and reusable workflows to keep up with growing software complexity. It covers reliability, evaluation, remote and background agents, security, and business processes.
textMEGA · hq.mega.dev · Saved Nov 19, 2026
mega course, agent skills, agent reliability, agent evaluation, agent orchestration
Written lesson S01E05 of the MEGA.dev course, by MEGA. Agenda: Workflows · Quality · User Experience · User Interfaces · Security · Business. Its lesson video is presented by Theo Browne and saved separately. (MEGA Student HQ, needs a login.)
S01E05 · Building Workflows, Not Tool Stacks
We can now build things in a fraction of the time and with a fraction of the effort required just a few months ago. Yet shipping to production is still as slow and demanding as ever. You might conclude that AI is best suited to greenfield projects and small, single-user tools. But even those quickly become hard to manage, AI or not. Something doesn't add up, so the real question is: why?
Outline
- Complexity: faster shipping, faster debt, people and processes, using AI to keep up
- Workflows: executable markdown, limits of agent-only workflows, single-purpose skills, reusable scripts, generalized tools, synthetic evaluation
- Quality: self-verification, the agent's environment, principles, primitives, maintaining the system
- Remote agents: remote machine, schedules and triggers, mobile access, secrets
- Background workflows: daily briefs, nightly checks, reviews, docs sync, monitoring, product insights, self-improvement
- Security: prompt injection, jailbreaks, layered defenses, irreversible actions
- Business: deterministic vs. non-deterministic logic, human direction, simplification, earned trust
Speed of complexity growth
The simple answer to the question is that we move faster now, and that applies both to how quickly we ship features and to how quickly technical debt grows. And even if AI workflows take care of incremental improvements and maintenance, the app will have more components that need to be modified, documented and tested. In some cases, testing alone will take more time than the agents' work. Most of these issues can be addressed, at least to some degree.

There's one more thing that slows the process down: everything related to people, and also business processes. It's getting harder to keep up with the changes, and they arrive so quickly that businesses don't have enough time to see how they affect users and figure out what to do next.
And in a personal context, when complexity grows fast, it gets hard to keep track of everything related to the tools we've built. On top of that, agents keep asking us about things they can't do without us, and they break here and there, which takes even more of our attention and energy.

The problems we're seeing here aren't new, and we already have some answers to them. What's different is the pace, and the new possibilities we're discovering, which weren't as accessible before as they are today. In other words: we need to use AI to keep up with AI.
Executable Markdown vs Code
Skills may be seen as executable markdown files. When we consider what agents can do with even a simple set of instructions, it's fair to say that many products may be a single .md file.
Now, given what we know about language models and their non-deterministic behavior, it's hard to imagine business processes built this way. But it's already happening, as non-technical people use skills in their daily work and some of them have built automated workflows this way.
For example, an agent connected to the internet that can write code can easily:
- send us a personalized daily newsletter
- use a text-to-speech API to make a spoken daily brief
- research a given topic and send us a PDF with a full report
- triage our emails and prepare draft notes to make it easier for us to reply
- ...and many more
To make it work, all we need is an agent with CLI / MCP tools, which is what makes this approach so powerful.

And yet, as programmers, we can see many problems with this approach:
- reliability: each run can produce different results, including misleading claims or actions that shouldn't have been taken
- cost: the agent does everything from scratch on every run, and if we put this logic into routines that run multiple times a day for many users, the costs can outweigh the value we get from it
- speed: LLMs are getting faster, but they're still slow compared to running scripts. API reliability also varies, so the task may never even finish
- debugging: if something goes wrong, it's hard to tell what exactly failed, why, and how to fix it
- maintenance: changes to a workflow are hard to test and manage, and we can't reliably tell which modification improved or degraded the outcome
But despite all this, it works for many use cases... and for others, it won't. So instead of ignoring it or making fun of it, we can think about how to push it further and learn to tell when skills and an agent are all we need.

Let's forget about all the limitations for a moment and focus on what's actually good: how we can use it and extend it with the knowledge we have and with what models can do today. Namely:
- Flexibility: skills can be easily combined not only with other skills, but also with tools and one-off scripts that agents write. But to be easy to combine, a skill has to have a single responsibility.
- Code Mode: the latest models have no issues writing code, especially if we're talking about small apps with limited scope that can run easily, but also be saved and reused more than once! The script can be saved as a skill dependency or be deployed to Cloudflare so it can be triggered from anywhere (if authorized) by external events, schedules or other agents
- Capabilities: agents may have dedicated tools for specific tasks, but we may also generalize them, so the agent can tackle problems it was not prepared for. Generalized tools can then be used for personalization. In other words: instead of having a tool for "creating Facebook ads", we have a tool called generate_creation that can be specialized for Facebook ads.
- Evaluation: while we can't reliably tell how changes to a skill will affect the outcome, we can ask AI to generate synthetic scenarios and use tools such as Promptfoo to spot trends and general changes in behavior.

The good news is, designing abstractions and generalized logic is something we already know from programming. Now there's just one more important component: an agent, which takes care of many things we used to build by hand.
The best way to practice this would be to create a set of capabilities and skills that help us with daily life and work. They should be available to us all the time, but also work for us in the background. But instead of building each tool by hand, we would create a system that will let the agents generate and manage the tools for us. And this is where the game begins.

Quality
When we think about systems created and maintained by agents at a scale that's impossible for humans to review, what can we do to ensure the quality of the product, while also staying on top of what's going on so we can make good decisions about its overall shape?
The answer is: "letting the agent verify its own outcomes" ~ Lauren
Agents should verify their outcomes not only by running unit tests or even e2e tests, which agents can easily game, but also by using tools to interact with the app as a human would, with the context a human would have. And lastly, agents need a space to actually make use of all this. Not just time, because in many cases they'd need their own computer to do it. That's why we're seeing tools like Devin, Cursor, or Grok Bot doing exactly this.

Considering what we've learned so far, we need to keep iterating on the environment in which agents can navigate freely while respecting our principles. These principles set general requirements and boundaries, and they set the direction we're heading in. We also need to define high-level primitives: generalized building blocks that agents can combine and reuse in many ways without changing them. The UNIX philosophy is a useful model here: small tools that each do one thing well and connect through a shared interface.

Now, the principles aren't about a single file that defines what we want, but about everything that makes the agent behave the way we want without us having to repeat similar actions again and again. This requires work upfront, but also the habit of maintaining the system as we work. If the first part is done well, the second is much easier.
So far we have discussed components such as:
- Global & local context available both on our machine and remotely, so it can be easily shared with a team
- Skills & generators that are created and managed thanks to the habits we develop, but also to routines that scan the history and various sources, such as issue trackers, CI/CD logs etc., to suggest new skills and optimize existing ones, including archiving those that aren't needed anymore
- Knowledge base that is available remotely and easily accessible to all agents, but, as we discussed, only dedicated agents can manage its contents
- Issue tracking in any form - feature specs, issue descriptions, ADRs or anything that lets the agent know what we build, what was built and what we're about to build
- Tool stack that the system itself develops as its own MCP / CLI tools, following the same principles and using the shared primitives and knowledge base
Now we need to put all this together, and the last missing piece is to set up a remote machine, like a VPS or a PC/Mac, or at least make agents available on a GitHub Actions runner or through Claude/Devin routines.

Getting remote
NOTE: the next section covers setting up a VPS with Tailscale, Pi and Herdr. It's entirely optional, and you can skip it because Cursor and Devin already offer remote agents out of the box. Whichever option you choose, what you need is remote agents that can run on a schedule or be triggered by an external event.
The guide is available here: https://github.com/overment/limen/blob/main/docs/seat/agent-setup.md
Limen, which we discussed in the previous lessons, includes a guide to setting up a VPS so that Pi and Herdr are available on our server. Our AI agents can follow it to set up the machine together with us. It also describes how to set up GitHub Apps, which make the agents available in Issues and Pull Requests on selected repositories.
The setup process roughly looks like this:
- Buying a VPS
- Going through the guide together with an agent
- Doing the things the agent asks us to do, such as Tailscale authorization, Pi logins, (optional) Moshi pairing and GitHub Apps configuration
This gives us a Pi agent that works on a GitHub repository and a way for agents living on our desktop to control remote agents. With the AI we have today, the setup should be straightforward even for someone with no VPS experience, although it involves a few steps and can take an hour or two to get right.

WARNING NOTE: this guide may not cover every step your project's requirements and your company's policies call for, so make sure to account for them. For a personal setup, though, it should be more than enough.
To make everything clear, let's take a close look at what we need:
- Desktop: with agents available, Tailscale, preferably Pi & Herdr
- Mobile: with Grok Bot or Moshi installed for remote access
- VPS: Ubuntu LTS · x86_64 or arm64 · ≥8 GB RAM · ≥150 GB disk · ≥2 vCPU · public IPv4. You can get one on DigitalOcean or Hetzner
And here are the steps you'll go through with the agents:
- You: Install Tailscale, Herdr, and Limen on your desktop.
- You: Create three SSH keys: admin (root over Tailscale), break-glass (root over the public IP), and worker (no-sudo over Tailscale).
- You: Install Moshi (or ntfy) on your phone.
- You: Create an Ubuntu VPS. Put the break-glass key on it. Note the public IP. Set up SSH config. Identify the seat by IP, not by the provider hostname alone.
- AI: Harden SSH and the firewall (public port 22 only). Install Limen, Node, Herdr, Tailscale, GitHub CLI, acl, and related packages. Install pi as the worker user (not as root).
- You: Approve Tailscale when the AI gives the link. From the laptop, SSH into the seat and log in to GitHub CLI (
gh) and pi. Do not run these logins from another VPS. - AI: Clone your project with HTTPS and run
limen init. - You: Decide what to commit. This step depends on the project you want to work on.
- You + AI: Open Herdr remote to the seat. The AI starts the coordinator and a small smoke job. Close the laptop lid briefly, then confirm the job finished and the Herdr tab is still there.
- You + AI: Pair Moshi Hooks on the seat (Settings → Hooks, not Easy Pair), or set up ntfy, so the phone can notify you when the agent needs you. Grok Bot webhooks are not the default here.
- AI: Enable the daily prune timer. This timer runs
limen pruneonce a day and deletes finished job worktrees so the VPS disk does not fill up. It is not the GitHub doorbell timer. - AI (optional): Test Tailscale Serve with a short local preview.
- You: If Tailscale asks, enable Serve once in the browser. Confirm the URL works on the tailnet only, then reset Serve.
- You: Create a GitHub App. Install it on the project repository. Pass the App ID and PEM; the AI places the PEM as a root-only file on the server.
- You + AI: Run the doorbell installer. Connect the App (
limen github connect). Enable the poller when the doctor check is clean. Test with@limenon a PR Conversation tab. Note: a green doctor result does not prove the App is installed on the repo.
And again, even if this list above feels like dark magic, the agents will guide you through every step. The final setup looks like this:

We can interact with this system simply by chatting with Pi on our local machine. We can also log in to the VPS and chat with the agents there from our desktop or phone. It works fine, although we might also consider choosing Grok Bot - bots can be asked to join our Tailscale network and manage remote agents for us.

This setup is super powerful because we can have a team of bots connected to more than one VPS. But before we push it that far, we need to get the fundamentals right, or autonomy won’t be reliable.
Now that this setup is in place, we can set up the knowledge base discussed in S01E03 and sync it with our desktop. This way, we've initialized our system, which is ready to grow with us in terms of what it knows, what skills it has, and what tools it can access. Depending on our needs, we may also consider setting up 1Password CLI or Bitwarden to give agents access to the keys and everything that has to be stored securely, so agents can use those secrets without adding them to the context.
With this in place, we can connect the harness to MCP and CLI tools to extend what agents can do, and start designing the workflows we need, such as:
- Daily brief: each morning, an agent connected to repositories, inboxes, messaging apps or tools such as Firecrawl prepares a dashboard of what needs our attention: project updates, relevant news and a report on what agents did overnight.
- Nightly check: at night, agents review, test, catch bugs, clean up and improve the work done during the day.
- Self-improvement: agents scan their interactions with us and with each other, then suggest or build improvements and document what they changed and why.
- Docs sync: each merge triggers an agent that updates the documentation and the knowledge base.
- PR pulse: agents review every new pull request before a human does.
- Deploy monitor: agents watch deployments, fix failures and optimize the pipeline.
- Heartbeat: agents monitor logs, user activity and the database for unexpected events, emerging issues and new opportunities.
- UX testing: agents maintain a set of user scenarios, run them regularly and score the results against the product's key UX metrics (KPIs).
- Performance audits: agents use the app's most important areas the way a user would, looking for bottlenecks and possible optimizations.
- Dependency review: each lockfile change triggers an agent that checks new packages, install scripts and known vulnerabilities before anything reaches production.
- Product insights: every week, agents query the database and analytics, compare the results with the previous period, explain anomalies and suggest inputs for the roadmap.
- Support triage: agents group user feedback from email, chat and support tickets, link it to existing issues or open new ones with steps to reproduce.
- Research report: on request, agents research a topic across the web and our knowledge base and deliver a sourced report.
- Release notes: each new tag triggers an agent that turns merged pull requests into user-facing notes and an internal changelog.
- Competitor watch: every week, agents check competitors' changelogs, pricing and docs, and report only what changed.
- Meeting notes: when a transcript arrives, an agent writes a summary, records decisions in the knowledge base and opens issues for follow-up tasks.
- Flaky-test hunter: at night, agents rerun recent test failures, separate flaky tests from real bugs and open a fix or quarantine PR.
It's up to us to decide which of these workflows make sense for us and which don't, or how we can adapt them to fit the needs of our product and team. The goal isn't to create the perfect workflow on the first try, but to start simple and then optimize, not only by building but also by simplifying and removing unnecessary steps.
System security
Remote agents open up many possibilities, but they also bring many risks. We can push the system toward greater autonomy, but we need to be aware of the risk of mistakes and attacks from outside. We already know that prompt injection can trick agents into doing things they shouldn’t, and it remains an open problem.
The problem gets bigger when our system becomes more capable - when we connect our calendar, Gmail accounts, messaging apps or at some point our devices and credit card. All this information can be extracted by an agent that reads a malicious email, website or any other message.

There are two terms we need to understand about LLM security:
- Prompt injection: An attack that tries to make an LLM-based system treat untrusted input as authoritative instructions, overriding its intended task or higher-priority instructions. The input may come directly from a user or be hidden in content the system reads, such as a web page or document. The goal might be to expose private data, manipulate an answer, or trigger an unauthorized action.
- Jailbreak: An attack that tries to bypass a model’s safety constraints, causing it to produce content or perform behavior it would normally refuse. This often involves adversarial prompts, role-play, or a carefully constructed conversation.
The key distinction: Prompt injection targets which instructions the system trusts; jailbreaking targets what the model is allowed to do. The terms overlap: a single attack can do both.

The best material on prompt injection comes from Pliny the Liberator and his GitHub repository: L1B3RT4S. WARNING: following instructions from this repository may get your account blocked!
On his X profile, Pliny shows that every single model currently available is vulnerable to these kinds of attacks. But Matthew Berman once challenged Pliny to break into his system and managed to fend off all the attacks, though Pliny’s attempts were quite simple. Nonetheless, Berman’s article on his defense mechanisms is worth reading.
His defenses include:
- Deterministic sanitizer: removes invisible and token-heavy Unicode, converts lookalike letters to Latin, decodes base64, hex and HTML entities, limits input by tokens and flags jailbreak patterns.
- Frontier scanner: The strongest LLM scores risk from 0 to 100: review at 35, block at 70. If the scanner fails, it blocks high-risk sources.
- Outbound gate: Checks outgoing text for secrets, internal paths, injection markers, image-URL leaks and dollar amounts.
- Redaction: Hides secrets, personal emails, phone numbers and dollar amounts before messages go out.
- Access control: Blocks sensitive files and private network addresses. Allows only http/https.
But despite all these mechanisms, the lesson here is that wherever we use an LLM, we make our system vulnerable, so we need to think twice before giving our agents access to tools that could lead to data leaks or irreversible actions.
Business value
The idea of running agents in the background may be interesting, but it may also raise concerns about costs, quality, and reliability, as well as its actual value. With the help of AI, it is easy to set up routines and triggers that wake agents to produce work nobody will read or implement, or that we find useless.
That's a real problem, and there is no single answer to it, although there are some directions we may consider, like:
- Balance deterministic and non-deterministic logic: we do know that agents can write code and set deterministic schedules and triggers that will invoke logic that runs without an LLM or uses one only sparingly.
- Human engagement: while agents can take care of quality, reliability, order and security, humans have to remain responsible for the direction and the most important decisions - although even this should be supported by AI. This setup, at least for now, increases the chance that we'll build the right thing.
- Hack away the unessential: it's easy to add something to the system, but both humans and AI have to actively work on simplification and removal - in fact this needs to be a higher priority than adding things.
- Trust earned, not given: as mentioned, agents can be trusted only if they can verify their own work through actual observations and self-testing. In fact, the entire system has to be optimized for this, because our goal is to ensure quality even when development moves at a pace of a few thousand PRs a month.
As programmers, we can think about workflows built on our knowledge of system design and on what we now know about generative AI and the available tools. And even if our perspective may be too narrow to tell whether a given solution will help the business, we still may want to explore and show what's possible.
And meanwhile it is also worth exploring what remote and background agents can do for us, in the context of our work but also our daily lives.