Metadata-Version: 2.4
Name: robotframework-lint-lsp
Version: 1.3.3
Summary: Robot Framework lint for coding agents: robocop rules, an LSP server and an auto-fix hook
Author: Abdulwahab Isam
License-Expression: MIT
Project-URL: Homepage, https://github.com/ai94iq/robotframework-lint-lsp
Project-URL: Documentation, https://github.com/ai94iq/robotframework-lint-lsp/blob/main/docs/agents.md
Project-URL: Issues, https://github.com/ai94iq/robotframework-lint-lsp/issues
Keywords: robotframework,robocop,lint,lsp,claude-code
Classifier: Development Status :: 5 - Production/Stable
Classifier: Framework :: Robot Framework
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: robotframework==7.5.1
Requires-Dist: robotframework-robocop==9.4.0
Requires-Dist: pygls==2.1.1
Provides-Extra: dev
Requires-Dist: hypothesis==6.170.17; extra == "dev"
Requires-Dist: pytest==9.2.0; extra == "dev"
Dynamic: license-file

# robotframework-lint-lsp

Robot Framework lint for coding agents, built and tested as a Claude Code
plugin. The agent edits a `.robot` file. Safe fixes are applied right after
the edit. Only the findings left come back to the agent, one short line each.

[![PyPI](https://img.shields.io/pypi/v/robotframework-lint-lsp)](https://pypi.org/project/robotframework-lint-lsp/)
[![Python](https://img.shields.io/pypi/pyversions/robotframework-lint-lsp)](https://pypi.org/project/robotframework-lint-lsp/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue)](LICENSE)

- Language server (`robotframework-lint-lsp`): robocop findings plus the
  RFL rules below, sent after every edit. It also gives definition,
  references, hover and workspace symbols for your own keywords.
- Auto-fix hook (`robotframework-lint-autofix`): after each Edit or Write,
  it applies robocop's safe fixes. These cover DEPR03 to DEPR11, MISC04,
  MISC09, VAR01 and RFL001, for example `Set Test Variable` to `VAR`. The
  agent spends no turns on them. After an Edit, the hook fixes only the
  lines the edit wrote, so untouched lines stay out of the diff. After a
  Write, it fixes the whole file.
- Rule pack: seven rules that robocop 9.4.0 does not check, each from a
  Robot Framework release note or the User Guide (see Rules below).

The PyPI package and the plugin are named `robotframework-lint-lsp`. The
Python module is `robotframework_lint`.

## Contents

- [Does it help?](#does-it-help)
- [Install](#install)
- [If you are an agent installing this](#if-you-are-an-agent-installing-this)
- [What the agent gets](#what-the-agent-gets)
- [Settings](#settings)
- [Rules](#rules)
- [Other agents and editors](#other-agents-and-editors)
- [Development](#development)
- [License](#license)

## Does it help?

Measured on one task (write two suites with keywords, then run them):
robocop 9.4.0 default findings left in the final files, and cost per run.
Three runs per arm at medium effort, so read these as direction:

| Model | No lint | robocop MCP | This plugin | Cost against no lint |
|---|---|---|---|---|
| Haiku | 17.3 | 13.7 | 4.7 | +10% ($0.030 to $0.033) |
| Sonnet | 12.0 | 2.7 | 2.0 | +9% ($0.171 to $0.186) |
| Opus | 11.0 | 0 | 0 | +57% ($0.251 to $0.395) |

The plugin leaves the same or fewer findings than the robocop MCP and costs
less than it on all three models. A larger Haiku run used 25 runs per arm
at default effort. It left 18.5 findings with no lint, 13.2 with the MCP
and 4.7 with the plugin. There the plugin cost 21% more than no lint. These runs used plugin commit c84eb65
with up to 20 findings per file. Every run, version and chart:
[benchmarks](https://ai94iq.github.io/robotframework-lint-lsp/benchmarks.html)
([source](docs/benchmarks)).

## Install

Needs Python 3.10 or later, [uv](https://docs.astral.sh/uv/) (or pipx) and
Claude Code 2.1.275 or later. It lints projects on Robot Framework 7.x: the
hook writes `VAR`, which needs RF 7.0, and RFL002 to RFL006 report RF 7.5
deprecations.

Each step has the result to expect.

1. Install the server commands:

   ```bash
   uv tool install robotframework-lint-lsp==1.3.3
   ```

   Or: `pipx install robotframework-lint-lsp==1.3.3`.

   Expected: exit code 0, and the output names `robotframework-lint-lsp` and
   `robotframework-lint-autofix`. The tool has its own environment, separate
   from your project's robotframework, and pins robotframework 7.5.1,
   robotframework-robocop 9.4.0 and pygls 2.1.1.

2. Check that the server command is on PATH:

   ```bash
   which robotframework-lint-lsp      # Windows: where robotframework-lint-lsp
   ```

   Expected: one path. If nothing prints, add the folder that
   `uv tool dir --bin` prints to PATH (pipx: `pipx ensurepath`) and open a
   new terminal. The plugin runs the bare command, so it
   fails without this.

3. Add the marketplace and install the plugin:

   ```bash
   claude plugin marketplace add ai94iq/robotframework-lint-lsp
   claude plugin install robotframework-lint-lsp@robotframework-lint-lsp --scope user
   claude plugin list
   ```

   Expected: a row for `robotframework-lint-lsp` with `Status: enabled`. If
   the marketplace is already added, continue.

4. Reload the plugins: run `/reload-plugins` in Claude Code, or restart it.

5. Check both parts. Under a test case in any `.robot` file, add:

   ```robotframework
       Set Test Variable    ${x}    1
   ```

   Expected: the hook rewrites the line to `VAR    ${x}    1    scope=TEST`.
   Then add `Library    Telnet` to the file's `*** Settings ***` section.
   Expected: the edit result or the next tool result has
   `RFL002 Telnet is deprecated since RF 7.5; use TelnetLibrary`.
   Diagnostics are pushed, so they can arrive one tool result late, and a
   finding already delivered is not shown again. If the line is not
   rewritten, the hook is not running. If no `RFL002` line comes, the
   server is not running. Check step 2, then step 3, then reload again.

   With a debug log, `claude --debug-file debug.log`, both parts show in
   `grep -E "LSP Diagnostics: Delivering|robotframework-lint-autofix" debug.log`.

## If you are an agent installing this

Follow the Install steps in order. If a result does not match the expected
one, stop and report the output to the user. Do not change the user's PATH
or shell profile without their approval. In step 2, ask the user to add the
folder. An agent cannot run `/reload-plugins`: in step 4, ask the user to
reload and wait for their confirmation before step 5.

## What the agent gets

| Feature | Behaviour |
|---|---|
| Diagnostics | On open, save and change (debounced 0.4 s). One line per finding, `RULEID message`, at most 120 characters. By default, warnings and errors only, and at most 9 per file, then one line saying how many more were cut. Claude Code shows the first 10 diagnostics of a file, so the default leaves room for that line. |
| Fix hints | A finding from a rule the hook fixes (DEPR03 to DEPR11, MISC04, MISC09, VAR01, RFL001) ends with `fix all: <command>`. The hint is for lines the agent did not edit. Info rules on that list are raised to Warning so the agent sees them. |
| Auto-fix | The PostToolUse hook runs robocop's safe fixes on a temp copy of the edited file. It keeps your line endings and applies the fixes only to the lines an Edit wrote. If the file changed while robocop ran, it writes nothing. |
| Navigation | Definition and references matched the way Robot matches names (`say_hello` finds `Say Hello`); hover shows the signature and first doc line; workspace symbols rank exact, then prefix, then substring. At most 50 results. The server builds the keyword index in the background on start. Its limits are in [docs/agents.md](docs/agents.md#configuration-details). |

When a file has more findings than the limit, findings on lines changed
since git HEAD come first. A finding on an unchanged line reads
`RULEID (old) message`. The full order is in
[docs/agents.md](docs/agents.md#configuration-details).

## Settings

The plugin passes these in `initializationOptions` of its `.lsp.json`, in
the plugin folder:
`~/.claude/plugins/cache/robotframework-lint-lsp/robotframework-lint-lsp/<version>/.lsp.json`.
A plugin update installs a new version folder, so edits there are lost.
To choose rules, use your project's robocop config instead (below).

| Option | Default | Meaning |
|---|---|---|
| `maxDiagnostics` | 9 | Findings per file before the overflow line |
| `minSeverity` | `warning` | `info`, `warning` or `error` |
| `select` | all rules | Report only these rule IDs |
| `ignore` | none | Rule IDs to drop |
| `robotcodeCommand` | unset | Command list for `robotcode` in a project venv; see below |

The project's own `robocop.toml`, or `[tool.robocop.lint]` in
`pyproject.toml`, narrows the rules for its files through `select` and
`ignore`. How it combines with the options above is in
[docs/agents.md](docs/agents.md#configuration-details).

`robotcodeCommand`, for example `["D:/proj/.venv/Scripts/robotcode"]`,
adds on save up to 5 errors robocop cannot see: unresolved keywords,
variables and imports. Without it, a call to a keyword that does not exist
is not reported, because robocop does not resolve keywords. robotcode runs
on the saved file in your workspace, not a temp copy, and imports your
project's libraries. In the plugin's `.lsp.json`, it applies to every
workspace you open. Set it only while you work on one project whose code
you trust. A venv without that project's libraries reports false
import errors.

## Rules

| ID | Name | What it reports | Source |
|---|---|---|---|
| RFL001 | for-in-zip-without-mode | `FOR ... IN ZIP` without `mode`. The hook adds `mode=SHORTEST`, which keeps the current behaviour | [RF 7.0](https://github.com/robotframework/robotframework/blob/v7.0/doc/releasenotes/rf-7.0.rst) |
| RFL002 | deprecated-standard-library | `Library    Telnet` | [RF 7.5](https://github.com/robotframework/robotframework/blob/v7.5.1/doc/releasenotes/rf-7.5.rst) |
| RFL003 | deprecated-tag-pattern | `XORY` and `&` in tag patterns | [RF 7.5](https://github.com/robotframework/robotframework/blob/v7.5.1/doc/releasenotes/rf-7.5.rst) |
| RFL004 | deprecated-translation | French `Unités de test`, Finnish `Tagit` | [RF 7.5](https://github.com/robotframework/robotframework/blob/v7.5.1/doc/releasenotes/rf-7.5.rst) |
| RFL005 | doc-tags-without-empty-row | `Tags:` in keyword docs | [RF 7.5](https://github.com/robotframework/robotframework/blob/v7.5.1/doc/releasenotes/rf-7.5.rst) |
| RFL006 | deprecated-argument-name | `list_=`, `time_=` | [RF 7.5](https://github.com/robotframework/robotframework/blob/v7.5.1/doc/releasenotes/rf-7.5.rst) |
| RFL007 | local-shadows-suite-variable | `${contract}=` that hides `${CONTRACT}` from the same file's Variables section; imported resources are not checked | [User Guide, Variables](https://github.com/robotframework/robotframework/blob/v7.5.1/doc/userguide/src/CreatingTestData/Variables.rst) |

RFL007 is an error by this tool's choice, not by the User Guide. The guide
recommends capitals for non-local variables and lowercase for local ones.
Variable names are case-insensitive, so the local assignment replaces the
suite value. The guide does not forbid this.

RFL003 uses Robot Framework's own `TagPatterns`. It flags the same
patterns RF 7.5.1 warns about. This includes all-caps tags such as
`-DONOTX`, which RF reads as `DO NOT X`. RFL004 reports a term only when RF parsed it
as a header or setting, that is, in a French or Finnish file.

To lint from the command line, with the RFL rules:

```bash
uv tool run --from robotframework-lint-lsp==1.3.3 robocop check --custom-rules robotframework_lint path/to/tests
```

`robocop list rules` has no `--custom-rules` flag. To list the RFL rules,
put `custom_rules = ["robotframework_lint"]` under `[tool.robocop.lint]`
in a config file and run `robocop list rules --config <file>`.

## Other agents and editors

[docs/agents.md](docs/agents.md) gives the setup for opencode, Crush,
Codex and any LSP client. It also covers the GLM coding plan, a model plan
that runs inside those tools, and how to call the hook from other hook
systems. Only Claude Code is tested end to end. That page gives the status
of each other setup.

## Development

```bash
# Windows: use .venv/Scripts/python in both commands
python -m venv .venv
.venv/bin/python -m pip install -e ".[dev]"
.venv/bin/python -m pytest
```

Releases publish to PyPI from a GitHub release through trusted publishing
(`.github/workflows/release.yml`).

## License

MIT
