Skip to content
Projetos

Sobre

ERP nativo de IA para contabilidade, estoque, vendas, compras e muito mais, operado em linguagem natural. Gratuito para sempre e auto-hospedado. GPL v3.

Negócios e finanças

Como estes números são medidos

Crescimento medido de estrelas

em 24 h
+41
em 7 dias
+50
em 15 dias
+52
em 1 mês
Coletando histórico

Variações líquidas em períodos sobrepostos, não totais diários. Medições ausentes ficam em branco. Estrelas indicam interesse, não qualidade.

README.md

Original

ERPClaw

ERPClaw keeps the books of a small business: customers and suppliers, invoices and bills, payments, stock, bank, tax and reports. You do not fill in forms. You write what you want in plain words, for example Invoice Acme Ltd for 3 hours of consulting at 150 dollars an hour, and an AI model of your choice prepares it.

You stay in control. The AI can read your books, but it cannot change them. Each change (an invoice, a payment, a bill) comes to you first as a card. The card shows what will go into the books. Nothing goes into the books until you click Yes on the card.

How ERPClaw works, in four steps. 1. You write: Invoice Acme Ltd for 3 hours of consulting at 150 dollars an hour. 2. The AI prepares a card with the invoice and its total, 450.00. 3. You click Yes, go ahead. 4. The invoice goes into the books. Below the steps: the AI can read your books, but it cannot change them.

See it work

A real conversation on new books, with the default model:

The ERPClaw chat page. The owner asks for an invoice to Acme Ltd for 3 hours of consulting at 150 dollars an hour. A card shows the invoice with its line and its total, 450.00, and the buttons Yes, go ahead, No and Change something. The owner clicks Yes, go ahead. Then the owner asks who owes money, and ERPClaw answers that Acme Ltd owes 450.00.

Is this guide for you?

This guide installs ERPClaw on your own computer. Your books are kept on your computer, in your own database. What you ask, and the parts of your books that the AI reads to answer you, go to the AI provider that you choose, and to no other place.

  • You do not need to be a programmer. You copy each command from this guide into a terminal and press Enter. Each step starts with a short line that tells what the step does.
  • Plan about one hour for the first install. For most of that time, the computer downloads and builds.
  • You need a key from an AI provider. A key is a long secret text that the provider gives you, so that it can charge your account. Claude from Anthropic is the default. Other models also work (step 7).
  • If a step shows an error, stop there, and read "When something goes wrong" near the end of this guide.

A terminal is a window where you type commands.

  • On a Mac: open Finder, then Applications, then Utilities, then Terminal.
  • On Ubuntu: press Ctrl, Alt and T together.

To run a command, copy all the lines of one grey box, paste them into the terminal, and press Enter. When a command asks for a password or a secret, nothing shows while you type or paste. That is normal.

You use three terminal windows. Keep each one open until the end of step 9:

Window What it is for
Window 1 Steps 1 to 4, and a new sign-in code when you need one
Window 2 The books (step 5). They run while this window is open
Window 3 Steps 6 to 8. The chat runs in it while it is open

To open a new window: on a Mac, press Command and N in Terminal. On Ubuntu, press Ctrl, Shift and N.

How you use it each day

After the install:

  1. The database starts by itself when your computer starts. Only in WSL or a container, start it first with sudo service postgresql start.
  2. In one terminal window, start the books with the command of step 5.
  3. In a second window, start the chat with the commands of step 8. Paste the books token and your model key, and type a chat password (you can use the same one each day).
  4. Open http://127.0.0.1:8201 in your browser. Sign in with the name opencode and your chat password.
  5. Ask in plain words, for example Who owes me money?, List my open invoices. or Invoice Acme Ltd for 3 hours of consulting at 150 dollars an hour.
  6. When a card comes, read it. Click Yes, go ahead only if it is right. Nothing goes into the books without your Yes.
  7. To stop, press Ctrl and C together in each of the two windows.

If the chat shows the books sign-in card again, make a new code (see "A sign-in code does not work" in "When something goes wrong"). Make a backup often (see "Back up and update").

How it works

It has three parts:

  • The books server (packages/, plugins/): the ledger and the areas of the books (sales, purchases, stock, bank, tax, currencies, reports, the year end, exports). It gives the model its actions as MCP tools, and it serves the approval page.
  • The chat program (chatside/): built from opencode with ERPClaw's patches. It runs on your computer and shows the chat as a web page. It talks to the model you choose and to your books server.
  • The approval card. The model can read your books, but it cannot change them. Every change (an invoice, a payment, a bill) comes back as a card in the chat. You read the card, and you approve or decline it. Only then does anything reach the books.

