harbor

mcp
Guvenlik Denetimi
Basarisiz
Health Uyari
  • License — License: MIT
  • Description — Repository has a description
  • Active repo — Last push 0 days ago
  • Low visibility — Only 7 GitHub stars
Code Basarisiz
  • rm -rf — Recursive force deletion command in .github/workflows/release.yml
  • exec() — Shell command execution in docker/local/server/launcher.mjs
  • process.env — Environment variable access in docker/local/server/launcher.mjs
Permissions Gecti
  • Permissions — No dangerous permissions requested

Bu listing icin henuz AI raporu yok.

SUMMARY

Memory and guardrails for AI coding agents

README.md

Harbor

Memory and guardrails for your AI coding agents, running on your own computer.
Harbor keeps what Claude Code, Codex, Cursor and Copilot learn, and hands each one the right rule at the right moment.

npm License: MIT Node 22.12 or newer Runs on your machine Works with Claude Code, Codex, Cursor and Copilot

Quick start · How it works · What runs on your computer · Benchmark · Commands · FAQ

Harbor against mem0, basic-memory, claude-mem and keyword search on 122 merged pull requests from 15 public repos. Harbor finds a needed rule on 48 of 117, mem0 44, basic-memory 43, claude-mem 41, BM25 40.

Which rules does a coding agent need for this change? 122 merged pull requests from 15 public repos Harbor was never tuned on. How it was measured.


Why Harbor

Your agent works out that this repo uses pnpm, that the API runs on port 4100, that a migration must
never be reset. Then the session ends, it forgets, and tomorrow it makes the same mistake again.

Harbor turns those lessons into rules. Before every prompt it finds the few rules that fit the task
and hands them to the agent. The agent names the rules it used, so you see what helped. When a
session ends, what the agent learned waits for you to keep or drop.

  • Runs on your computer. The app, its database and its search model run locally and listen on
    127.0.0.1 only. No account, no telemetry.
  • No AI key needed. Search runs on a small embedding model that ships inside the app. Your own
    coding agent does the checks a key would do.
  • One set of rules for every agent. Claude Code, Codex, Cursor and GitHub Copilot get the same
    rules, from the same place.
  • Quiet when nothing fits. A rule must clear a similarity bar to be sent. No "top 5 memories"
    stuffed into every prompt.
  • Guardrails. Stop a risky shell command, file write or MCP call before it runs, with the reason
    you wrote.
  • You stay in charge. A rule goes live when you approve it. Every rule shows where it came from,
    and every change can be undone.

Quick start

npm install -g harborloop
harbor local

harbor local does four things:

  1. installs the app on this machine (a few hundred MB, once),
  2. starts it, with its own Postgres, on 127.0.0.1:4100,
  3. connects every coding agent it finds (hooks and an MCP server),
  4. turns Harbor on in the repo you are standing in, and offers to bring in the rules your repo
    already wrote (CLAUDE.md, AGENTS.md) for you to approve.

Then open a new session in your agent and work as usual. To check on it:

harbor doctor    # every part checked, with the fix for anything broken
harbor ui        # open the web app, signed in
Prefer Docker, or no global install?
npx harborloop local            # same thing, without installing the command
harbor local --docker           # run the app in Docker instead (about 700 MB, once)

With --docker, the app runs from ghcr.io/gethrbr/harbor-local with Postgres 17 beside it. The app
is published on 127.0.0.1:4100 only, Postgres is published nowhere, and Docker restarts both after a
reboot.

What a session looks like

You ask your agent for something. Before it answers, Harbor sends it the rules that fit:

#3  This repo uses pnpm. Never run npm install here.
#7  The API runs on port 4100; the web app proxies /v1 to it.

The agent works with them, and ends its answer with the rules it used:

harbor-applied: #3

Harbor prints a one-line receipt under the answer (Harbor: your agent used 1 rule), so you always
know when it helped. When nothing fits, it sends nothing. When the session ends, anything new the
agent learned (a fix, a convention, a trap) waits for you in harbor review.

How it works

