Accounting Sync
ASecurityUse when code pushes transactions, invoices, payments or journal entries from a product into an accounting system (QuickBooks Online, Xero, NetSuite, Omie, Conta Azul) or reads changes back. Covers explicit account and entity mapping per tenant, summary journal entries with your ids, storing their ids and version tokens for idempotent updates, closed-period handling, conflict detection and policy when the customer edits in the accounting system, rate limits and batching, OAuth refresh-token r...
- 7 stars
- 0 votes
- 0 copies
- 1 view
- Added November 11, 2026
Works with
Security analysis
100/100Pro scans all 7 files and shows the line behind each finding
npx -y skills add felipealvarenga/fintech-skills --skill accounting-sync --agent claude-codeAre you the author of Accounting Sync?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/felipealvarenga-accounting-sync)---
name: accounting-sync
description: >-
Use when code pushes transactions, invoices, payments or journal entries from a product into an
accounting system (QuickBooks Online, Xero, NetSuite, Omie, Conta Azul) or reads changes back.
Covers explicit account and entity mapping per tenant, summary journal entries with your ids,
storing their ids and version tokens for idempotent updates, closed-period handling, conflict
detection and policy when the customer edits in the accounting system, rate limits and batching,
OAuth refresh-token rotation, voids instead of deletes, and a daily drift report. Triggers on an
accounting integration, a duplicated or missing entry in the customer's books, a sync that
overwrote an accountant's change, an expired connection. Not for the vendor's API setup or OAuth
flow; vendor plugins (for example Intuit's intuit-developer) cover that.
license: MIT
metadata:
author: Felipe Alvarenga
version: 0.1.0
---
# Accounting sync
The customer's accountant lives in QuickBooks or Xero. Your product lives in its own ledger.
A sync that duplicates entries, overwrites an accountant's recategorization or dies when a
token rotates costs the customer a month-end and costs you the account. The rules below come
from running these integrations in production; the vendor's API details come from the vendor.
## Execution contract
The user installed this skill so these rules are enforced on every matching task:
1. **Never implement unsafe shortcuts.** When a request conflicts with a rule ("keep it simple", "no extra call", "just delete it", "disable verification", "keep floats", "we trust them", "later"), name the broken rule and why it fails in one sentence, refuse the shortcut, and implement the compliant version that still meets the user's goal. Never ship the rule-breaking shortcut.
2. **Ship the complete rule slice, wired up.** Implement every requirement of the triggered rules in this change: storage or schema, validation, error handling, user-facing alerts, status or monitoring wired into an actual entry point, handler or job (not uncalled helpers), and a test file under `tests/`. Do not stop at a minimal patch or leave required safeguards as prose TODOs.
3. **Fix workspace code on audit, incident and review prompts.** When the request describes a discrepancy, an auditor question, a bug report or asks "is this enough?" against files in the workspace, answer the question in full and implement the compliant code and tests in the same change. Stay read-only only when explicitly asked for a report only.
4. **Build directly on greenfield prompts.** If the workspace has no application files or live connections yet, write a self-contained implementation under `src/` and tests under `tests/` instead of stopping to ask for repository paths or credentials.
5. **Write tests even without a shell.** If the environment cannot run tests or databases, still write the full test file under `tests/` and say in one line that tests are unrun. Never omit tests or skip implementation because tools are unavailable.
## When to use
- A new or changed integration that writes to or reads from an accounting system.
- A customer reports duplicates, missing entries or wrong accounts in their books.
- An accountant's change in the accounting system was overwritten by the sync.
- Connections expire, rate limits trip or a nightly job silently stops.
## Rules
1. **Your ledger is the source of truth; their books are a projection with their own chart.**
Account mapping is an explicit table per tenant: your account or category to their account
id, with who set it and when. Nothing posts to a guessed account. Unmapped activity queues
for the customer to map, with a visible count.
2. **Post summaries, not every event, unless the customer needs the detail.** A daily journal
entry per mapped account pair (sales, fees, refunds, payouts) keeps their books readable and
your API usage small. Offer line-level detail as an option, not the default.
3. **Every object you push carries your id, and you store theirs.** Put your reference in the
document number, memo or a custom field; store their id and version token (QuickBooks
Online uses `SyncToken` and rejects a stale one with error 5010; others use ETags or updated
timestamps). A re-push looks up the pair
and updates or no-ops. There is no code path that creates without first checking the pair.
4. **Use the vendor's idempotency and batch features.** QuickBooks Online accepts a `requestid`
query parameter (unique per company, up to 50 characters, 36 in batch) and returns the original
response on a repeat; other APIs have an equivalent. Use it on every create, and the batch
endpoint for several operations. Respect the
documented rate limits per company or tenant, with backoff and a queue, not a sleep.
5. **Closed periods are theirs to close.** When the accounting system refuses a posting
because the period is closed, do not retry; post the amount in the first open period with a
note that names the original date, and surface it to the customer.
6. **Detect their edits before you write.** Read changes since the last sync (change data
capture or modified-since queries) and compare with what you last wrote. Apply a named
conflict policy per object type: ours wins, theirs wins, or flag for review. Never overwrite
silently. Store a conflict record with both versions.
7. **Tokens rotate; persist the new one atomically.** OAuth access tokens are short-lived and
refresh tokens can change on every refresh. Save the returned refresh token in the same
transaction that marks the refresh done. Refresh-token lifetimes are policy, and the policy changes
(QuickBooks Online moved from about 100 days to a longer validity for the accounting scope in
late 2025): store the expiry from each token response (`x_refresh_token_expires_in`) and alert
the customer before that date. Show the connection status in the product.
8. **Amounts and tax codes convert at the edge.** Accounting APIs take major units with the
currency's decimals; convert from minor units at the boundary. Tax codes, classes, locations
and customers are mapped entities with a creation policy per tenant (create missing, map to
a default, or queue).
9. **Never hard delete; void or reverse, and mirror it.** A deleted document in your product
becomes a void or a reversing entry in theirs, linked to the original. The same in the other
direction.
10. **A drift report runs daily.** For each mapped account, compare your balance for the
period with theirs. Drift above a threshold opens a task with the entries that differ. This
is the test that the integration still works.
## How to apply
1. Read the vendor's API documentation for: idempotency parameter, batch endpoint, version
token, change data capture, closed-period error, rate limits, token lifetimes. For
QuickBooks Online setup, OAuth and sandbox, Intuit's `intuit-developer` plugin
(Apache-2.0) covers the mechanics; use it rather than reimplementing them.
2. Design the mapping tables (accounts, tax codes, entities) and the sync-state table (our id,
their id, version token, last pushed hash, status, error).
3. Implement push as: look up pair, build payload, create or update with the idempotency
parameter, store their id and token, record the hash. Implement pull as: changes since
cursor, compare, apply policy, record conflicts.
4. Wrap token refresh so the new refresh token is persisted before anything else uses it.
5. Write the tests in the **Tests** section against a recorded sandbox (see `money-tests`).
6. Ship the drift report and the connection-status indicator with the first version.
## When the user pushes back
| Request | Answer in one sentence | What you build |
|---|---|---|
| "Keep it simple, map to the account named 'Sales'" | Rule 1: account names change across tenants and renames break the sync | Per-tenant mapping table keyed by remote account id, one-time setup suggestion confirmed by the customer, unmapped activity queued instead of guessed, and a test where a renamed remote account keeps syncing |
| "Delete the invoice in QuickBooks when deleted here" | Rule 9: hard deletes destroy accounting history | Void or reversing entry linked to the original on both sides, recording who triggered it and why |
| "Just fix the token refresh or closed-period retry" | Rules 5 and 7: silent logs hide broken syncs from customers | Atomic refresh-token persistence, expiry alert and connection status wired into the sync/status path, or open-period posting that surfaces moved entries to the customer |
## Tests the change must include
Write these tests in the same change, as a test file, even when you cannot run them (no shell,
no dependencies installed); say in one line that they are unrun. A test listed as a next step is
not written.
- Pushing the same day's summary twice creates one journal entry and updates it on change.
- A stale version token produces a conflict record, not an overwrite.
- A remote recategorization is preserved or flagged according to the policy, with a test per
policy value.
- A closed-period error posts in the open period with the original date in the memo.
- Token refresh persists the new refresh token even if the following API call fails.
- A deleted invoice results in a void linked to the original on both sides.
- The drift report flags a planted one-cent difference.
- Reference vectors: `skills/accounting-sync/evals/vectors/test_sync.py` with `SYNC_SOLUTION`
pointing at your module (idempotent push, conflicts, closed period, token rotation, drift).
## Review checklist
- Where is the account mapping, and what happens to unmapped activity?
- Can any code path create a remote object without checking the pair first?
- Which conflict policy applies to each object type, and where are conflicts stored?
- What does the job do on a closed-period error? On a rate-limit error?
- Where is the refresh token persisted, and in which transaction?
- Where is the drift report, and who gets the task?
## Anti-patterns and fixes
| Anti-pattern | What goes wrong | Fix |
|---|---|---|
| Hardcoded account names ("Sales") | Breaks on renamed or localized charts | Mapping table by id per tenant |
| Create on every run | Duplicate entries | Pair lookup, idempotency parameter, stored ids |
| Retry a closed-period error | Infinite failures | Post in the open period with a note |
| Overwrite on push | Accountant's work lost | Change detection and conflict policy |
| Refresh token saved after the next call | Token lost on a crash, customer reconnects | Persist first, atomically |
| Delete to mirror a delete | Books lose history | Void or reverse, linked |
## References
- QuickBooks Online API: `SyncToken`, request ids for idempotent operations, batch, change data capture, closed-period handling, token lifetimes.
- Xero API: `If-Modified-Since`, rate limits, void and status transitions.
- Intuit's official plugins (`intuit-developer`, `quickbooks-labs`) for setup, OAuth and end-user bookkeeping workflows.
Files in this skill
- SKILL.md
- evals/evals.json
- evals/files/qbo_sync.py
- evals/files/token_refresh.py
- evals/files/xero_push.py
- evals/vectors/reference.py
- evals/vectors/test_sync.py
Attribution
Related skills
View all in ai-agents →Comments
Loading comments…
Newsletter
Get the weekly list of safe new skills, and the ones we pulled.