Build a Local AI “Second Brain” for Your Code (Without Leaking Secrets)
From the publisher’s feed, collected in the ZeroLabs newsroom.
A privacy-first PKM framework for developers who want AI to actually understand their code, without shipping it to someone else’s server first.Source: AI-generated image by MidjourneyIn November 2023, three separate teams of engineers at Samsung’s semiconductor division pasted internal source code into ChatGPT within the same month. One was checking a block of code for errors. Another was trying to optimize it. A third fed it notes from an internal meeting and asked for a clean summary. Nobody stole anything. They were just trying to get unstuck a little faster, the way you’d paste an error message into a search bar. Samsung banned generative AI tools company-wide a few weeks later. [1]That story usually gets told as a lesson about careless employees. I think it’s actually a lesson about a tool with no third option. Those engineers weren’t choosing between leaking the code and protecting it. They were choosing between getting help and getting none, and the assistant in front of them only offered the version of help that happened to route someone else’s intellectual property through a server neither of them controlled.If you write software for a living, you already live inside a smaller, quieter version of that same choice. You want to ask an AI why your rate limiter keeps misfiring, except the file also contains a client’s pricing logic. You want to chat with two-year-old notes about a system you designed, except those notes describe a database schema you don’t technically own. So you paraphrase the real problem into something vague enough to feel safe, and you get back an answer vague enough to be useless. Or you just paste the real thing in, and hope nobody ever asks.The problem isn’t that AI is bad at understanding your code. It is that the tool most developers reach for was never built to keep a secret.Here’s what we’re actually going to build: a second brain, in the personal-knowledge-management sense people usually apply to reading lists and meeting notes, except this one indexes your repositories, your architecture docs, and your client’s schematics, and it runs entirely on a machine you own. No API key leaves the building. No retention policy to take on faith. No incident report to write in the morning.The Problem Runs Deeper Than “Just Don’t Paste That”Company policy has caught up to this risk faster than most individual habits have. Apple restricts staff from using ChatGPT for exactly this reason. Google has told its own engineers to be careful feeding code into Bard, a tool built by Google itself. [2] A 2025 academic audit of five major AI coding assistants, built with input from a data protection lawyer, found a twenty-point gap between the best and worst privacy practices among them, and concluded that most developers have no reliable way of knowing what actually happens to the code they submit. [1]None of that stops people from doing it anyway. On the developer forum Blind, one engineer described a coworker who had been pasting an entire company codebase into ChatGPT for months, secrets and API keys included, out of pure convenience. [3] The replies split along a predictable line. Some said report it. Most said, more or less, that they were already doing something close to the same thing, policy or not.That’s the part worth sitting with. This isn’t really a story about a few careless people. It’s what happens whenever the fastest way to solve a problem and the safest way to solve it stop being the same option. Make someone choose between speed and safety at 4:45pm before a deploy, and you already know which one wins.Why Doesn’t “Just Don’t Paste That” Work?The standard advice is to abstract the code before you share it. Describe the bug in general terms. Swap in fake variable names. Feed the model a synthetic version of the schema instead of the real one. It sounds reasonable, and it fails for a specific reason: debugging lives almost entirely in the details you just stripped out. A bug that only appears with your client’s actual edge-case pricing tiers isn’t reproducible in a made-up example, so the AI ends up answering a slightly different question than the one you actually have. You’re back to solving it yourself, except now you’ve also spent ten minutes writing a fictional version of your own problem.The other common answer is to trust the enterprise tier. Pay for the plan that promises zero data retention, skim the privacy page, feel better about it. This helps, and it still doesn’t solve the actual requirement, which usually isn’t “promise not to remember this.” It’s “this can never leave the building in the first place.” A retention policy is a promise about what happens after your code has already crossed the wire. An NDA with a client, a data-residency clause, or a national data security law is often a rule about the wire itself. [1] No retention policy fixes a problem that starts the moment the request leaves your laptop.The Real Requirement Isn’t “No AI.” It’s “No Transmission.”Once you see it this way, the fix stops looking like a compromise. Privacy risk isn’t really a function of whether you use AI, it’s a function of where the computation happens. If the model runs on hardware you control, and the index it searches lives on a disk you control, there is no wire for the secret to travel across. Not a slower wire, not an encrypted wire. No wire. The retention policy, the breach risk, the vendor’s own staff, all of it stops being relevant, because none of it was ever in the loop to begin with.This is the same principle every decent personal knowledge management system already runs on, just applied to a sharper boundary. A living index of your work is only useful if you trust it enough to actually put things into it. For notes, that trust is usually about whether the system stays usable over time. For code, it’s about whether the system stays yours.The Framework: Four Layers, All LocalYou don’t need a data center for this. You need four pieces, and as of 2026, all four run comfortably on a decent laptop.Step 1 — Pick Your Local EngineThis is the part of the setup that actually runs the model. Ollama is the simplest starting point: install it, and it handles downloading, running, and updating models through one command. LM Studio is the alternative if you’d rather have a graphical interface than a terminal. Either one turns your laptop into its own private inference server, the same job ChatGPT’s servers do, except the only place your prompts go is back to your own process.Step 2 — Pick a Model Sized to Your Machine, Not Your AmbitionThis is where most people quit on day one, by pulling a model too large for their hardware and deciding local AI “doesn’t work.” Size the model to your RAM first, and to your ambitions second.The gap between these local models and the frontier cloud ones has narrowed faster than most developers assume, especially for the unglamorous 80% of coding work: explaining a function, writing tests, refactoring, answering “why is this failing.” [6][7] It’s the remaining 20%, long, multi-file agentic tasks, that still tends to favor the biggest cloud models. Keep that distinction honest. It matters later, in the section on where this breaks down.Step 3 — Build the Index, Not Just the ChatA chat window bolted onto a local model isn’t a second brain. It’s just a slower version of the same tool. What makes it a second brain is the index: an embedding model that reads through your repo, your architecture notes, and your client’s schematics, and turns each chunk into a vector it can compare against your questions later. nomic-embed-text, run through the same local engine, does this well and stays entirely on your machine the whole time. [4][5] A ten-thousand-note vault takes a few minutes to embed on an ordinary laptop, and the resulting index runs a few dozen megabytes, small enough to back up like any other file. [5]Treat your code and your notes as one corpus, not two separate systems. The whole point of a second brain is that the useful answer to today’s bug sometimes lives in a note you wrote about a different client eighteen months ago, and you want one search that can reach both.Step 4 — Wire It Into Where You Actually WorkThe last step connects the engine and the index to the tools you already open every day. Continue.dev is the most common choice inside VS Code or JetBrains, pointed at your local Ollama endpoint instead of a cloud API. [7] If your notes live in Obsidian, a plugin called Smart Connections handles semantic search across your vault, and a community plugin called Copilot for Obsidian (unrelated to the Microsoft product of the same name) adds a chat sidebar that answers from your own notes, both configurable to run entirely against your local model. [4][5]Source: Image by the author.What This Looks Like in PracticeOld WorkflowHit a bug↓Copy the relevant function↓Notice it touches the client’s real schema↓Rewrite it as a “hypothetical” example↓Paste the fictional version into ChatGPT↓Get an answer that doesn’t quite fit↓Solve it yourself anywayNew WorkflowHit a bug↓Ask your local model directly, real names and all↓It searches your indexed repo and notes↓The answer references your actual schema↓Nothing left the machineSay you’re a freelance developer with three active clients, each under a separate confidentiality agreement. A payment integration you built eighteen months ago for one client starts throwing an error that looks familiar in a completely different client’s project today. Under the old workflow, you’d have no real way to connect those two things without digging through old projects by hand, because pasting either codebase into a shared AI thread would violate both agreements at once. Under the local setup, your question touches one private index that already contains both, and the answer can reference your actual past solution, real variable names included, because nothing left the machine that would make that a problem.The Mistakes That Can Quietly Undo All of This● Confusing “local” with “secure.” Your embeddings still sit on disk as ordinary files. Full-disk encryption (FileVault, BitLocker) is not optional here, it’s the actual boundary.● Syncing the vault straight back into the cloud. Obsidian Sync, iCloud, or a shared Git repo will happily upload the very index you built this whole system to avoid exposing. [5] Sync the notes if you need to. Think hard before syncing the embeddings folder anywhere outside your own devices.● Treating this as a substitute for an actual employer policy. If you’re an employee rather than a freelancer, this is a personal workflow decision, not a compliance strategy. Check with whoever owns that answer at your company before you index anything client-facing.● Pulling the biggest model first and giving up when it’s slow. Start small. A 7B model that actually runs beats a 70B model you never open.Where This Breaks DownThis isn’t a universal upgrade, and pretending otherwise would undercut the whole point of writing about it honestly.The hardware cost is real. A machine that comfortably runs a 14B or 32B model is not the machine most people are issued at a first developer job. If you’re on an 8GB laptop, you’ll be working with genuinely smaller models, and some tasks will simply be slower or rougher than what a frontier cloud model would give you.The capability gap is real too, particularly for long, multi-file, agentic work, planning and executing changes across a dozen files in one pass. Local models have closed most of that gap for everyday debugging and refactoring, and the largest cloud models still tend to win on the hardest, most sprawling tasks. [6][7] If that’s the work you’re doing most days, a hybrid setup, local for anything client-sensitive, cloud for your own greenfield side projects, is often more honest than an all-or-nothing rule.And none of this replaces an actual conversation with a client or an employer about what they’re comfortable with. A local second brain protects the wire. It doesn’t retroactively grant you permission to index a client’s proprietary schema just because the risk profile improved. Ask first. Build second.The Larger Lesson HereA second brain, of any kind, dies the same way every time. Not from a dramatic failure, but from friction. The moment retrieving from your system costs more than the risk it was solving, you quietly stop using it. That’s true of a color-coded Notion vault nobody reopens, and it’s just as true here. If the local setup is fiddly enough that you’re back in ChatGPT’s tab by Thursday out of sheer deadline pressure, you haven’t actually solved the privacy problem. You’ve bought an expensive set of speakers and never plugged them in.So keep the first version boring and small. One model. One folder, your most recent project, not your entire archive. Get that working before you expand it into the system this article describes in full.ConclusionSo, what was the problem with those Samsung engineers? And no, it wasn’t a discipline problem. They had exactly one option that felt fast, and it happened to be the unsafe one. That’s the actual failure, and it’s not unique to a semiconductor company. It’s sitting on your laptop right now, in the gap between the bug you want help with and the client agreement you signed before you ever opened the file.What changes once you build a local second brain isn’t that AI gets smarter. It’s that the fast option and the safe option finally become the same option. You stop paraphrasing your own problems into vague, less useful versions of themselves. You stop hoping nobody asks.Install Ollama today. Pull one small model. Point it at one folder. Ask it one real question, with real names in it. That’s the whole first step, and it’s the only one that matters right now.If This HelpedStart with the smallest version: install Ollama, pull qwen2.5-coder:7b, and point it at one real project folder this week. Everything else in this framework, the notes vault, the multi-repo index, can wait until that first piece is boring and reliable.Sources[1] Al-Maamari, A. “Can You Trust Your Copilot? A Privacy Scorecard for AI Coding Assistants.” arXiv, 2025. https://arxiv.org/html/2509.20388v1[2] Spencer, M. “Apple Blocks ChatGPT.” The Nvidia Patterns, Substack, 2023. https://futuresin.substack.com/p/apple-blocks-chatgpt[3] Blind (teamblind.com), developer forum thread on pasting a company codebase into ChatGPT. https://www.teamblind.com/[4] “Best Obsidian Plugins for Local LLM with Ollama 2026.” PromptQuorum. https://www.promptquorum.com/power-local-llm/local-llm-with-obsidian-2026[5] “Obsidian Local AI 2026: Connect Ollama with 3 Plugins.” Local AI Master. https://localaimaster.com/blog/local-ai-obsidian-integration[6] “Best Ollama Models 2026.” Morph. https://www.morphllm.com/best-ollama-models[7] “Best Local Coding LLMs 2026: Kimi K2.6, Qwen, Devstral.” PromptQuorum. https://www.promptquorum.com/local-llms/best-local-llms-for-codingBuild a Local AI “Second Brain” for Your Code (Without Leaking Secrets) was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.