---
title: "Build a local-first AI setup that sends only the context each request needs"
description: "Keep AI context files on your own machine, load only the files a request needs, and know exactly what reaches the API and what stays local."
canonical: "https://scalewithsearch.com/articles/local-first-ai-architecture"
date: "2026-01-28"
modified: "2026-09-25"
---
## Site navigation

- [Scale With Search](https://scalewithsearch.com/)
- Real estate
  - Real estate
    - [Real estate](https://scalewithsearch.com/for/real-estate)
- Work
  - Start here
    - [Send your brief](https://scalewithsearch.com/work#send-your-brief)
    - [Prepare your six-question brief](https://scalewithsearch.com/work#prepare-your-six-question-brief)
  - Build
    - [Site build, content library with SEO, signal desk](https://scalewithsearch.com/work)
- For your business
  - Trades and home services
    - [Auto body and collision shops](https://scalewithsearch.com/for/auto-body-and-collision-shops)
    - [Foundation and home repair contractors](https://scalewithsearch.com/for/foundation-and-home-repair)
    - [Garage door and fencing contractors](https://scalewithsearch.com/for/garage-door-and-fencing-contractors)
    - [HVAC contractors](https://scalewithsearch.com/for/hvac-contractors)
    - [Janitorial and commercial cleaning companies](https://scalewithsearch.com/for/janitorial-and-commercial-cleaning)
    - [Locksmiths](https://scalewithsearch.com/for/locksmiths)
    - [Moving companies](https://scalewithsearch.com/for/moving-companies)
    - [Pest control companies](https://scalewithsearch.com/for/pest-control-companies)
    - [Plumbing and electrical contractors](https://scalewithsearch.com/for/plumbing-and-electrical-contractors)
    - [Restoration and water or fire damage companies](https://scalewithsearch.com/for/restoration-and-water-fire-damage)
    - [Roofing companies](https://scalewithsearch.com/for/roofing-companies)
    - [Towing companies](https://scalewithsearch.com/for/towing-companies)
    - [Tree services and landscaping companies](https://scalewithsearch.com/for/tree-services-and-landscaping)
    - [Solar installers](https://scalewithsearch.com/for/solar-installation)
    - [General contractors](https://scalewithsearch.com/for/general-contractors-and-construction)
    - [Paving, concrete, and flooring contractors](https://scalewithsearch.com/for/paving)
  - Practices and professional services
    - [Bookkeeping and tax practices](https://scalewithsearch.com/for/bookkeeping-and-tax-practices)
    - [Dental practices](https://scalewithsearch.com/for/dental-practices)
    - [Family and criminal defense law firms](https://scalewithsearch.com/for/family-and-criminal-defense-law-firms)
    - [Med spas and aesthetics practices](https://scalewithsearch.com/for/med-spas-and-aesthetics)
    - [Personal injury law firms](https://scalewithsearch.com/for/personal-injury-law-firms)
    - [Veterinary clinics](https://scalewithsearch.com/for/veterinary-clinics)
    - [Gyms and fitness studios](https://scalewithsearch.com/for/fitness)
    - [Therapy and outpatient health practices](https://scalewithsearch.com/for/therapy-and-outpatient-health)
    - [Medical billing companies](https://scalewithsearch.com/for/medical-billing)
    - [Insurance agencies](https://scalewithsearch.com/for/insurance-agencies)
    - [Financial advisors](https://scalewithsearch.com/for/financial-advisors)
    - [Property management companies](https://scalewithsearch.com/for/property-management)
    - [Recruiting and staffing agencies](https://scalewithsearch.com/for/recruiting-and-staffing)
    - [Architects and interior designers](https://scalewithsearch.com/for/architects-and-interior-designers)
    - [Logistics and supply chain companies](https://scalewithsearch.com/for/logistics-and-supply-chain)
  - Agencies, MSPs, and manufacturing
    - [IT and managed service providers](https://scalewithsearch.com/for/it-and-managed-service-providers)
    - [Machine shops and precision manufacturers](https://scalewithsearch.com/for/machine-shops-and-precision-manufacturing)
    - [Marketing agencies and freelancers](https://scalewithsearch.com/for/marketing-agencies-and-freelancers)
    - [SEO agencies and consultants](https://scalewithsearch.com/for/seo-agencies-and-consultants)
    - [Small manufacturers and fabricators](https://scalewithsearch.com/for/small-manufacturers-and-fabricators)
  - Restaurants, shops, studios, and nonprofits
    - [Restaurants and hospitality businesses](https://scalewithsearch.com/for/restaurants-and-hospitality)
    - [Retail stores and ecommerce sellers](https://scalewithsearch.com/for/retail-and-ecommerce)
    - [Photographers, event planners, and travel agents](https://scalewithsearch.com/for/photographers)
    - [Churches and nonprofits](https://scalewithsearch.com/for/churches-and-nonprofits)
  - [All industries](https://scalewithsearch.com/for/)
- Learn
  - For your office
    - [Office job guides](https://scalewithsearch.com/guides/)
    - [Browser calculators](https://scalewithsearch.com/tools/)
  - Start here
    - [How it works](https://scalewithsearch.com/how-it-works)
    - [Free Starter Kit](https://scalewithsearch.com/kit/business-memory-starter-kit.zip)
    - [Synthetic specimen](https://scalewithsearch.com/specimen/working-session-specimen.zip)
  - Guides
    - [The Complete Guide to Business Memory for AI Agents](https://scalewithsearch.com/articles/business-memory-for-ai-agents-guide)
    - [The Complete Small-Business Guide to AI Agent Governance](https://scalewithsearch.com/articles/ai-agent-governance-guide-small-business)
    - [The Complete Guide to Leaving Vendor AI Memory](https://scalewithsearch.com/articles/leaving-vendor-ai-memory-guide)
  - Articles by cluster
    - [Business memory](https://scalewithsearch.com/articles/business-memory-for-ai-agents-guide)
    - [Agent governance](https://scalewithsearch.com/articles/ai-agent-governance-guide-small-business)
    - [Migration and ownership](https://scalewithsearch.com/articles/leaving-vendor-ai-memory-guide)
  - For machines
    - [llms.txt](https://scalewithsearch.com/llms.txt)
    - [llms-full.txt](https://scalewithsearch.com/llms-full.txt)
    - [Machine view](https://scalewithsearch.com/?view=machine)
- Company
  - Evidence
    - [Proof](https://scalewithsearch.com/proof)
  - Company
    - [About](https://scalewithsearch.com/about)

# Build a local-first AI setup that sends only the context each request needs.

You want an assistant that remembers your business. You do not want that memory to live on someone else's server.

Memory needs storage. In most AI products, storage means the vendor's cloud, and the vendor holds a standing copy. Local-first architecture changes where the memory lives. Your context files stay on your machine. A cloud model still processes each request, but it receives only the files that the request needs.

This article lays out the four layers, traces one request, and sets the rules for encryption, sync, and backup.

## Know where cloud memory lives

Most AI tools that offer memory store it in the vendor's cloud. ChatGPT memory lives on OpenAI's servers. Claude Projects live on Anthropic's servers. Notion AI works from data in Notion's database. The guide to [what Notion AI keeps between chats](/articles/notion-ai-memory-chat-history-business) separates its chat history from the pages it reads.

That arrangement limits your control. You cannot see the exact stored form. Export and complete deletion depend on the product's features. You also rely on the vendor's training policy, its security, and its future privacy terms.

For personal preferences, that trade can be acceptable. For client information and financial records, you may want a tighter boundary.

## Keep data local and send processing to the cloud

Local-first architecture keeps the context on your machine and still uses a cloud AI API.

Your context files, such as `CLAUDE.md`, domain folders, and session logs, live in a folder on your laptop. When you ask a question, your local setup reads the relevant files and sends them with your prompt to the API. The API returns a response.

The files do not become a memory record on the vendor's side. They travel inside one request. The provider still handles that request under its retention policy for your account type. "Local" describes where the memory lives. It does not promise that the content never leaves your machine.

## Lay out the four layers

A local-first setup has four parts:

1. **Local storage.** Markdown files on your machine.
2. **Context loader.** A script that selects the relevant files for a request.
3. **API bridge.** The client that sends the prompt and the selected context to the AI service.
4. **Response handler.** The part that receives the response, shows it, and writes any local log.

From your side, you ask a question and read an answer. Behind that, the local layers select context, send it, and receive the reply.

### Layer 1: Local storage

Keep the context files in a folder on your machine. The folder can sit in Documents, or in a folder that syncs between your own devices.

An example structure:

```
/vault/
  CLAUDE.md (root context)
  /work/
    _context.md
  /business/
    _context.md
  /personal/
    _context.md
```

These are plain Markdown files with no special format. You back them up, and you decide who can read them. For the wider case for text files, read [why plain text is the durable layer for AI memory](/articles/plain-text-ai-memory).

### Layer 2: Context loader

The loader decides which files a request needs. In Claude Code, a hook can do this job. A hook is a script that Claude Code runs at a defined event, such as prompt submission. The hook reads the prompt, matches keywords to a domain, and adds that domain's `_context.md` to the session.

A simple routing table for the loader:

```text
prompt contains "lead" or "client"   -> load work/_context.md
prompt contains "invoice" or "tax"   -> load business/_context.md
prompt contains "family" or "house"  -> load personal/_context.md
no keyword match                      -> load CLAUDE.md only
```

The loader runs on your machine and sends nothing by itself. It prepares context for the next layer. For a method to decide what a task should read, see [what context an agent should read](/articles/what-context-should-an-agent-read).

### Layer 3: API bridge

The bridge sends the request to the AI service. The request holds the prompt and the loaded context. The API generates a response from both and returns it.

The difference from cloud memory is scope. The request says "here is information for this question." It does not say "keep this for every future session."

### Layer 4: Response handler

The response comes back through the bridge and appears in Claude Code, a terminal, or another interface. If the session produces a decision or a completed task, the handler can write it to a local session log. The log stays on your machine.

## Trace one request

Take the prompt "What's the status on the Client A lead?"

1. You submit the prompt.
2. The loader matches the keyword "lead."
3. The loader maps "lead" to the work domain.
4. The loader reads `work/_context.md`.
5. The bridge sends the prompt and that file's contents to the API.
6. The handler shows the answer and appends a line to the session log.

The API receives three things in each request:

- your prompt;
- the loaded context files;
- the conversation history of the current session, in a multi-turn session.

Everything else stays local. That includes files from domains that the prompt did not match, logs from earlier sessions, drafts, and personal notes. If you ask about work, the model does not receive your personal files. If you ask about one client, it does not receive other clients' files, provided the loader separates them. For stronger client isolation, see [how to keep businesses, clients, and roles separate for AI agents](/articles/separate-business-contexts-ai-agents).

Add one line to the handler: log the list of files sent with each request. That list is your receipt. It lets you check later exactly what left the machine.

## Check the provider terms for what you send

When this article was first written (January 2026), Anthropic's and OpenAI's commercial API terms stated that API data was not used for training by default. Consumer plans follow different terms, and those terms changed during 2025. Read the current terms for the account that your client software uses.

The provider does not get standing access to your folder. It cannot browse the vault, and it cannot see files that you did not send. It sees what each request contains, and it keeps that content for the period its policy states. An agent client such as Claude Code can also let the model ask for more files during a session. The client then sends those files too, so set its read permissions to the folders that the task needs.

## Compare local-first with cloud memory

| Point | Cloud memory (ChatGPT, Claude Projects) | Local-first |
|---|---|---|
| Storage location | Vendor servers | Your machine |
| Vendor access | Standing access to stored memory | Request content only |
| Control of contents | Limited to product features | Full: you edit the files |
| Visibility | You see the interface view | You read every file |
| Policy exposure | Vendor privacy terms decide storage | Vendor terms apply only to request content |

With cloud memory, you rely on the vendor for storage. With local-first, you take on that job yourself.

## Control what else leaves the machine

Privacy depends on the whole setup, not only on file location. Sync to an outside server happens only if you choose it. The AI call happens only when you send a request, with the context you selected.

Check the client software itself. Some AI clients send usage telemetry or error reports by default. Read the client's documentation, and turn off what you do not want.

## Work offline when the model is not needed

Your context files are local, so you can read, edit, and search them without a connection. You cannot generate cloud AI responses offline, unless you run a local model such as one served by Ollama. You can still update context files, add session notes, and organize the vault. When you reconnect, the next request can use everything you added.

## Encrypt the files at rest

A thief with your unencrypted laptop can read your context files. Encrypt the disk or the vault. Use FileVault on macOS, BitLocker on Windows, or a tool such as Cryptomator for a single folder.

Encryption does not change how the setup works. When you unlock the machine, the loader reads plain text as before.

## Sync between your own devices

You can sync the vault between a laptop and a desktop with iCloud, Dropbox, or Syncthing. The setup stays local-first, because the AI service still receives only request content.

The sync service is a third party, though. iCloud and Dropbox store copies on their servers. Syncthing moves files directly between your devices. Choose the sync service with the same care as any other service that holds business files.

## Back up on the 3-2-1 rule

Cloud memory comes with the vendor's backups. Local-first makes backup your job.

Use three copies on two kinds of storage, with one copy off-site:

- Primary: the vault on your laptop.
- Secondary: a synced copy in iCloud, Dropbox, or on a second device.
- Third: a manual backup to an external drive once a month, stored away from the laptop.

Test a restore at least once. A backup that you never restored is an assumption. For a full check of what survives a lost account, run the [AI subscription shutdown test](/articles/ai-subscription-shutdown-test).

## Avoid vendor lock-in

The files are plain Markdown, so no single vendor owns the format. If you move from Claude Code to another client, the vault moves with you. If you move from Obsidian to VS Code, another Markdown editor, or the terminal, the files do not change. You need no export process and no database migration.

## Check compliance before you rely on the design

Local-first storage helps in regulated work, such as healthcare, finance, and law. Client data is not stored in an AI vendor's memory feature, so fewer third parties hold standing copies.

It does not remove the vendor from the chain. Each request sends the selected context to the API, and that transfer is data processing by a third party. HIPAA, GDPR, and similar rules still apply to that transfer. You may still need a data processing agreement or a business associate agreement with the provider. Keep regulated records in their governed systems, and send only what a request needs.

## Expect fast context reads

A local disk read is fast. Context loading from local files adds little delay to a request. A cloud memory system must query its own store before it builds the request.

The larger gain is control, not speed. You decide what the memory contains, which request receives which file, and where every copy lives.


## Related: AI memory

- [Build an AI context file that briefs the model before every session](/articles/ai-context-files)
- [Give AI a persistent context layer so each session starts from your business](/articles/ai-doesnt-remember-context)
- [Give AI a context file so it knows your business without model training](/articles/ai-memory-vs-ai-training)

----

```text
                  .|########||.                                       .|########||.                                       .|########||.
               |##||.      .||##|.                                 |##||.      .||##|.                                 |##||.      .||##|.
             |#|.              .|#|.                             |#|.              .|#|.                             |#|.              .|#|.
           |#|                    |#|                          |#|                    |#|                          |#|                    |#|
         .#|                        |#.                      .#|                        |#.                      .#|                        |#.
        .#.                          .#|                    .#.                          .#|                    .#.                          .#|
       |#.                            .#|                  |#.                            .#|                  |#.                            .#|
      |#             ......             #|                |#             ......             #|                |#             ......             #|
     .#           ||#########|           #|              .#           ||#########|           #|              .#           ||#########|           #|
    .#.         |######||######|.        .#.            .#.         |######||######|.        .#.            .#.         |######||######|.        .#.
    #.        .##|###|##|#|######|        .#            #.        .##|###|##|#|######|        .#            #.        .##|###|##|#|######|        .#
   ||        |##|#||||||||||||#||#|        ||          ||        |##|#||||||||||||#||#|        ||          ||        |##|#||||||||||||#||#|        ||
   #        |#||||||||||||||||||||#|        #.         #        |#||||||||||||||||||||#|        #.         #        |#||||||||||||||||||||#|        #.
  ||       |#||||||||||||||||||||||#|       ||        ||       |#||||||||||||||||||||||#|       ||        ||       |#||||||||||||||||||||||#|       ||
  #       .#||||||||||||||||||||||||#|       #        #       .#||||||||||||||||||||||||#|       #        #       .#||||||||||||||||||||||||#|       #
 ||   ....|||#||||||##|#|||#|#||##||||....|. ||      ||   ....|||#||||||##|#|||#|#||##||||....|. ||      ||   ....|||#||||||##|#|||#|#||##||||....|. ||
 #.  .  ....|#  ....#|||   ||| .#|||  ....#. .#      #.  .  ....|#  ....#|||   ||| .#|||  ....#. .#      #.  .  ....|#  ....#|||   ||| .#|||  ....#. .#
 #   .  ||||#| .#####||  . .#| .#|||  ||||#   #.     #   .  ||||#| .#####||  . .#| .#|||  ||||#   #.     #   .  ||||#| .#####||  . .#| .#|||  ||||#   #.
.|   |||||  #. |#|||||. ||  #. |#||. .|||||   ||    .|   |||||  #. |#|||||. ||  #. |#||. .|||||   ||    .|   |||||  #. |#|||||. ||  #. |#||. .|||||   ||
||   |....  #. ....|#.      |. ...|. ....||   ||    ||   |....  #. ....|#.      |. ...|. ....||   ||    ||   |....  #. ....|#.      |. ...|. ....||   ||
#.  .||||||##||||||##||####|||||||#||||||#|   .#    #.  .||||||##||||||##||####|||||||#||||||#|   .#    #.  .||||||##||||||##||####|||||||#||||||#|   .#
#    .||####|###########################|.     #    #    .||####|###########################|.     #    #    .||####|###########################|.     #
#      .#||||||.#.|| # |. ..# #| #|||||#|      #    #      .#||||||.#.|| # |. ..# #| #|||||#|      #    #      .#||||||.#.|| # |. ..# #| #|||||#|      #
#      .#|||||| ..  |# ## |#| ...#|#|||#|      #    #      .#|||||| ..  |# ## |#| ...#|#|||#|      #    #      .#|||||| ..  |# ## |#| ...#|#|||#|      #
#      .#|||#|# .# .#| #| ##|.#..#|||||#|      #    #      .#|||#|# .# .#| #| ##|.#..#|||||#|      #    #      .#|||#|# .# .#| #| ##|.#..#|||||#|      #
#      .#||||||############|######|||||#|      #    #      .#||||||############|######|||||#|      #    #      .#||||||############|######|||||#|      #
#   |...||#||||||#||||#|#||||||#|||||#||| |.|  #    #   |...||#||||||#||||#|#||||||#|||||#||| |.|  #    #   |...||#||||||#||||#|#||||||#|||||#||| |.|  #
#. .. ||||# .|||##|.  |#| .|| || .|||#. #|  # .#    #. .. ||||# .|||##|.  |#| .|| || .|||#. #|  # .#    #. .. ||||# .|||##|.  |#| .|| || .|||#. #|  # .#
|| |  ...||  ...##| |  #| .|. |. #####  .. .| ||    || |  ...||  ...##| |  #| .|. |. #####  .. .| ||    || |  ...||  ...##| |  #| .|. |. #####  .. .| ||
|| ||||| || ||||#|  .  |. |. |#. ||||| |#| || ||    || ||||| || ||||#|  .  |. |. |#. ||||| |#| || ||    || ||||| || ||||#|  .  |. |. |#. ||||| |#| || ||
.# |.....#|....|#.||||.|||##.|#|....||.#||.#. #.    .# |.....#|....|#.||||.|||##.|#|....||.#||.#. #.    .# |.....#|....|#.||||.|||##.|#|....||.#||.#. #.
 #.|||||||#############################| ||| .#      #.|||||||#############################| ||| .#      #.|||||||#############################| ||| .#
 ||       ##||#||#||||||#||#||#||#||##.      ||      ||       ##||#||#||||||#||#||#||#||##.      ||      ||       ##||#||#||||||#||#||#||#||##.      ||
  #       .#|||||||||#||#|||||||||||#|       #        #       .#|||||||||#||#|||||||||||#|       #        #       .#|||||||||#||#|||||||||||#|       #
  ||       |#||||||||||||||||||||||#|       ||        ||       |#||||||||||||||||||||||#|       ||        ||       |#||||||||||||||||||||||#|       ||
  .#        |#||||||||||||||||||||#|        #.        .#        |#||||||||||||||||||||#|        #.        .#        |#||||||||||||||||||||#|        #.
   ||        |#||||||||||||||||||#|        ||          ||        |#||||||||||||||||||#|        ||          ||        |#||||||||||||||||||#|        ||
    #.        .######|#|#########|        .#            #.        .######|#|#########|        .#            #.        .######|#|#########|        .#
    .#.         |#####||||#####|         .#.            .#.         |#####||||#####|         .#.            .#.         |#####||||#####|         .#.
     |#           ||########||           #.              |#           ||########||           #.              |#           ||########||           #.
      |#             ......             #|                |#             ......             #|                |#             ......             #|
       |#.                            .#|                  |#.                            .#|                  |#.                            .#|
        |#.                          .#.                    |#.                          .#.                    |#.                          .#.
         .#|                        |#.                      .#|                        |#.                      .#|                        |#.
           |#|                    |#|                          |#|                    |#|                          |#|                    |#|
            .|#|.              .|#|.                            .|#|.              .|#|.                            .|#|.              .|#|.
               |##||.      .||##|                                  |##||.      .||##|                                  |##||.      .||##|
                 .||########||.                                      .||########||.                                      .||########||.

Scale With Search  2026  [scalewithsearch.com](https://scalewithsearch.com)
```
