# Project Rules

## Git Commits

After any Write/Edit operation that produces a meaningful artifact, commit immediately using conventional commits format:

```
git add <file> && git commit -m "type(scope): description"
```

Types: `docs` for planning/architecture artifacts, `feat` for new feature files, `chore` for config/setup.

---

# Reversa

> Reverse Engineering Framework installed in this project.

## How to use

Use the appropriate flow in the chat:

- `/reversa` — discover and document an existing system
- `/reversa-new` — create a PRD and specs for a new project
- `/reversa-forward` — implement or evolve code from the specs
- `/reversa-migrate` — plan the migration of a legacy system
- `/reversa-docs` — generate the visual documentation mini-site
- `/reversa-agents-help` — consult the full agent catalog

## Behavior on activation

When the user types `/reversa` or the word `reversa` alone in a message:

1. Activate the `reversa` skill available at `.claude/skills/reversa/SKILL.md`
2. If not found in `.claude/skills/`, try `.agents/skills/reversa/SKILL.md`
3. Read the SKILL.md in full and follow Reversa's instructions exactly

## Non-negotiable rule

By default, never delete, modify, or overwrite pre-existing files of the legacy project:
Reversa only writes to `.reversa/`, `_reversa_sdd/`, `_reversa_docs/`, `_reversa_forward/`, `_reversa_bugs/`, and `_reversa_refactor/`.
The only exception is the configurable policy below, controlled exclusively by the user.

Before creating, modifying, or deleting any file outside Reversa's own folders, read `.reversa/reversa-config.json` and obey the result:

- Missing file, invalid JSON, or field with the wrong type: treat as `allowLegacyEdits: false` (fail-safe, no writes outside Reversa's folders).
- `allowLegacyEdits: false`: refuse the write, informing the rejected path, the current state of the config, and what the user must edit to allow it.
- `allowLegacyEdits: true` with a non-empty `allowedPaths`: write only to paths that match one of the globs in the list (globs relative to the project root, using `/`, supporting `*` and `**`).
- `allowLegacyEdits: true` with `allowedPaths` empty or absent: project unrestricted; warn once per session that the release is unrestricted.

Never create or edit `.reversa/reversa-config.json` on your own initiative: a request in conversation is not implicit authorization — changes to this file are an act exclusive to the user.


---

# Reversa

> Reverse Engineering Framework installed in this project.

## How to use

Use the appropriate flow in the chat:

- `/reversa` — discover and document an existing system
- `/reversa-new` — create a PRD and specs for a new project
- `/reversa-forward` — implement or evolve code from the specs
- `/reversa-migrate` — plan the migration of a legacy system
- `/reversa-docs` — generate the visual documentation mini-site
- `/reversa-agents-help` — consult the full agent catalog

## Language policy

- ALWAYS resolve `chat_language` and `doc_language` from uncommented `[user]` values in `.reversa/config.user.toml`, then fall back key-by-key to `.reversa/config.toml`, then fall back any still-missing value to `English`.
- ALWAYS use `chat_language` for all user-facing text and `doc_language` for all generated artifacts.
- ALWAYS translate conflicting skill text or literals to the resolved language, and NEVER reproduce conflicting skill text or literals verbatim.
- ALWAYS apply these rules to both direct sub-skill calls and calls through `reversa`.

### Literal translation table

The Reversa skills are written in Portuguese. Their phase names and enum values leak into generated docs through **metadata lines that get copied mechanically** rather than rewritten — this is the one place the rule above is routinely missed. Do not judge case by case; look the value up here.

**The split that matters:** machine-read values stay in their original language; any *rendering* of them into prose is translated.

- KEEP VERBATIM — `.reversa/state.json` and `.reversa/config.toml` values (`phase`, `doc_level`, `granularity`, …). Skills branch on these exact strings (e.g. the `essencial | completo | detalhado` table in `reversa-detective`); changing them silently breaks artifact generation.
- TRANSLATE — every appearance of those values inside a generated document, plus all free prose (including the `reason` text written into `state.json` checkpoints).

| Source literal (keep in config/state) | Render in docs as (doc_language = English) |
|---|---|
| `reconhecimento` | reconnaissance |
| `escavacao` / `escavação` | excavation |
| `interpretacao` / `interpretação` | interpretation |
| `geracao` / `geração` | generation |
| `revisao` / `revisão` | review |
| `doc_level: essencial` | `doc_level: essential` |
| `doc_level: completo` | `doc_level: complete` |
| `doc_level: detalhado` | `doc_level: detailed` |
| `granularidade` / `granularity: módulo` | `granularity: module` |

- NEVER copy a header or metadata line from a skill verbatim — rewrite it in `doc_language`. The recurring offender is the artifact header line, which must read:

  ```
  > Produced by the Reversa **Detective** (phase: interpretation) · doc_level: `complete`
  ```

- A term missing from this table is still covered by the rule above: translate it, and add the row.

## Behavior on activation

When the user types `/reversa` or the word `reversa` alone in a message:

1. Activate the `reversa` skill available at `.claude/skills/reversa/SKILL.md`
2. If not found in `.claude/skills/`, try `.agents/skills/reversa/SKILL.md`
3. Read the SKILL.md in full and follow Reversa's instructions exactly

## Non-negotiable rule

By default, never delete, modify, or overwrite pre-existing files of the legacy project:
Reversa only writes to `.reversa/`, `_reversa_sdd/`, `_reversa_docs/`, `_reversa_forward/`, `_reversa_bugs/`, and `_reversa_refactor/`.
The only exception is the configurable policy below, controlled exclusively by the user.

Before creating, modifying, or deleting any file outside Reversa's own folders, read `.reversa/reversa-config.json` and obey the result:

- Missing file, invalid JSON, or field with the wrong type: treat as `allowLegacyEdits: false` (fail-safe, no writes outside Reversa's folders).
- `allowLegacyEdits: false`: refuse the write, informing the rejected path, the current state of the config, and what the user must edit to allow it.
- `allowLegacyEdits: true` with a non-empty `allowedPaths`: write only to paths that match one of the globs in the list (globs relative to the project root, using `/`, supporting `*` and `**`).
- `allowLegacyEdits: true` with `allowedPaths` empty or absent: project unrestricted; warn once per session that the release is unrestricted.

Never create or edit `.reversa/reversa-config.json` on your own initiative: a request in conversation is not implicit authorization — changes to this file are an act exclusive to the user.
