# Before load listener

> Before load listener is an open-source agent skill for developer tools. Adds dynamic search filters to Sankhya entity finders before the query runs. It is available on Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf, Goose
- **Website:** https://github.com/snk-devcenter/addon-studio/tree/main/plugins/addon-studio/skills/before-load-listener
- **Repository:** https://github.com/snk-devcenter/addon-studio
- **GitHub stars:** 7
- **License:** MIT
- **Skill name:** before-load-listener
- **Collection:** https://github.com/snk-devcenter/addon-studio
- **Categories:** [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-12-04

## About

This skill guides an agent through creating, reviewing and standardizing a FinderListener annotated with @BeforeLoadListener in a Sankhya Addon Studio 2.0 project. The listener intercepts every read or load of one entity through JAPE and can append criteria to the WHERE clause, such as a per-user or multi-tenant restriction applied transversally rather than in each query. The skill covers the rules for composing the clause without overwriting existing filters, the required this. prefix on fields, and keeping the beforeExecute method lightweight because it runs on every search.

It also explains how this annotation differs from @Listener, which handles insert, update and delete events, and from @Criteria, which applies to a single repository query. The guidance points out that the target entity must be declared in the data dictionary, either through XML or a JapeEntity annotation, and that the listener only works on the add-on's own instances, not native system entities. A checklist and anti-pattern table help with reviews, including the rule of one listener per entity and the transaction type to check on services called from the listener.

The content is written in Portuguese and targets Java 8, Gradle, Wildfly/EJB, Guice injection and the JAPE SDK.

## When your agent uses it

> Cria, revisa e padroniza interceptadores de busca Sankhya com `@BeforeLoadListener` (interface `FinderListener` + método `beforeExecute`) — injeta filtros/critérios dinâmicos no Finder JAPE antes da query chegar ao banco. Use ao criar, alterar, revisar, auditar ou padronizar interceptação de buscas/carregamento de entidades, ao implementar `beforeExecute`, ao aplicar filtro de segurança/multi-tenant transversal a uma entidade (só trazer os registros da empresa do usuário logado, sem depender de quem chama e sem repetir o filtro em cada consulta), ao trabalhar com classes `*FinderListener`, ou ao tocar em código com `@BeforeLoadListener`/`FinderListener`. NÃO usar para reagir a gravação/exclusão (eventos CRUD insert/update/delete, `PersistenceEventAdapter`) — isso é `@Listener`, skill `listener`.

## 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/before-load-listener)
- [License: MIT](https://github.com/snk-devcenter/addon-studio/tree/HEAD/plugins/addon-studio/skills/before-load-listener)

## Features

- **Search interception setup:** Explains how to annotate a FinderListener so it runs before every search on one add-on entity.
- **Safe WHERE clause composition:** Shows how to append criteria to the existing clause so earlier filters are not discarded.
- **Per-user filtering:** Demonstrates restricting results to the logged-in user's records using the session context.
- **Dictionary and scope checks:** Lists the prerequisites: entity declared in the data dictionary and limited to add-on instances.
- **Performance guidance:** Advises keeping the method lightweight and caching stable configuration since it runs on every search.
- **Review checklist:** Provides a step-by-step checklist and anti-pattern table for new or reviewed listeners.

## Good for

- Restrict search results of a custom entity to the records of the logged-in user's company
- Add a soft-delete or active-status filter to every query on an add-on entity
- Review an existing FinderListener for clause handling and naming mistakes
- Create a new before-load listener that injects a service through Guice

## 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/before-load-listener`:

```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/before-load-listener &&
cp -R "$tmp/plugins/addon-studio/skills/before-load-listener" ~/.claude/skills/before-load-listener &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/before-load-listener` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/before-load-listener` 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/before-load-listener &&
cp -R "$tmp/plugins/addon-studio/skills/before-load-listener" ~/.agents/skills/before-load-listener &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/before-load-listener` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/before-load-listener` 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/before-load-listener &&
cp -R "$tmp/plugins/addon-studio/skills/before-load-listener" ~/.cursor/skills/before-load-listener &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/before-load-listener` 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/before-load-listener
```

Or copy the folder to `~/.gemini/skills/before-load-listener` yourself.

### VS Code

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

```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/before-load-listener &&
cp -R "$tmp/plugins/addon-studio/skills/before-load-listener" ~/.copilot/skills/before-load-listener &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/before-load-listener` 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/before-load-listener` into your agent's skills folder as `before-load-listener`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Can this be used on native Sankhya entities like Parceiro or Produto?

No. The skill states that the listener may only intercept instances created by the add-on itself, not native system instances.

### Should I use this for validating records on save or delete?

No. The skill directs save and delete reactions to the separate listener skill, since this annotation only intercepts reads.

### Why must the new filter be appended instead of set directly?

Because setWhere replaces the entire WHERE clause, so the skill recommends combining the existing clause from getWhere with the new criterion using AND.

### What does the instance attribute refer to?

It is the logical entity name from the JapeEntity annotation or the XML instance name, not the database table name.

### How do I install Before load listener in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/before-load-listener to use it in all your projects, or to .claude/skills/before-load-listener 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 Before load listener 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 Before load listener?

Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, Windsurf and Goose. Each reads skills in the SKILL.md format from its own folder; the install steps on this page list them.

### What are the best alternatives to Before load listener?

The closest alternatives to Before load listener are Listener, Entity, Repository, Test and Callback.

## Where this comes from

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

## Alternatives

- [Listener](https://ai-powered.com/skills/listener): Listener is an open-source agent skill for developer tools.
- [Entity](https://ai-powered.com/skills/entity): Entity is an open-source agent skill for developer tools.
- [Repository](https://ai-powered.com/skills/repository): Repository is an open-source agent skill for developer tools.
- [Test](https://ai-powered.com/skills/test-snk-devcenter): Test is an open-source agent skill for developer tools.
- [Callback](https://ai-powered.com/skills/callback): Callback is an open-source agent skill for developer tools.
- [Sankhya utils](https://ai-powered.com/skills/sankhya-utils): Sankhya utils is an open-source agent skill for developer tools.
- [Jsp](https://ai-powered.com/skills/jsp): Jsp is an open-source agent skill for developer tools.
- [Job](https://ai-powered.com/skills/job): Job is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/before-load-listener