What ERPClaw promises:

  • Nothing reaches the books without a card that a person approved. The model never approves.
  • The ledger is append-only. An undo is a reversing entry, never an edit.
  • Amounts are exact decimals, and every entry balances.
  • The model never makes up an id or a total: the books server finds and computes them.

ERPClaw works with any model that has tool calling. How well it reads your words depends on the model.

What you need

  • A computer with Ubuntu 24.04, or a Mac with Apple silicon. To check a Mac: open the Apple menu, then About This Mac. The Chip line must name Apple M1 or a later chip. This version has no chat program for Intel Macs, and this guide does not cover Windows yet. (The chat program builds for the targets linux-x64, darwin-arm64 and windows-x64.)
  • On a Mac, Homebrew, the usual tool that installs other tools. Its page shows the one command that installs it. Its set-up also installs Apple's command line tools, which include git.
  • PostgreSQL 15 or newer, the database that keeps your books. Step 2 installs it. Our tests run on PostgreSQL 18.
  • uv, which installs the Python parts of ERPClaw, and Python 3.12 for them. Install it with this command, then open a new terminal window: curl -LsSf https://astral.sh/uv/install.sh | sh
  • git, curl, unzip and Bun 1.4.4, to get the code and to build the chat program. On Ubuntu: sudo apt install git curl unzip. A Mac already has curl and unzip. Step 6 installs Bun.
  • A model and your own key: Claude through Anthropic, Gemma through Ollama, Qwen through OpenRouter, or any model with tool calling that opencode supports. You get the key on the provider's web site, after you make an account there.

1. Get the code

In short: this downloads ERPClaw into a new folder, erpclaw, and installs its Python parts. Use window 1. A new window starts in your home folder, so the folder is ~/erpclaw.

git clone https://github.com/avansaber/erpclaw.git
cd erpclaw
uv sync --locked --no-dev --python 3.12

2. PostgreSQL: one database, two roles

In short: this installs PostgreSQL, the database that keeps your books, and makes two database users for ERPClaw. You choose a password for each, and you save both in a file that only you can read. Use window 1.

The books use two roles. The owner role owns the database and makes its tables. The runtime role is the only one the books server uses: it gets exactly the rights it needs, and no more.

Each createuser asks for the new role's password twice, so the password is never in your shell history or the list of running programs. Choose two different passwords, and keep them in your password manager.

On Ubuntu. The first sudo asks for your own computer password:

sudo apt install postgresql
sudo service postgresql start          # only if it is not running yet (for example in a container or WSL)
sudo -u postgres createuser --login --pwprompt erpclaw_owner
sudo -u postgres createuser --login --pwprompt erpclaw_rt
sudo -u postgres createdb -O erpclaw_owner -T template0 erpclaw

On macOS (Homebrew), your own user is the database's superuser:

brew install postgresql@18
brew services start postgresql@18
createuser --login --pwprompt erpclaw_owner
createuser --login --pwprompt erpclaw_rt
createdb -O erpclaw_owner -T template0 erpclaw

Do not grant the runtime role anything yourself. ERPClaw sets its rights in the next step, and the books server refuses to start if the runtime role can do more than it should (a superuser, a role that owns the database, or one that can create objects in it).

Give PostgreSQL the two passwords in your own password file, ~/.pgpass. PostgreSQL reads it by itself, so no password is ever part of an address, a command or a setting. Open it in a text editor: nano ~/.pgpass opens a simple one in the terminal, and makes the file if it is not there. Add these two lines, each with the password you chose for that role. The * in the third field lets the same line serve every database of that role, such as a restored copy (see "Back up and update"):

localhost:5432:*:erpclaw_owner:the-owner-password
localhost:5432:*:erpclaw_rt:the-runtime-password

In nano, press Ctrl and O, then Enter, to save, and Ctrl and X to close it. Then make the file readable by you alone:

chmod 600 ~/.pgpass

Then write the two addresses, which hold no password, into a file ~/.erpclaw-db in the same way (nano ~/.erpclaw-db):

ERPCLAW_MIGRATION_URL=postgresql+psycopg://erpclaw_owner@localhost:5432/erpclaw
ERPCLAW_DATABASE_URL=postgresql+psycopg://erpclaw_rt@localhost:5432/erpclaw

