Taming Multi-Agent Sprawl: Spec-File Relay and a Zero-Plaintext SOPS + age Secret Vault
Generative AI has compressed day-to-day software delivery timelines dramatically—from scaffolding endpoints and triaging bugs to spinning up single-page prototypes and technical docs. Yet after months of running Gemini, Cursor, Codex, and local open-weight models side by side, I hit an ironic wall: AI multiplied my raw code throughput tenfold, and promptly wrecked my personal engineering workbench first.
A few days ago, fed up with stray .env files scattered across my desktop and hundreds of half-finished agent threads, I froze all feature work for a full day to re-architect my multi-agent environment from scratch.
Here is the engineering postmortem of that overhaul: ruthless scope subtraction, replacing nested agent-in-agent CLI calls with deterministic Spec-file relays, and combining SOPS, age, and cloud sync to build a secret vault whose metadata AI agents can query freely without ever seeing a single plaintext credential.
1. The Failure Mode: 10x Code Throughput, 10x Workbench Entropy
Running Gemini as a long-context architect and research hub, Cursor/Codex for multi-file implementation, and local models for lightweight extraction produced three compounding symptoms:
- Context and artifact sprawl: My local coding agents had accumulated 260+ historical chat threads packed with stale specs, one-off patches, and overlapping refactor state. My Desktop and cloud-drive root were littered with
test_demo_v2.pyandtemp_script.shorphans. Starting work every morning meant spending 5–10 minutes doing digital archaeology just to figure out which branch or thread held the latest state. - Plaintext API keys everywhere: Evaluating new model providers and cloud sandboxes meant constantly rotating environment variables across project
.envfiles,~/.zshrc, and scratch notes. I faced a constant tug-of-war: letting workspace agents scan directories risked leaking live secrets into cloud context windows or Git commits, yet locking everything inside an opaque GUI password manager meant my coding agent couldn’t even answer “which environment variable name maps to the staging evaluation gateway?” - Raw ideas masquerading as active tasks: Whenever API quotas were plentiful, every passing idea turned into “let’s have an agent spin up a quick POC.” Within weeks I was babysitting six or seven 70%-done repositories—starving my core engineering roadmap of review bandwidth.
2. Subtraction First: Four Canonical Tracks & Separating Ideas from Tasks
Fixing entropy never starts by adding a heavier project-management tool; it starts by shrinking the surface area you agree to maintain.
1. Collapsing Everything into Four Canonical Tracks
Every repository, script, and draft on disk had to map to one of four top-level tracks—or leave the active workspace:
01-Core-Engineering(primary production systems and quality engineering)02-Open-Source(public repositories, evaluation workbenches, and standalone tools)03-Dev-Infra(multi-agent harnesses, automation scripts, and secret governance)04-Publications(technical essays, architecture diagrams, and postmortems)
Inactive experiments received an explicit [Frozen] prefix, and completed or abandoned folders moved into cold archive storage. At the same time, I pruned those 260+ local agent chat threads down to active sessions only and stripped contradictory rules out of global agent memory files.
2. One Five-Column Master Tracker
Instead of maintaining a heavyweight Kanban board, a single five-column markdown table tracks active momentum:
| Track | Current Milestone | Next Atomic Action | Status / Blocker | Entry Path |
|---|---|---|---|---|
| 03-Dev-Infra | kvault CLI wrapper complete |
Schedule daily 18:00 audit cron | In Progress | ~/projects/kvault |
3. Splitting the Idea Pool from the Execution Backlog
Dumping half-baked ideas directly into a to-do list manufactures chronic backlog guilt, while scattering them across scratch files guarantees losing good insights. Separating them into two distinct contracts solved both:
| Dimension | Idea Layer (Scratch Pool) | Task Layer (Execution Backlog) |
|---|---|---|
| Purpose | Offload working memory fast; capture raw hypotheses | Explicit engineering commitments |
| SLA | Zero deadlines, zero obligation | Bound to concrete milestones and acceptance gates |
| AI Role | Tag target track + minimum viable POC prompt | Concrete implementation steps after human sign-off |
| Lifecycle | Periodic incubation; promote only after proven value | Checked off upon verified delivery |
4. Spending Surplus Tokens Wisely: Three-Step Rate-Limited Incubation
Model tokens are cheap; human verification and architectural review bandwidth is scarce. To stop agents from mass-producing unreviewed code liabilities, new ideas pass through strict concurrency limits:
- Capture: Every new idea lands in the Scratch Pool first—never spin up a coding agent on impulse.
- Incubate (WIP = 1): At most one idea at a time may be handed to an agent for a bounded POC (such as a single-page prototype or benchmark script).
- Promote or Kill: Only prototypes that prove real utility in hands-on testing earn a dedicated repository and task breakdown; everything else stops cleanly in place.
3. Multi-Agent Collaboration: Drop “Nested CLI Calls” for Spec-File Relay
In my earliest multi-agent setups, I tried running an orchestrator agent inside a terminal and letting it shell out to invoke a second local coding agent CLI recursively. That “Russian-doll” invocation pattern was an operational disaster: doubled token burn, colliding interactive auth prompts, and interleaved terminal logs that were impossible to debug.
The durable replacement turned out to be dead simple: eliminate nested agent-to-agent CLI calls and coordinate strictly through 1-page Markdown Spec files.
- Planning & Cross-Source Synthesis Plane (Gemini): Uses long context to synthesize architecture docs and prior constraints. Its sole deliverable is a crisp 1-page specification (for example,
specs/feat-kvault-cli.md) whose header explicitly stamps the Recommended Model + Reasoning Tier (Flagship + High for cross-cutting architectural refactors; Workhorse + Medium for standard spec execution; Fast + Low for mechanical renames and type fixes). - Execution Plane (Codex / Cursor): Starts with an unpolluted terminal session—skipping messy brainstorming transcripts—and consumes the finalized Spec directly to edit code, run tests, and commit.
- Anti-Overengineering Rule: Only tasks that mutate core logic or external interfaces get a Spec file. Read-only research, log triage, and minor copy edits run via direct prompts—never writing bureaucracy for its own sake.
4. Zero-Plaintext Secret Governance with SOPS + age + Cloud Sync
The sharpest technical bottleneck in a multi-agent workspace is secret management:
- Plaintext
.envfiles on disk or cloud drive: One accidental folder share or broad agent workspace scan exposes live production keys immediately. - Opaque GUI password managers: Safe, but completely invisible to text tooling—an agent cannot inspect which environment variable names or service endpoints a project expects.
The sweet spot is Plaintext Keys + Ciphertext Values: keep structural metadata (name, env_var, purpose) in cleartext so both humans and AI agents can grep the schema freely, while encrypting every sensitive value string via CNCF’s SOPS paired with modern age asymmetric keys.
1. Encryption Policy (.sops.yaml)
At the root of the vault, .sops.yaml restricts encryption exclusively to secret-bearing value fields (the recipient below is the standard documentation example public key):
creation_rules:
- path_regex: \.enc\.yaml$
age: 'age1ql3z7hjy54pw3hyww5ayyfg7zqgvc7w3j2elw8zmrj2kg5sfn9aqmcac8p'
encrypted_regex: '^(value|secret|password|token|api_key|private_key)$'
2. Encrypted Vault Schema (secrets.enc.yaml)
Once encrypted and synced to cloud storage, the file looks like this:
services:
- name: OpenAI Production Key
env_var: OPENAI_API_KEY
purpose: Primary backend inference service credential
value: ENC[AES256_GCM,data:g6A7hK910xL...,iv:8fK...,tag:9a1...,type:str]
- name: Pinecone Vector DB
env_var: PINECONE_API_KEY
purpose: Retrieval-augmented generation vector index
value: ENC[AES256_GCM,data:p2B98zQ...,iv:1aD...,tag:5c3...,type:str]
When an AI agent reads secrets.enc.yaml, it immediately knows OPENAI_API_KEY is the canonical variable for backend inference—while seeing nothing but AES256_GCM ciphertext for the secret itself. Wrapped in a ~100-line Python CLI (kvault list to inspect cleartext metadata without touching the private key, kvault add using getpass so secrets never touch ~/.zsh_history, and kvault get decrypting straight into the system clipboard in memory), daily friction drops to zero.
3. Mobile Cloud Preview Trick & Three Non-Negotiable Key Rules
Because Google Drive treats .yaml files as opaque binary downloads on mobile web, exporting the synced copy as secrets.enc.yaml.txt makes the cleartext index instantly previewable in any browser; stripping .txt during restore lets SOPS decrypt it natively. Three ironclad rules govern the age private key:
- The private key never leaves local
~/.config/sops/age/keys.txt—never committed to Git and never placed inside a synced cloud folder; - The private key is never pasted into any AI chat prompt;
- One offline physical backup copy of the private key is stored cold.
5. Preventing Entropy Regression: The Daily 18:00 Audit & Sealing the Box
No workspace convention survives a busy week on willpower alone. A scheduled 18:00 daily audit script closes the loop: sweeping stray Desktop files into a dated staging inbox, checking repository naming conventions, counting active agent threads, and scanning secrets.enc.yaml.txt line by line via regex to verify every sensitive field starts with ENC[AES256_GCM,...]—aborting cloud sync and firing a desktop alert the instant an unencrypted value appears.
Sharpening the saw only matters if you get back to cutting wood. The most important final step of any developer-infrastructure overhaul is sealing the box: let the 18:00 audit run silently in the background, stop tweaking clients and folder layouts, and put 100% of engineering attention back onto shipping core systems.