flowchart LR
  subgraph machine["Your computer"]
    direction LR
    agent["Your coding agent<br/>Claude Code, Codex, Cursor, Copilot"]
    hooks["Harbor hooks<br/>~/.harbor/bin<br/>redact secrets, check guardrails"]
    subgraph app["Harbor app on 127.0.0.1:4100"]
      api["API and web app"]
      mcp["MCP server<br/>/mcp"]
      search["Search<br/>keywords + MiniLM embeddings"]
      db[("Postgres<br/>~/.harbor/local/postgres")]
    end
    agent -- "1. prompt, tool call, session end" --> hooks
    hooks -- "2. prompt, secrets redacted" --> api
    api --> search
    search --> db
    api -- "3. the few rules that fit, or nothing" --> hooks
    hooks -- "4. rules added to the prompt" --> agent
    agent -- "5. record what it learned" --> mcp
    mcp --> api
  end
  npm["npm registry<br/>install and update check"]
  hooks -. "once a day: is there a newer harborloop?" .-> npm

Your prompts, rules, code and database never leave your computer. The only outside call Harbor makes
on its own is the update check to the npm registry (full list).

Recall, before every prompt. The prompt hook sends the prompt (secrets redacted first) to the
app. The app searches your rules two ways, by meaning (the all-MiniLM-L6-v2 embedding model, run
locally) and by keyword, and merges the two lists with reciprocal rank fusion. A rule must clear a
similarity bar to be sent at all, which is why an off-topic prompt gets nothing. The first prompt of
a session gets the full set that fits; later prompts get only what is new when the topic shifts.
Rules you pin as always-on ride along every time.

It never blocks your agent. The lookup has a short deadline (about 6 seconds on the first
prompt, less after). If Harbor is slow or stopped, the hook sends nothing and your prompt goes
through as if Harbor were not there.

Capture, at the end of a session. On the first stop of a real working session, Harbor asks the
agent once to record what it learned with the harbor_record_learning tool. Before a new rule is
saved, Harbor shows the agent the rules it sits next to and asks: is this the same, narrower, new,
or does it reverse one? A repeat strengthens the old rule instead of making a copy. A reversal goes
to you for review, so a rule is never silently overwritten.

Guardrails, before a tool call. A guardrail matches a shell command, a file an agent is about to
write, or an MCP tool call. The hook checks it on your machine, against a local copy of your
guardrails, before the call runs. Each guardrail runs in one of three modes:

Mode What happens
observe counts how often it would have fired; says nothing (the default)
hold pauses for your approval (Claude Code) or refuses with a code
block refuses, with the reason you wrote

When a refusal is wrong for this one case, harbor allow-once <code> --because "<why>" lets that
exact command run once, and your reason is kept. The agent cannot run it for itself. Guardrails are a
seatbelt, not a security boundary.

In the background. While the app runs, it tidies your knowledge on a timer: hourly it labels new
rules with the files and actions they apply to; nightly it merges duplicate proposals, settles
conflicts and repairs the search index; daily it rechecks websites you imported; weekly it lets
unused rules fade, and retires rules no agent has used if you turn that on.
HARBOR_BACKGROUND_JOBS=off turns all of this off.

What runs on your computer

Everything below is what harbor local sets up. Nothing else is installed, and harbor uninstall
takes the agent wiring back out.

Processes

Process What it is Listens on
Harbor launcher node ~/.harbor/server/node_modules/harborloop-server/launcher.mjs, started in the background by harbor local. It starts the three below and stops them all if one stops nothing
Backend the API, the web app and the /mcp endpoint your agents call 127.0.0.1:4100
MCP server answers the MCP tools; your agents reach it through the backend's /mcp 127.0.0.1, a free port picked at each start
Postgres embedded Postgres, installed by npm with the app 127.0.0.1, a free port picked at each start
Hooks short scripts your agent runs on each prompt, tool call and session end. They exit when done nothing
Daily job harbor daily, started by the prompt hook at most once a day: update check, sign-in renewal, a small report to the local app nothing

There is no login item, launch agent or system service. After a reboot the app is down until your
agent's next prompt, when the prompt hook starts it again the way harbor local last did.
harbor local stop stops it, and it stays stopped until you run harbor local again.