3. Make the books

In short: this makes your empty books in the database. Run it once, in window 1. At the end it prints a line that starts with books made, company.

This makes the books' tables as the owner, records the plugins, and gives the runtime role exactly its rights. It runs once; on books that already hold a company it refuses and changes nothing.

set -a; . ~/.erpclaw-db; set +a
uv run erpclaw-books-create

4. You, as the books' owner

In short: this gives you two secrets: a books token, which the chat program uses to reach your books, and a sign-in code for step 9. Use window 1.

The books already know one person, owner. This gives owner a books token (the chat program sends it) and a sign-in code (for the approval page):

ERPCLAW_OWNER_DATABASE_URL="$ERPCLAW_MIGRATION_URL" uv run python -m erpclaw_books_server.users --name owner
  • It prints token: ... and code: .... Keep the token somewhere safe, for example in your password manager, never in a file inside your project, a log or the chat.
  • A code works once, within 10 minutes. For a new one, run the same command with --code-only.

5. Start the books server

In short: this starts the books. Open window 2 for it, and leave it open: the books run while this window is open. To stop them, press Ctrl and C in this window.

In its own terminal, with only the runtime address:

cd erpclaw
ERPCLAW_DATABASE_URL="$(sed -n 's/^ERPCLAW_DATABASE_URL=//p' ~/.erpclaw-db)" ERPCLAW_HOME="$HOME/erpclaw-books" uv run erpclaw-books-server

It listens on http://127.0.0.1:8001, only on your own machine. The approval page is at the same address. uv run erpclaw-books-server --check prints its settings (without any secret) and exits.

6. Build the chat program

In short: this builds the chat program and puts it where the terminal finds it. It is the longest step: the first build can take about 15 minutes.

First, in window 1, install Bun, the tool that builds the chat program:

curl -fsSL https://bun.sh/install | bash -s "bun-v1.4.4"

Then open window 3, so that the terminal finds bun. In window 3, go into the ERPClaw folder with cd erpclaw.

The output folder starts empty, so that after a build it holds exactly one program (an older build there would be copied too). On Ubuntu:

rm -rf "$HOME/erpclaw-chat"
chatside/build.sh linux-x64 --src "$HOME/erpclaw-opencode-src" --out "$HOME/erpclaw-chat"

On a Mac:

rm -rf "$HOME/erpclaw-chat"
chatside/build.sh darwin-arm64 --src "$HOME/erpclaw-opencode-src" --out "$HOME/erpclaw-chat"

The build ends with a line path: ...: that file is the chat program, and beside it the build writes its checksum file (.sha256). Check the program against it, then copy the program (not the checksum file) onto your PATH. On Ubuntu:

(cd "$HOME/erpclaw-chat" && sha256sum -c erpclaw-linux-x64-*.sha256)
mkdir -p "$HOME/.local/bin"
find "$HOME/erpclaw-chat" -name 'erpclaw-linux-x64-*' ! -name '*.sha256' -exec cp {} "$HOME/.local/bin/erpclaw" \;

On a Mac (brew install coreutils adds the sha256sum command if your Mac does not have it):

brew install coreutils
(cd "$HOME/erpclaw-chat" && sha256sum -c erpclaw-darwin-arm64-*.sha256)
mkdir -p "$HOME/.local/bin"
find "$HOME/erpclaw-chat" -name 'erpclaw-darwin-arm64-*' ! -name '*.sha256' -exec cp {} "$HOME/.local/bin/erpclaw" \;
  • The build fetches opencode at the commit in chatside/PIN, applies chatside/patches/ in order, and builds one program.
  • --src must be a folder only for the build: the build runs git reset --hard and git clean -fd in it.
  • Check that the terminal finds the chat program: in window 3, type command -v erpclaw and press Enter. It must print a path that ends in /.local/bin/erpclaw. If it prints nothing, see "When something goes wrong".

7. Settings for the chat program

In short: this tells the chat program where your books are and which AI model to use. If you use Claude, the default, you change only the books address. Use window 3.

Make a work folder and copy the settings into it:

mkdir -p "$HOME/erpclaw-work"
cp chatside/customer-opencode.json "$HOME/erpclaw-work/opencode.json"

