TL;DR
devsolar became a company, and suddenly a team working on it in our free time had to deal with taxes, invoices, deadlines and a lot of email. So I built it a brain. A GitHub repo holds everything the company knows, split into ten areas, each with its own agent. An internal app connects that repo with our Drive and our inbox, and an MCP server hands all of it to the Claude Code subscription on each of our laptops.
The accounting part has one strict rule. Before the app is allowed to file a single tax form, it has to reproduce the ones already filed, box by box. One cent of difference is a bug.
What is this?
As some of you might know, besides Footprint, I started a side project called devsolar.es a couple of years ago. It’s a SaaS that helps installers in Spain with the paperwork of different types of low-voltage projects, such as photovoltaic installations or EV charging points.
The brain has three parts. A repository of Markdown files that describes the company. An internal web app that reads our Google Drive, our email and that repository, and does the boring accounting. And an MCP server, so whoever opens Claude Code on their laptop can ask the company a question, or ask it to do something.
Why did I build it?
A bit more than a year ago, devsolar became a company, to make it more official and to be able to charge for our services. With the company, a lot of things became more complicated than we really needed: taxes, documentation, deadlines, the webpage, invoices, you name it. Until recently we did all of this in our free time, because the project is still relatively small.
But with all the possibilities AI opens up, I decided to give it a go and build an automatic brain for our small company. The goal was simple, a single point of knowledge that aggregates all our sources. The actual brain would be the Claude subscription on each team member’s laptop.
What I tried first
| Option | Why it didn’t fit |
|---|---|
| A gestoría (an accounting firm) | They file the taxes, but everything else was still on us, by hand, in Drive and email |
How did I build it?
Architecture
The first thing I needed to work on was the context of the company. I needed a place where I could define and iterate over its different areas: marketing, sales, engineering, product, customer success, and so on. For that I created a GitHub repository, the context repo, with one folder per area, which I ended up calling pillars. Each pillar has its Markdown files with the context and status of that piece, plus an AGENTS.md that says how to read it and, most importantly, how to update it. So the repo became a sort of context handler for agents.
For everything else the company handles internally we have a Google Drive. Images, decks, invoices, notes from meetings. You know, a normal company shared folder. And finally the email, so we could fetch, read, sort and understand all the conversations: an old sales conversation that stalled, a piece of information that’s missing, a tax document that needs to be filed. Email access was crucial.
Those sources are the memories of the system. Then I needed a pipeline to handle all of it, so I built a backend, a frontend and a database for an internal web app. We log in with our company Google account, and from there we can browse the accounting folders in Drive, read the inbox and file an attachment into the right quarter, upload bank statements, see the tax calendar, and search the whole context repo. The same backend exposes an MCP server, so Claude Code gets the same tools with the same permissions:
@mcp.tool()
def buscar_contexto(q: str, espacio: str = "", limite: int = 10) -> dict: ...
@mcp.tool()
def escribir_documento(ruta: str, contenido: str, mensaje: str, sha: str = "") -> dict: ...
@mcp.tool()
def calendario_fiscal(ejercicio: int = 0) -> dict: ...
@mcp.tool()
def archivar_adjunto(mensaje_id: str, adjunto_id: str, nombre: str = "adjunto.pdf", ...) -> dict: ...
(Search the context, write a document, read the tax calendar, file an email attachment into Drive. Everything is in Spanish because the company is.)
The agents
Each pillar also has an agente.md, which is the same agent written as a Claude Code subagent. You copy them to ~/.claude/agents/ (or ask Claude to fetch them through the MCP) and you get ten of them. This is the marketing one, trimmed:
---
name: marketing-agent
description: Agente de marketing de Devsolar — posicionamiento, web, contenido y canales de captación.
tools: Read, Grep, Glob, Edit, Write, WebSearch, WebFetch
---
Antes de responder o actuar:
1. Lee `AGENTS.md` (raíz del repo de contexto): pilares, reglas y protocolo de negociación.
2. Lee `marketing/AGENTS.md`: tu misión, lo que decides, tus invariantes y tus fuentes.
Reglas que no se saltan:
- Escribes solo en `marketing/`. Lo que sea de otro pilar se pide a su agente con el protocolo.
Every agent writes only in its own folder. If marketing wants to announce a region that product hasn’t finished, it has to ask the product agent, and there’s a written protocol for that: a request, an answer with what each side won’t give up, at most three rounds, and the strategy agent decides if they don’t agree. Anything that commits money, clients or something public needs a person to approve it. I tested it with a marketing–product negotiation and adjusted the agents afterwards.
Stack & dependencies
| Piece | Choice | Why |
|---|---|---|
| Context | A GitHub repo of Markdown, ten pillars | Agents handle files well, and git gives us history for free |
| Frontend | React + Vite + MUI | Same shell and theme as our product |
| Backend | FastAPI, raw SQL (psycopg 3), APScheduler | Same stack as the product, with the jobs in-process |
| Data | Postgres 14 | Full-text search over the context, finance tables, audit log |
| Accounting | A plain Python package, fiscal |
Runs from the CLI with no database or network, so I can test it alone |
| AI | Claude Code on each laptop, through MCP | Everyone uses their own subscription, no API keys |
| Hosting | Docker + Dokploy | Push to release, tests, build, deploy |
Key decisions & trade-offs
Access by spaces. espacios.toml maps each folder to one of four spaces: business and product for the whole team, finances and people only for admins. The filter lives in the SQL, so the web and the MCP can’t leak in different ways. The cost is that someone has to remember to declare every new private folder.
Nothing can be deleted. The Drive client can only move things to the trash, and a test checks it can’t send an HTTP DELETE. Email can only send reviewed templates.
Backtests before anything is filed. The accounting core reads the tax forms already filed from their official receipts and has to reproduce them exactly from our invoices and bank statements. Until it does, any form it generates is saved as a draft. It also checks that the bank statements chain: each balance has to be the previous one plus the movement, so a missing month fails loudly instead of quietly producing a lower VAT return. Early on, the backtest found a whole quarter with no purchase invoices in Drive, and said how much was missing and in which folder.
How AI fit into the build
I didn’t write the code. I wrote the plan with Claude first: what the app had to do, the decisions (Google sign-in restricted to our domain, connect the company inbox once, never delete in Drive, MCP writes go straight to main) and the assumptions to flag. Then Claude Code built it in eight phases, one commit each, from the database skeleton to the MCP server and the deploy.
In the sessions I still have, it’s almost all Opus 5.5 and a bit of Fable 5.1. My part was deciding, approving and pushing back.
Several of my later sessions start with something arriving by email: “We just received an email with the final 303. Is it correct? Can we replicate it?”
Demo
The app is full of our real finances, so for now the diagram and the snippets are what I can show.
By the numbers
| Time | About 3 weeks for the app (Sep 11 – Oct 3, the eight phases mostly on one day). The context repo keeps growing since Sep 11 |
| Commits | 56 in the app, 182 in the context repo |
| Lines of code | ~13,500 Python and ~5,800 JSX, plus ~7,600 lines of tests (300+ tests) |
| Context | 10 pillars, 10 agents, ~200 Markdown files |
| Cost (hosting + AI) | |
| Users |
Lessons learned
With enough context, the agents can do most of the work: reading the bank statements, filing invoices, drafting the tax forms, keeping the calendar. But we still need the gestoría to get the finances right to the cent.
Replicate it
Paste this into Claude Code in an empty repo, next to a folder where your company’s context will live. Adapt the areas and the tax forms to your country.
I run a small company with a couple of people in our free time, and I want to build it a brain: one place that aggregates everything the company knows, which each of us can use from Claude Code on our own laptop.
1. Context repo. Create a Git repository of Markdown with one folder ("pillar") per area: strategy, product, engineering, regulations, marketing, sales, customers, finances, people, operations. Each pillar has a README.md for humans, an AGENTS.md (mission, what it decides, what it never gives up, its sources), a CLAUDE.md that just imports AGENTS.md, and an agente.md with the same agent as a Claude Code subagent.
2. Root AGENTS.md with the rules for every agent: write only in your own pillar; a number lives in one place and the rest link to it; never copy content from a restricted space into an open one; mark every figure as verified, estimate or hypothesis; the product code beats the docs; absolute dates. Add a negotiation protocol between agents (written request, answer with what each side won't give up, max three rounds, the strategy agent arbitrates, agreements are written to a file). People approve anything that commits money, clients or public content.
3. An espacios.toml that maps folders to four access spaces: business and product for the whole team, finances and people for admins only. Longest prefix wins, default is business.
4. Internal app in a second repo: FastAPI with raw SQL (psycopg 3) on Postgres, React + Vite + MUI frontend, APScheduler in-process (run with one worker). Sign in with Google restricted to our domain, then our own JWT in an httpOnly cookie.
5. Connect the company Google account once (offline OAuth, refresh token encrypted in the database) to read and organize Drive and read the inbox. The Drive client must not be able to delete: only move to trash. Add a test that proves it. Email only sends reviewed templates.
6. Index the context repo into Postgres with full-text search, filtered by space in SQL, with no query that skips the filter.
7. Expose an MCP server (Streamable HTTP) on the same backend with per-user tokens and the same permissions: list, read, search and write context documents (writes are commits to main with the user as author, with an optimistic sha check), finance status, the tax calendar, filing an email attachment into Drive, product metrics.
8. Accounting as a separate package that works from the CLI with no database or network: read bank statements and verify the balance chain, extract invoices with a self-check (base + VAT - withholding = total), file them by quarter, reconcile bank against invoices, build the VAT books and the quarterly tax forms, and write the agency's file format.
9. Before generating any tax form for real, read the forms already filed from their official receipts and reproduce them exactly. One cent of difference is a bug, and the form stays a draft until the backtest passes.
10. Deploy by pushing to a release branch: CI runs the tests against Postgres, builds Docker images and deploys. Debounce anything an agent can trigger in a loop, so a burst of writes ends in a single deploy.
Build it in phases, one commit per phase, and ask me before any decision that touches money, email or deleting anything.