Accounting Engine logo

Accounting Engine

Community
peterbamuhigire
accounting-engine

Use when designing or implementing double-entry accounting policy and an embedded ledger engine for invoices, payments, stock, balanced postings, mapped accounts, idempotency, reversals, period locks, audit trails, and financial statements.

Overview

Publisherpeterbamuhigire
Repositorychwezi-dev-engine
Skill nameaccounting-engine
Stars
29
Forks
6
Bundled files
5
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 5 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by peterbamuhigire on GitHub. Read the source before you install it.

Installation

Install the Accounting Engine AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/peterbamuhigire/chwezi-dev-engine/tree/main/skills/finance-accounting/accounting-engine
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/peterbamuhigire/chwezi-dev-engine.git /tmp/chwezi-dev-engine
mkdir -p .claude/skills
cp -r /tmp/chwezi-dev-engine/skills/finance-accounting/accounting-engine .claude/skills/accounting-engine
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Accounting Engine in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Accounting Engine on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Accounting Engine is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Accounting Engine

Evidence Produced

CategoryArtifactFormatExample
CorrectnessLedger invariant test packMarkdown plus transaction fixturesbalanced posting, idempotency, reversal, period lock, subledger tie-out, and audit trail

Inputs

ArtefactRequired?Purpose
Transaction event and tenant contextyesDefine the event and isolation boundary
Account mapping and doctrine policyyesResolve balanced ledger accounts
Existing ledger and lock stateyesPrevent duplicate or closed-period posting

Outputs

ArtefactConsumerAcceptance condition
Posting contract and journal evidenceFeature services and finance reviewBalanced, idempotent, traceable, tenant-scoped

Capability contract

Read and search are required. Database writes, migrations, backfills, reversals, and period operations require explicit authority and a verified compensating path.

Degraded mode

Fallback without doctrine, mappings, or database access: return a posting design and unresolved control list; do not invent accounts or claim ledger correctness.

Decision rules

ConditionPosting actionFailure avoided
New valid economic eventAppend balanced journalMissing financial record
Duplicate idempotency keyReturn prior resultDouble posting
Error in posted journalPost linked reversal/correctionDestruction of audit history
Closed periodReject or use authorised later-period adjustmentPeriod integrity breach

Domain anti-patterns

  • Posting directly from controllers. Fix: use one posting service and contract.
  • Updating or deleting journals. Fix: reverse and repost with links.
  • Guessing accounts from feature names. Fix: require mapping-layer resolution.
  • Retrying without idempotency. Fix: persist and enforce the event key.
  • Mixing tenants in one posting context. Fix: require tenant scope on every ledger operation.

Use When

  • The product handles money, inventory value, payroll, tax, customer balances, supplier balances, assets, grants, donations, loans, refunds, wallet balances, or financial reporting.
  • A SaaS must replace routine bookkeeping in external products such as QuickBooks, Xero, Sage, Pastel, Tally, Zoho Books, or Wave.
  • You need architecture, schema, posting rules, tests, documentation, or review findings for ledger-backed business software.

Do Not Use When

  • The task is only financial analysis or projections without software architecture; use accounting-finance-controller or the business-plan finance skills.
  • The system only displays imported accounting reports and does not create business events or postings.
  • A jurisdiction requires a licensed accountant, auditor, or tax practitioner to exercise professional judgement; design the system support, but do not claim the software replaces that judgement.

Hard Rules

  • NEVER let a business module write directly to gl_entries, journal_lines, journal_entries, or any ledger table.
  • ALWAYS write ledger records through one service: LedgerPostingService::post(JournalEntry $entry) or the project-equivalent single posting service.
  • NEVER update, delete, or soft-delete posted journal lines. Corrections are reversing journals linked to the original entry.
  • NEVER store authoritative balances that cannot be rebuilt from journal lines. Materialized balances are caches with a documented rebuild command.
  • NEVER hardcode account codes in business logic. Use account mappings resolved at posting time.
  • NEVER use LIFO for IFRS or IFRS for SMEs tenants.
  • MUST reject posting when required account mappings are missing, inactive, cross-tenant, or not valid for the source document.

