# Business rule

> Business rule is an open-source agent skill for enterprise it. Guides writing Sankhya commercial business rules with @BusinessRule for sales documents. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/snk-devcenter/addon-studio/tree/main/plugins/addon-studio/skills/business-rule
- **Repository:** https://github.com/snk-devcenter/addon-studio
- **GitHub stars:** 7
- **License:** MIT
- **Skill name:** business-rule
- **Collection:** https://github.com/snk-devcenter/addon-studio
- **Categories:** [enterprise it](https://ai-powered.com/categories/enterprise-it)
- **Listing updated:** 2026-12-04

## About

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

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/snk-devcenter/addon-studio/tree/HEAD/plugins/addon-studio/skills/business-rule)
- [License: MIT](https://github.com/snk-devcenter/addon-studio/tree/HEAD/plugins/addon-studio/skills/business-rule)

## Features

- **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

## Install

### Claude Code

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

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

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

```sh
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.

### Codex

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

```sh
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.

### Cursor

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

```sh
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.

### Gemini CLI

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

```sh
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.

### VS Code

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

```sh
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.

### Other agents

Get the folder:

```sh
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.

## 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.

## Alternatives

- [System admin](https://ai-powered.com/skills/system-admin): System admin is an open-source agent skill for enterprise it.

---
Source: https://ai-powered.com/skills/business-rule
