Skip to content
Skill

Business rule

Guides writing Sankhya commercial business rules with @BusinessRule for sales documents

Business rule is an open-source agent skill for enterprise it. It is available on Claude Code.

Scripts
None
Platforms
Claude Code
GitHub stars
7
Last commit
License
MIT
Listing updated

Similar skills

About Business rule

This skill helps an agent create, review and refactor @BusinessRule classes for the Sankhya Addon Studio 2.0 commercial module, covering sales and transfer documents such as orders, invoices and credit-limit release. It explains which hook to pick, how the Regra interface and ContextoRegra API work, and how to detect the moment a document is confirmed by comparing old and new states or reading a session property.

The guidance includes three worked examples: requesting a credit or discount release through the rules bus, adding a note only on confirmation, and sending data to an external system after the transaction commits. It also flags common pitfalls, such as calling external services inside the transaction, using REQUIRES_NEW transactions in services, and placing validation in afterInsert.

The skill is written in Portuguese and targets Java 8, Gradle and Wildfly/EJB projects using the JAPE SDK with Guice injection. It points to companion skills for callbacks on purchase invoices, listeners for plain CRUD events, and dependency injection, testing and entities.

When your agent uses it

Cria, revisa e refatora regras de negócio Sankhya com `@BusinessRule` (interface `Regra` + `ContextoRegra`) para barramento de eventos do módulo comercial, liberação de limite e regras transacionais. Use ao criar, alterar, revisar, auditar ou padronizar regras de negócio do comercial (nota, pedido, fatura, limite de crédito), ao implementar `beforeInsert`/`beforeUpdate`/`beforeDelete`/`afterInsert`/`afterUpdate`/`afterDelete` de `Regra`, ao trabalhar com arquivos `*Regra.java`, ou ao tocar em código com `@BusinessRule`. NÃO usar quando o documento é Nota de Entrada (compra) ou quando o gancho é o ponto de confirmação em si, na Central ou no Portal de Vendas — isso é `@Callback`/`ICustomCallBack`, skill `callback`. NÃO usar para evento de persistência de qualquer tabela — documento nativo (pedido, nota) ou tabela `AD_` do próprio addon — fora do barramento: validar/preencher campo no insert, auditoria de alteração (quem mudou e quando), mudança de status, bloquear exclusão — isso é `@Listener`/`PersistenceEven

From the skill's SKILL.md. Your agent reads this description to decide when to load the skill.

What it can access

From a static check of its 1 file (17 KB) on GitHub on 4 December 2026. Nothing was run. Read the files before you install a skill: it can tell your agent to run anything its tools allow.

Check another skill before you install it.

Install

This skill ships in the addon-studio plugin. In Claude Code, add the marketplace and install the plugin (it may include other skills too):

/plugin marketplace add snk-devcenter/addon-studio
/plugin install addon-studio@snk-devcenter

Or copy only this skill to ~/.claude/skills/business-rule:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/business-rule &&
cp -R "$tmp/plugins/addon-studio/skills/business-rule" ~/.claude/skills/business-rule &&
rm -rf "$tmp"

For one project only, put the folder in .claude/skills/business-rule inside it instead.

Claude Code docs on skills

Copy the skill folder to ~/.agents/skills/business-rule to use it in every repository:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/business-rule &&
cp -R "$tmp/plugins/addon-studio/skills/business-rule" ~/.agents/skills/business-rule &&
rm -rf "$tmp"

For one repository only, put the folder in .agents/skills/business-rule inside it instead.

Codex docs on skills

Copy the skill folder to ~/.cursor/skills/business-rule to use it in every project:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/business-rule &&
cp -R "$tmp/plugins/addon-studio/skills/business-rule" ~/.cursor/skills/business-rule &&
rm -rf "$tmp"

For one project only, put the folder in .cursor/skills/business-rule inside it instead.

Cursor docs on skills

Run in a terminal (add --scope workspace to install it for the current workspace only):

gemini skills install https://github.com/snk-devcenter/addon-studio.git --path plugins/addon-studio/skills/business-rule

Or copy the folder to ~/.gemini/skills/business-rule yourself.

Gemini CLI docs on skills

For GitHub Copilot in VS Code, copy the skill folder to ~/.copilot/skills/business-rule:

tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/business-rule &&
cp -R "$tmp/plugins/addon-studio/skills/business-rule" ~/.copilot/skills/business-rule &&
rm -rf "$tmp"

For one project only, put the folder in .github/skills/business-rule inside it instead.

VS Code docs on skills

Get the folder:

git clone --depth 1 https://github.com/snk-devcenter/addon-studio.git

Then copy addon-studio/plugins/addon-studio/skills/business-rule into your agent's skills folder as business-rule. Agents that support SKILL.md read one folder per skill.

The SKILL.md format

What it does

Hook selection guidance
Explains when a business rule fits better than a callback or a listener for a given commercial event.
Regra interface reference
Lists the six lifecycle methods of the Regra interface and when each one fires.
ContextoRegra usage
Shows how to read old and new document state, write fields, add messages and raise liberation requests.
Confirmation detection
Demonstrates detecting the confirmation moment from the CONFIRMADA field change or a session property.
Post-commit integration
Describes running external calls only after the transaction commits to avoid partial sends on rollback.
Review checklist
Provides a step-by-step checklist for building a new business rule with dependency injection.

Good for

  • Create a rule that requests approval when a sales order discount exceeds a set percentage
  • Review an existing business rule for transaction propagation mistakes
  • Add a confirmation-only note to an invoice when it is confirmed
  • Send an invoice to an external system after its confirmation commits
  • Refactor a credit-limit check into a clean rule class delegating to a service

Business rule FAQ

When should I use @BusinessRule instead of @Callback?

Use @BusinessRule for outgoing sales and internal movement documents when logic needs the rules bus, such as limit releases or complex checks at confirmation or billing. Purchase invoices and the confirmation point itself in the Central or Sales Portal belong to @Callback.

Which methods does a Regra class have to implement?

The Regra interface declares six abstract methods without defaults: beforeInsert, afterInsert, beforeUpdate, afterUpdate, beforeDelete and afterDelete. Classes must declare all six, leaving empty bodies for the ones they do not use.

How does the rule know the document is being confirmed?

It compares the CONFIRMADA field between the old and new state, or reads the JapeSession property CabecalhoNota.confirmando.nota, as shown in the examples.

What should I avoid doing inside a rule?

Avoid synchronous HTTP or web service calls and executor services in the rule, since they run before the commit. Use AfterCommit or a queue table with a job instead.

How do I install Business rule in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/business-rule to use it in all your projects, or to .claude/skills/business-rule in one project. Or install the addon-studio plugin, which includes it: /plugin marketplace add snk-devcenter/addon-studio, then /plugin install addon-studio@snk-devcenter.

Does Business rule run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

Which AI agents can use Business rule?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

Where this comes from

  • Description: from the skill's own SKILL.md.

More from snk-devcenter/addon-studio

  1. Adds dynamic search filters to Sankhya entity finders before the query runs

    • Open source
    • 7 GitHub stars
    • Developer tools
  2. Lets agents write, review and refactor Sankhya document callbacks with @Callback hooks

    • Open source
    • 7 GitHub stars
    • Developer tools
  3. Builds and reviews Sankhya REST endpoints with @Controller, DTOs and transactions

    • Open source
    • 7 GitHub stars
    • Developer tools
  4. Sets up global Sankhya exception handlers with rollback, error DTOs and HTTP status

    • Open source
    • 7 GitHub stars
    • Developer tools
  5. Generates Sankhya CRUD screens from table XML in datadictionary/ with no JS or HTML

    • Open source
    • 7 GitHub stars
    • Developer tools
  6. Creates and audits dual MSSQL/Oracle database migration scripts for Sankhya addons

    • Open source
    • 7 GitHub stars
    • Databases