With --docker, the launcher is replaced by two containers (harbor-local and postgres:17) that
Docker keeps running.

Files

Path What is in it
~/.harbor/server/ the app: backend, MCP server, web app and the search model. Replaced on each update
~/.harbor/local/harbor.env this install's secrets and your optional AI keys. Mode 0600 in a 0700 folder
~/.harbor/local/postgres/ the database: your rules, how-tos, guardrails and history
~/.harbor/local/objects/ documents you upload
~/.harbor/local/server.log the app's log, started over past 10 MB
~/.harbor/local/server.pid, start.json the running app, and how to start it again after a reboot
~/.harbor/auth.json, install-secret this machine's sign-in to the local app
~/.harbor/bin/ the hook scripts your agents run
~/.harbor/guardrails.json the local copy of your guardrails the hooks check against
~/.harbor/repos.json which repos you turned Harbor on in
~/.harbor/*.json, *.jsonl small state files: last update check, guardrail fires waiting to be sent, recall outcomes, locks

With --docker: ~/.harbor-local/harbor.env and compose.yml, plus two Docker volumes for the
data and the database.

Harbor writes nothing into your repos.

Agent settings it edits

Harbor adds its own entries and touches nothing else in these files. harbor uninstall removes them.

Agent Hooks MCP server
Claude Code ~/.claude/settings.json ~/.claude.json
Codex ~/.codex/hooks.json ~/.codex/config.toml
Cursor ~/.cursor/hooks.json ~/.cursor/mcp.json
GitHub Copilot CLI ~/.copilot/hooks/harbor.json ~/.copilot/mcp-config.json

Network calls

Call When
npm registry when you install or update: harborloop, then the app package harborloop-server
registry.npmjs.org/harborloop/latest the update check: once a day from the daily job, and when you run harbor doctor or harbor update
ghcr.io and Docker Hub only with --docker: the app image and postgres:17
websites you imported a daily recheck, only for sites you added yourself
OpenAI or Anthropic only if you add a key with harbor local keys

That is the full list. The search model ships inside the app package and is never downloaded at run
time. There is no telemetry: the local edition reports nothing to anyone.

What stays on your computer: your prompts, your code, your rules and the database. The hooks
redact secrets (API keys, tokens, private keys, passwords in URLs and more) before a prompt even
reaches the local app, and names and email addresses are masked in everything Harbor hands an agent.
The app refuses a request addressed to any host name but this machine's own (localhost,
127.0.0.1), and any caller without this machine's sign-in.

Benchmark

Does the agent get the rule it needs, and only that? We tested it on data nobody at Harbor wrote.

  • Rules: the real agent rule files (CLAUDE.md, AGENTS.md, .cursorrules, copilot-instructions.md)
    of 15 public repos, among them axios, deno, angular, material-ui, vllm, uv, home-assistant and
    storybook. Each repo is its own memory, split into one rule per bullet by a script: 694 rules.
  • Questions: merged pull requests opened by people after the rule file existed. Each system is
    asked the PR title plus the first sentence of its description, about what you would type to an
    agent.
  • Answer key: two models (gpt-4.1 and gpt-4.1-mini) read each PR's diff, blind, and named the
    rules the change had to follow. 122 PRs kept, 5 of them need no rule.
  • Frozen first: the set and its labels were frozen before any system ran on it. No Harbor
    setting was chosen on it, and Harbor ran on it once.
System Found a needed rule Found every needed rule Relevant share of what it served Quiet when no rule applied Rules served per PR
Harbor 48 / 117 17 / 117 37% 2 / 5 2.7
mem0 44 / 117 13 / 117 33% 0 / 5 2.9
basic-memory 43 / 117 12 / 117 30% 0 / 5 3.0
claude-mem 41 / 117 9 / 117 30% 0 / 5 3.0
Keyword search (BM25) 40 / 117 11 / 117 28% 0 / 5 3.0

All three test sets. The table above is the held-out set, the only one frozen before anyone
ran on it. Harbor was tuned on the other two, and we show them too:

Test set Harbor mem0 basic-memory claude-mem BM25
Held-out, 15 repos, never tuned on 48 / 117 44 43 41 40
First, 15 repos 45 / 108 45 38 39 37
Fresh, 15 repos 28 / 113 35 31 25 39

Harbor leads the held-out set, ties mem0 on the first, and is fourth on the fresh set. That one is
our open work.

Every system ran at its defaults, on the same rules, in throwaway containers: mem0 2.2.1 (local
embeddings, no LLM step), basic-memory 1.0.0, claude-mem 17.0.2, rank-bm25 0.2.2. The rivals return
their top 3; Harbor decides how many to send, and can send none. No API with a per-call price ran while the
systems ran.

Quiet matters as much as found. A tool that always returns its top 3 puts three rules in front
of your agent on every prompt, relevant or not. Replayed on 2,275 real prompts from coding sessions,
Harbor stayed silent on 66% of the prompts where no rule applied. A fixed top-k tool scores 0% there
by design.

What it does not show.

  • A rival tuned to serve more rules can pass Harbor on "found a needed rule" (claude-mem at top 4:
    51, BM25 at top 9: 49, at 5.3 rules per PR). In a search over thousands of settings per rival, none
    matched Harbor on all four columns at once.
  • Every system finds fewer than half. The graders agree only partly (0.37), and many needed rules
    share almost no words or meaning with a PR title.
  • Harbor's learning loop (agents naming the rules they used) is not in this test.

The web app

harbor ui opens the app on localhost:4100, signed in with a one-time link. It serves no page
until you ask.

Your agents

harbor local (and harbor init --local) finds the agents on this machine and wires each one.

Agent Hooks it gets
Claude Code prompt recall, subagent recall, tool context, guardrails, capture, session report
Codex prompt recall, subagent recall, tool context, guardrails, capture, after compaction
Cursor session and prompt recall, tool context, guardrails (shell and MCP), capture, before compaction
GitHub Copilot CLI prompt recall, subagent recall, tool context, guardrails, capture

Pick agents with --codex, --cursor, --copilot (or --no-...). In VS Code, start the harbor
MCP server once: MCP: List Servers, harbor, Start Server.

Turn it on in another repo:

cd ~/code/another-repo
harbor bind

Harbor stays off in every repo you do not bind. A repo with no git remote works too, as long as it
has a first commit. harbor off pauses a repo (--capture keeps recall on and stops only capture);
harbor on resumes.

The harbor command

Everything the web app does day to day, you can do from the terminal.

Command What it does
harbor review what waits for your approval, one at a time (--list, approve --all)
harbor rules the rules your agents get (search, add, edit, rm, restore)
harbor spaces your Spaces, to keep one project's rules apart from another's
harbor howtos step-by-step how-tos your agents saved, with every version (show, revert)
harbor guardrails what stops an agent, and how often each one caught something (mode <id> observe|hold|block)
harbor check "<cmd>" which guardrail would stop this command; runs nothing
harbor guardrail test how often each guardrail would have fired over your agents' history
harbor handoffs notes one session left for the next
harbor home the numbers: sessions helped, rules sent, catches (--days 7|30|90)
harbor context what Harbor and your other tools add to every turn
harbor scan your agents and the MCP servers each can reach; sends nothing
harbor settings how Harbor learns: capture mode, learning from corrections, retiring unused rules
harbor doctor is it actually working? Every part, with the fix
harbor status this repo, from local files only
harbor ui open the web app, signed in
harbor update the latest release, hooks included
harbor local stop stop the app until you run harbor local again
harbor uninstall take Harbor out of your agents and this machine

harbor help lists every command and flag.

MCP tools

Besides the hooks, your agents get an MCP server at http://localhost:4100/mcp with five tools:

Tool What it does
harbor_get_knowledge search your rules and memories for the task at hand, or open a how-to
harbor_record_learning save a convention, pattern, gotcha or preference it learned
harbor_revoke_learning take back a learning it recorded
harbor_save_how_to save the numbered steps of a job it will do again; versions are kept
harbor_handoff leave a note for the next session, or pick one up

FAQ

Why not just CLAUDE.md?

Keep it. Harbor reads your CLAUDE.md and AGENTS.md in as rules. The difference:

A rules file Harbor
What the agent gets the whole file, every session the few rules that fit this prompt
How it grows when you edit it from what your agents ran into, once you approve
Repeats and contradictions pile up caught before they are saved
Several agents one file per tool, drifting apart the same rules for every agent
Did it help? you cannot tell the agent names the rules it used
Stopping a bad command not its job guardrails, with a reason on record
Do I need an OpenAI or Anthropic key?

No. Recall, search by meaning and capture run on your machine. A key turns on two extras: drafts
from uploaded documents, and rules read from your corrections. Add one with harbor local keys; it
stays in ~/.harbor/local/harbor.env and is sent only to that provider.

Will it slow my agent down?

The prompt hook waits at most about 6 seconds on a session's first prompt, and less after. If the app
is slow or stopped, the hook sends nothing and your prompt goes through unchanged.

What happens after a reboot?

Nothing runs at login. Your agent's next prompt starts the app again in the background, and the
prompt after that gets its rules.

Can I see or edit what it learned?

Yes: harbor rules, harbor review or the web app. Every rule shows where it came from, and every
change can be undone (harbor rules restore).

Configuration

Harbor keeps its settings in ~/.harbor/local/harbor.env (with --docker,
~/.harbor-local/harbor.env). After an edit, run harbor local again.

Setting What it does
OPENAI_API_KEY, ANTHROPIC_API_KEY optional. Turn on drafts from uploaded documents and rules read from your corrections. Set them with harbor local keys
HARBOR_BACKGROUND_JOBS=off stop the background jobs and keep the app running
HARBOR_LOCAL_PORT run a second install on another port (1024 to 65535; not with --docker)
KG_COSINE_FLOOR how close a rule must be to the prompt to be sent (0.32 by default)

These are the settings Harbor supports. The server reads other variables too (most start with
KG_); they tune recall internally and can change or go away in any release.

harbor settings changes how Harbor learns: whether captures wait for review or go live, whether it
learns from your corrections, how many characters a lookup may send, and whether unused rules
retire.

Troubleshooting

Start with harbor doctor. It checks the app, the sign-in, each agent's hooks and MCP entry, this
repo, recall delivery and guardrails, and prints the fix for whatever is broken.

Problem Fix
The agent gets no rules open a new session: hooks load when a session starts. Then harbor doctor
The app is not running harbor local. After a reboot, your agent's next prompt starts it again
Port 4100 is taken stop what is on it. Your agents send their key to whatever answers on 4100, so it should be Harbor
A rule keeps coming back wrong harbor rules edit or harbor rules rm; your agent's next session gets the change
Codex ignores the hooks Codex asks you to trust new hooks once; harbor doctor says if it has not
The app's log ~/.harbor/local/server.log

Uninstall

harbor uninstall
npm uninstall -g harborloop

harbor uninstall takes Harbor's hooks and MCP entries out of every agent and signs this machine
out. It keeps the app and your rules in ~/.harbor/local, so you can come back with harbor local.
To delete those too, run harbor local stop and then remove ~/.harbor.

Requirements

  • macOS or Linux. Windows is not supported yet.
  • Node 22.12 or newer.
  • At least one of Claude Code, Codex, Cursor or GitHub Copilot.
  • For --docker: Docker Desktop with Compose.

Build from source

git clone https://github.com/gethrbr/harbor.git
cd harborloop
npm ci
scripts/local/harbor-local.sh setup

builds the app's image from this checkout and starts it (scripts/local/harbor-local.sh up | down | logs | status).

Folder What it is
packages/cli harborloop: the harbor command and the hooks your agents run
packages/backend the API: recall, capture, review, guardrails, background jobs
packages/mcp-server the MCP server your agents call
packages/frontend the web app
packages/ai embeddings, model providers, secret and PII masking
docker/local the app's image and the launcher that runs it without Docker

Contributing

Issues and pull requests are welcome. See CONTRIBUTING.md, and
SECURITY.md to report a vulnerability privately.

License

MIT

Yorumlar (0)

Sonuc bulunamadi