Open ~/erpclaw-work/opencode.json in a text editor (nano ~/erpclaw-work/opencode.json; in nano, Ctrl and W finds a word, for example books.example.com) and change two things:

  1. Your books address. Under mcp → servers → books, change "url": "https://books.example.com/mcp" to "url": "http://127.0.0.1:8001/mcp".

  2. Your model. Three places name it, and all three must agree: "model" at the top, "model" under agents → erpclaw, and the provider in "enabled_providers". The default is Claude Haiku 5.5: the model anthropic/claude-haiku-5-5#high (with its high variant) and the provider anthropic. The steps of this README test this default. To use another model with tool calling, put it in the same three places as opencode names it (provider/model, and the provider alone), and give its key in step 8. For example:

    • Gemma through Ollama: the model ollama-cloud/gemma4:31b, the provider ollama-cloud, your key in OLLAMA_API_KEY;
    • Qwen through OpenRouter: the model openrouter/qwen/qwen3.5-9b, the provider openrouter, your key in OPENROUTER_API_KEY.

    The chat program uses only the model that its settings name. If that model cannot be used, it says so and sends nothing.

8. Run it

In short: this starts the chat, in window 3. Leave the window open: the chat runs while it is open. To stop it, press Ctrl and C in this window.

The chat runs as a small web server on your own computer. read -rs takes each secret without showing it and without putting it in your shell history. Paste the books token from step 4, press Enter, then paste your model key and press Enter, then type a chat password you choose and press Enter:

cd "$HOME/erpclaw-work"
read -rs ERPCLAW_BOOKS_TOKEN && export ERPCLAW_BOOKS_TOKEN
read -rs ANTHROPIC_API_KEY && export ANTHROPIC_API_KEY     # or OLLAMA_API_KEY, or OPENROUTER_API_KEY
read -rs OPENCODE_SERVER_PASSWORD && export OPENCODE_SERVER_PASSWORD
export OPENCODE_DISABLE_AUTOUPDATE=1 OPENCODE_DISABLE_MODELS_FETCH=1
export ERPCLAW_BOOKS_URL=http://127.0.0.1:8001
erpclaw serve --hostname 127.0.0.1 --port 8201

ERPCLAW_BOOKS_URL is your books address from step 7, without /mcp. The cards on the page reach your books through it.

Then open http://127.0.0.1:8201 in your browser and sign in with the name opencode and the chat password.

In this version, use only the web page for the books. erpclaw run cannot answer a card, and the full-screen chat is not tested with the books.

9. The first question and the first card