Canonical Architecture

Business modules emit events. A mapper turns events into balanced JournalEntry value objects. The posting service validates and writes the entry atomically. Reports, subledgers, balances, tax schedules, and dashboards are deterministic projections of the ledger.

text
Sales / Stock / Payroll / Assets / Payments / Grants
        -> business event
        -> account resolver and posting-rule mapper
        -> JournalEntry value object
        -> LedgerPostingService::post()
        -> append-only journal_entries + journal_lines
        -> reports, subledgers, tax schedules, dashboards

Required Model

Core tables:

  • chart_of_accounts
  • account_mappings
  • journal_entries
  • journal_lines
  • accounting_periods
  • posting_rule_versions
  • accounting_integrity_runs
  • accounting_audit_log

Every accounting table MUST carry tenant_id, unless the product is explicitly single-tenant. If legacy files use franchise_id, treat it as a project-specific tenant alias and document the mapping.

Posting Service Contract

php
<?php
declare(strict_types=1);

final readonly class JournalEntry
{
    public function __construct(
        public int $tenantId,
        public string $idempotencyKey,
        public DateTimeImmutable $entryDate,
        public string $sourceType,
        public string $sourceId,
        public string $description,
        /** @var list<JournalLine> */
        public array $lines,
        public ?int $reversesJournalId = null,
    ) {}
}

final readonly class JournalLine
{
    public function __construct(
        public int $accountId,
        public string $currency,
        public string $debitMinor,
        public string $creditMinor,
        public array $dimensions = [],
    ) {}
}

interface LedgerPostingService
{
    public function post(JournalEntry $entry): PostedJournal;
}

The service validates tenant scope, account status, open period, debit-credit equality, currency policy, idempotency, source document state, and mapping completeness before insert.

Integrity Checks

Run these per tenant and per accounting period from day one:

  • Debits equal credits per journal_entry_id.
  • Trial balance total debits equal total credits.
  • AR control account equals customer-tagged journal line balance.
  • AP control account equals supplier-tagged journal line balance.
  • Inventory control account equals stock-on-hand value by item/location/cost layer.
  • Fixed asset control account equals asset-register cost less disposals.
  • Payroll liability accounts equal unpaid statutory and employee deductions.
  • No journal exists in a locked period unless it is a permitted reopening workflow with approval evidence.
  • No ledger table has rows written outside the posting service.
  • Materialized balances rebuild to the same values as stored cache rows.

User Experience Principle

Non-accountants record business actions: Record Sale, Receive Payment, Buy Stock, Run Payroll, Record Asset Purchase, Receive Grant, Close Month. The system posts accounting behind the scenes. Accountant-facing roles get journals, CoA, mappings, period close, manual journal, and report exports.

Companion Skills

  • ledger-posting-engine-core (chwezi-accounting-doctrine) for IFRS-aligned industry templates.
  • inventory-costing-and-stock-accounting (chwezi-accounting-doctrine) for IAS 2 stock valuation and COGS flows.
  • payroll-and-statutory-postings-east-africa (chwezi-accounting-doctrine) for PAYE/NSSF/LST payroll journal shapes.
  • fixed-assets-and-depreciation for IAS 16 asset lifecycle.
  • multicurrency-and-fx for IAS 21 currency handling.
  • multi-tenant-saas-architecture, api-design-first, and advanced-testing-strategy for platform integration.

References

  • references/posting-engine-contract.md
  • references/integrity-invariants.md

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Accounting Engine AI skill do?

Use when designing or implementing double-entry accounting policy and an embedded ledger engine for invoices, payments, stock, balanced postings, mapped accounts, idempotency, reversals, period locks, audit trails, and financial statements.

Why use Accounting Engine on TypingMind?

Because you install it once and use it with any model. Accounting Engine is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Accounting Engine in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/peterbamuhigire/chwezi-dev-engine/tree/main/skills/finance-accounting/accounting-engine. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Accounting Engine?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Accounting Engine?

As many as you like. As long as a model supports skills, you can use Accounting Engine with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Accounting Engine AI skill free?

Yes. It is published on GitHub by peterbamuhigire under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