In short: your first questions, on the chat page in your browser. Each change to the books comes as a card, and you click Yes, go ahead on it.

  1. In the page's input box, ask: Set up my company: Example Trading LLC, in US dollars, the year starts on 1 January. Press Enter.

  2. The chat shows a books sign-in card. A code works once, within 10 minutes. If the code from step 4 is older, make a new one in the terminal of step 4 (window 1):

    ERPCLAW_OWNER_DATABASE_URL="$ERPCLAW_MIGRATION_URL" uv run python -m erpclaw_books_server.users --name owner --code-only
    

    Enter the name owner and the code, and click Sign in. The header then reads "Signed in to books as owner".

  3. The chat shows the set-up card with the company details. Read it and click Yes, go ahead. The company is set up.

  4. Ask: Invoice Acme Ltd for 3 hours of consulting at 150 dollars an hour. On your own books, the first answer after the set-up is a card that asks once whether you agree to use a hosted model (your words go to the model's provider). Read it and click Yes, go ahead if you agree.

  5. Ask for the invoice once more: Invoice Acme Ltd for 3 hours of consulting at 150 dollars an hour. On new books, a card for the new customer and a card for the new item come first. Then a card shows the invoice, with its lines and total. Click Yes, go ahead on each card.

  6. Ask: Who owes me money? Acme Ltd owes 450.00.

Back up and update

A backup is a dump of the database, as the owner (the password comes from ~/.pgpass). Make one at least once a week, and before each update:

pg_dump -Fc -h localhost -U erpclaw_owner -d erpclaw -f "$HOME/erpclaw-backup-$(date +%Y-%m-%d).dump"

To restore it, make a new empty database owned by erpclaw_owner (as in step 2, with another name) and run pg_restore -h localhost -U erpclaw_owner -d <that database> <the dump>. Keep your backups somewhere other than this machine, for example on a USB drive.

An update of ERPClaw, in the erpclaw folder (cd erpclaw):

  1. Get the new code (git pull) and run uv sync --locked --no-dev --python 3.12.

  2. Stop the books server (Ctrl-C in its terminal).

  3. Bring the books up to the new code, as the owner:

    set -a; . ~/.erpclaw-db; set +a
    uv run erpclaw-books-update
    
  4. Start the books server again (step 5). If chatside/ changed, build the chat program again (step 6).

When something goes wrong

  • A command says command not found. Open a new terminal window and try again: a window finds a new tool only after it opens. In the new window, run cd erpclaw first for the commands that this guide runs in the erpclaw folder. If erpclaw is still not found, run this line once, then open a new window. On a Mac: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zprofile. On Ubuntu: echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc.

  • The chat page says "The model in your settings cannot be used." Check the model's name in step 7, and the key that you pasted in step 8. Then stop the chat (Ctrl and C in its window) and start it again (step 8).

  • The chat says "The books are not reachable yet; try again in a moment." Check that the books window (step 5) is open and shows no error. Then ask again.

  • The books server does not start, and says the runtime role "does not hold exactly its policy". Someone gave the runtime role rights by hand, or took some away. Set them back as the owner, then start the server again:

    set -a; . ~/.erpclaw-db; set +a
    uv run python - <<'EOF'
    import os
    from erpclaw_core import db, grants, setup
    
    # The plugins' tables are part of the runtime role's rights.
    setup.load_plugins()
    # As the owner, set the runtime role's rights back to exactly what it needs.
    with db.make_engine(os.environ["ERPCLAW_MIGRATION_URL"]).begin() as conn:
        grants.apply_grants(conn, "erpclaw_rt")
    print("rights set back")
    EOF
    

    Rights given to PUBLIC, or to a role that erpclaw_rt belongs to, must be taken back by whoever gave them.

  • It says the runtime role belongs to a role, or owns the database. Make erpclaw_owner the database's owner and take erpclaw_rt out of every role (REVOKE <role> FROM erpclaw_rt).

  • A sign-in code does not work. A code works once, within 10 minutes. Make a new one in window 1 with the command of step 9, item 2. If you closed window 1, open a new window and run these two lines first:

    cd erpclaw
    set -a; . ~/.erpclaw-db; set +a
    

Keep it safe

  • Never put your books token or your model key in a file in your work folder, in a log or in the chat.
  • ERPClaw never updates itself. A new version comes only from a new build.
  • The browser plugin stays off, so the chat program can never click Yes on a card for you. Keep other opencode settings out of your work folder too: an opencode.json in a subfolder, an opencode.json inside a .opencode folder, or the OPENCODE_CONFIG_CONTENT variable could switch it back on.
  • The chat program keeps its own settings in its own folder erpclaw-chat (for example ~/.config/erpclaw-chat), never in opencode's.

The tests

For developers only. You do not need the tests to use ERPClaw.

uv sync --locked --all-extras --python 3.12
ERPCLAW_TEST_DB_PRIVATE=1 ERPCLAW_PG_TEST_URL=postgresql+psycopg://<a role that may create databases>@localhost:5432/erpclaw_test uv run pytest -q tests/

Use a PostgreSQL server of its own for the tests: ERPCLAW_TEST_DB_PRIVATE=1 says that the server belongs to this test run alone, and the tests refuse to start without it. The tests make and drop their own databases. The live chat tests need a built chat program and are skipped without one.

Why ERPClaw has its own engine

ERPClaw v2 was a skill for general AI agents such as OpenClaw and Hermes. ERPClaw v3 has its own books server and its own chat program. We made this change for three reasons:

  • The general agents held us back. ERPClaw had to fit each agent's own setup and way of working. Now ERPClaw controls the whole path from your words to your books.
  • Lighter models can do the work. The model sees only the books' own actions, so smaller and cheaper models can keep the books. The default is Claude Haiku 5.5, and we also test ERPClaw with Gemma 4 31B, an open model.
  • Focused, with fewer errors. The model can read your books, but it cannot change them. Each change is a card that you check and approve on the books' own page.

ERPClaw v2, the OpenClaw skill, stays on the branch v2.

About and acknowledgements

ERPClaw is accounting software licensed under GPL-3.0-only. Its chat program is based on opencode. ERPClaw licence · opencode

We studied how ERPNext, Odoo and Tryton handle accounting transactions when developing ERPClaw’s books rules. Our US chart of accounts is adapted from ERPNext's US chart, and our currency reference data comes from Odoo's currency file. ERPNext · Odoo · Tryton · Third-party notices

Licence

GPL-3.0-only (see LICENSE). The parts that come from other projects, and their licences, are listed in THIRD_PARTY_NOTICES.md.

Explore projetos relacionados

Carregando…