Robot Framework Language
Write and review Robot Framework code in .robot and .resource files: test cases and suites, user keywords, resource files and variables, in modern syntax that fits the project's Robot Framework version.
Python keyword libraries and listeners belong to rf-python-library; library keywords, locators and waits belong to the library skills (rf-browser, rf-requests, …).
Verified against Robot Framework 7.4.2.
When to use
Load this skill first, before opening the .robot and .resource files or answering from memory, when Robot Framework test data is written, changed, reviewed or explained, even if the user just says "tests" or "keywords":
- test cases and suites, user keywords and variables in .resource files, tags, setups and teardowns,
__init__.robotsuite files; - data-driven tests with a Test Template table; Given/When/Then (BDD) scenarios and their step keywords;
[Arguments](optional, typed or embedded); replacing Force Tags,[Return], Run Keyword If or Set Suite Variable with current syntax;- selecting tests by tag on the robot command line;
Multiple keywords with name '...'and import scope between__init__.robotand child suites.
Not this skill: Python keyword libraries or listeners use rf-python-library; library keywords use rf-browser, rf-requests or another library skill. Running, discovering, keyword lookup, result reading and debugging with the robotcode CLI are covered by the robotcode skill of the robotcode plugin.
Version gate
Establish the project's Robot Framework version once, before writing version-dependent syntax. Use rf.effective and rf.features from Step 0, or run this in the project (it exits 0; robot --version prints the version but exits 251):
bashuv run python -c "import robot; print(robot.__version__)"
| Feature | Min RF |
|---|---|
RETURN | 5.0 |
Test Tags, Keyword Tags, robot:private | 6.0 |
--parseinclude, suite Name setting, JSON variable files, embedded + normal arguments in one user keyword | 6.1 |
VAR, [Tags] -tag removal, --test matching the full name from the root suite | 7.0 |
VAR … scope=SUITES, BDD prefix before a leading embedded argument | 7.1 |
GROUP, (?i) in embedded patterns, templated test passes when some rows skip | 7.2 |
Typed user keyword arguments ${count: int}, typed VAR, Variables section and FOR variables | 7.3 |
Secret type | 7.4 |
- Do not use a feature newer than the project's version. On RF 7.1, for example: no
GROUP, no(?i)pattern and no${name: type}in[Arguments],VARor the Variables section. - Native typed arguments only on RF 7.3 or newer. On older versions keep
${count}and convert explicitly (${count}= Convert To Integer ${count}). ${count}: intis invalid on every version.${count: int}on RF < 7.3 passesrobot --dryrunand fails at run time.
Step 0: Match the project
Detect the project's conventions before writing code, and follow them. Use the first of these that works:
- The bundled script, run through the project environment. Script paths are relative to this skill's directory (the folder containing this SKILL.md), not to the project:
bashuv run python "${CLAUDE_SKILL_DIR}/scripts/rf_conventions.py" . uv run python "${CLAUDE_SKILL_DIR}/scripts/rf_conventions.py" tests --max-examples 5 uv run python "${CLAUDE_SKILL_DIR}/scripts/rf_conventions.py" . --json-out results/conventions.json
Project not managed by uv (no uv.lock)? Run it with the project's interpreter: .venv/bin/python "${CLAUDE_SKILL_DIR}/scripts/rf_conventions.py" . or poetry run python "${CLAUDE_SKILL_DIR}/scripts/rf_conventions.py" . (see rf-setup).
- Without Robot Framework for the script, three searches, then read one existing file for the separator width:
bashgrep -rhoE '^(Library|Resource|Variables)\s+\S+' --include='*.robot' --include='*.resource' . | sort | uniq -c grep -rhoE '^\s+(Given|When|Then|And|But) |^Test Template|^\s+\[Template\]' --include='*.robot' --include='*.resource' . | sed -E 's/^\s+//' | sort | uniq -c grep -rhE '^(Test Tags|Force Tags|Default Tags)|^\s+\[Tags\]' --include='*.robot' --include='*.resource' . | sed -E 's/^\s+//' | sort | uniq -c
| Result field | Follow it |
|---|---|
style.separator.dominant, style.assignment.dominant | Same separator width and ${x}= / ${x} = / ${x} style in new code |
style.keyword_case, keywords.embedded, advice follow-embedded-style | Same keyword-name casing; write new keywords of the same kind with embedded arguments |
rf.features.typed_arguments.available | Typed arguments only when true |
libraries.web_library, libraries.imports | Keep the web or API library the project uses |
layout.resource_dir, layout.variable_files | Put new keywords and variable files where the existing ones are |
calls.bdd_steps, tests.template_suites, tests.top_tags | Keep BDD, template and tag vocabulary consistent |
keywords.duplicate_names, legacy | Fix or avoid them; advice names the robocop rules |
Search for an existing keyword before creating one: robotcode doc keywords resources/<file>.resource "<text>" lists what a resource file exports (robotcode discover tests --search "<text>" finds similar tests).
Choose a style
| Situation | Use |
|---|---|
| One workflow per test (set up, act, verify) | Keyword-driven test calling user keywords |
| The same workflow with varying data | Data-driven: Test Template or [Template] with one data row per test |
| Scenarios that stakeholders read | BDD: Given/When/Then calls to prefix-free step keywords with embedded arguments |
| Large or externally maintained data sets | An external data source such as DataDriver, installed via rf-setup |
| Steps repeated across tests | A user keyword in a resource file |
| Logic that needs Python (parsing, protocols, heavy computation) | A Python keyword library: logic goes into Python, composition of existing keywords into a user keyword |
Test skeletons
Keyword-driven (assets/examples/tests/01__keyword_driven.robot):
robotframework*** Settings *** Resource ../resources/calc.resource Test Setup The Calculator Is Cleared *** Test Cases *** Adding Two Numbers [Tags] smoke The User Adds 1 And 2 The Result Should Be 3 Test Without Setup [Setup] NONE No Operation
Data-driven, one test per row, header cells name the columns (assets/examples/tests/02__data_driven.robot):
robotframework*** Settings *** Resource ../resources/login.resource Test Template Login Should Fail *** Test Cases *** USERNAME PASSWORD Invalid User Name invalid mode Invalid Password demo invalid Empty User Name ${EMPTY} mode
BDD, with the step keywords defined without a prefix in calc.resource (assets/examples/tests/04__bdd.robot):
robotframework*** Settings *** Resource ../resources/calc.resource *** Test Cases *** Adding Two Numbers As A Scenario Given The Calculator Is Cleared When The User Adds 2 And 3 Then The Result Should Be 5
Keyword anatomy
Default template, settings in the Robocop ORD02 order ([Documentation], [Tags], [Arguments], [Timeout], [Setup], body, [Teardown]); typed arguments need RF 7.3 (assets/examples/resources/keywords.resource):
robotframework*** Settings *** Library Collections *** Keywords *** Add Items To Cart [Documentation] Adds ``quantity`` items of ``product`` and returns the cart size. [Tags] cart [Arguments] ${cart: list} ${product: str} ${quantity: int}=1 [Timeout] 10 seconds [Setup] Log Adding ${quantity} x ${product} FOR ${_} IN RANGE ${quantity} Append To List ${cart} ${product} END ${total}= Get Length ${cart} RETURN ${total} [Teardown] Log Cart has ${total} items
On RF < 7.3 the same keyword takes [Arguments] ${cart} ${product} ${quantity}=1 and converts with Convert To Integer. Name keywords as Title Case sentences without underscores (Add Items To Cart), unless rf_conventions reports another dominant style.
| Need | Write |
|---|---|
| Required value | ${product} |
| Optional value | ${quantity}=1, ${note}=${EMPTY}; a default may use an earlier argument: ${to}=${from} |
| Any number of values | @{items} after the positional arguments |
| Options that must be named | Arguments after @{items} (or after a bare @{}): @{} ${timeout}=10s |
| Free-form named options | &{options}, always last |
| Values inside the sentence | Embedded arguments: Select Team "${city}" "${team}" |
| Conversion or validation | Types on RF 7.3+: ${count: int}, ${mode: Literal["fast", "safe"]} |
- Named arguments are written literally (
timeout=5s). A variable that containstimeout=5sis passed as a positional value. - A wrapper forwards everything:
[Arguments] @{args} &{kwargs}and callsInner Keyword @{args} &{kwargs}. - Embedded arguments: case-insensitive match, spaces and underscores count, no defaults or varargs. Quote adjacent values or give the last one a pattern (
${team:\S+}); details inreferences/embedded-arguments.md.
Setup, teardown and suite files
- A setup or teardown is exactly one keyword call. Put several steps in a user keyword.
- A test's
[Setup]/[Teardown]replaces the suite'sTest Setup/Test Teardown; it does not add to it.NONEdisables it. - A teardown runs when the test or suite fails, and it continues when one of its steps fails.
- A failed suite setup fails every test in the suite without running them; the suite teardown still runs.
- Keywords and variables defined in
__init__.robotare not visible to child suites. ATest SetuporTest Teardownset in__init__.robotis resolved in each child suite, so every child imports the resource that defines that keyword. Defining it in the init file's own*** Keywords ***section fails with "No keyword with name … found".Test Templateis not allowed in__init__.robot. - Running a child file or directory directly skips the parent
__init__.robot. Run the root with--suiteor--test. 01__login.robotstyle prefixes order suites and are removed from suite names.
assets/examples/tests/api/__init__.robot; users.robot imports api.resource too:
robotframework*** Settings *** Documentation API suite: one session for all API tests. Resource ../../resources/api.resource Suite Setup Open Api Session Suite Teardown Close Api Session Test Tags api
Tags and selection
- Suite-wide tags go in
Test Tags; per-test tags in[Tags].[Tags] -smokeremoves a suite tag from one test (RF 7.0+).Force TagsandDefault Tagsare legacy; robocop flagsForce Tags(DEPR07). - Reserved tags use the
robot:prefix:robot:skip,robot:exclude,robot:skip-on-failure,robot:continue-on-failure,robot:stop-on-failure,robot:no-dry-run(on keywords),robot:private(on keywords),robot:flatten. Do not invent otherrobot:tags (robocop TAG03). - Tags match case-, space- and underscore-insensitively:
S_M O K Eselectssmoke. - Quote tag patterns and write operators in upper case:
"smoke NOT slow","api AND smoke","smoke OR regression". A lower-casenotis part of the tag name.
| Goal | Command | Tests in assets/examples |
|---|---|---|
| Smoke but not slow | robot --include "smoke NOT slow" tests | 2 |
| One test by full name from the root suite | robot --test "Tests.Api.Users.Create User" tests | 1 |
| Same test by pattern | robot --test "*.Users.Create User" tests | 1 |
| One suite, with its parent init files | robot --suite users tests | 3 |
| Parse only some files | robot --parseinclude "02__*.robot" tests | 3 |
| Run but skip a tag | robot --skip slow tests | 14 |
Turn failures of known-flaky tests into skips with --skiponfailure flaky; re-run failures with --rerunfailed results/output.xml --output rerun.xml and merge with rebot --merge (it errors when nothing failed). More in references/tags-and-selection.md.
Variables and resources
VAR(RF 7.0+) creates variables:VAR ${TOKEN} abc scope=SUITE. Scopes:LOCAL(default),TEST,SUITE,SUITES(7.1+),GLOBAL.- Upper case for non-local variables, lower case for locals and arguments.
- Priority:
--variableover--variablefileover the suite's own*** Variables ***over imported resources and variable files (the first import wins). - Default layout: the detected resource directory, else
resources/;common.resourcewith shared imports; one<domain>.resourceper domain;variables/<env>.yamlselected with--variablefile. Never overwrite an existing file unless asked. - Resource files hold keywords and variables only: no tests, and only imports,
DocumentationandKeyword Tagsin Settings. Import with paths relative to the importing file or${CURDIR}. - YAML variable files need PyYAML in the project (
uv add pyyaml); JSON variable files need nothing extra.
| Legacy | Write instead |
|---|---|
[Return] ${x} | RETURN ${x} |
Run Keyword If $x Kw | IF $x Kw (inline) or an IF/END block |
Set Suite Variable ${X} 1 | VAR ${X} 1 scope=SUITE |
Create List a b | VAR @{items} a b |
Force Tags api | Test Tags api |
The full table with minimum versions and robocop rule IDs is references/migration.md.
Agent workflow
- Run the version gate and Step 0.
- Look up the signatures of the library keywords and existing user keywords you plan to call:
robotcode doc keyword <Library or resources/file.resource> "<Keyword>". - Write or restructure the code. Every new file starts with its section header.
- Dry run the changed suites from the project environment:
uv run robot --dryrun --outputdir results tests. The dry run does not catch:- undefined or misspelled variables;
- a space before
=in a named argument (timeout =5sbecomes a positional value); - wrong embedded-argument binding, including BDD steps matching an unintended keyword;
- union-with-
strconversion surprises (${v: int | str}keeps"10"a string), and typed arguments on RF < 7.3. These need a real run of at least one affected test before you report success.
- Lint with
--target-versionset to the project's RF major version:uv run robocop check --no-cache --target-version 7 -s "DEPR*" -s "ERR*" -s ORD02 -s "NAME*" -s VAR07 -s ARG03 tests resources(repeat-s; a comma list is rejected), plus-s KW06for keyword name conflicts. Fix what it reports in the code you wrote. - Check the changed files statically:
uv run robotcode analyze code <changed files>, and fix every error. - Run the affected tests for real by longname,
uv run robotcode robot -bl "<Suite.Sub.Test>"(longnames fromrobotcode discover tests), or a whole directory, so that__init__.robotfiles apply. Don't pass a single.robotfile. - Read the results:
uv run robotcode results show --failed, thenuv run robotcode results log -bl "<longname>". - Fix and repeat from step 4.
If robotcode or Robocop is missing from the project environment, report steps 5–8 as skipped instead of passed, and point to rf-setup for robotcode[all].
Gotchas
- A templated test runs every row even after a failure (
[Template]rows continue on failure): it fails if any row fails and is skipped only if all rows skip. Do not wrap rows inTRY; tag the testrobot:stop-on-failureto stop at the first failure. Test Templatein__init__.robotis rejected with "not allowed in suite initialization file"; set it per suite file.[Template] NONEturns a suite template off for one test.*and?in a test name act as wildcards in--test(--test "Login ?"also selectsLogin A); keep them out of test names.Kw timeout =5spasses the stringtimeout =5spositionally, and the dry run does not notice; writetimeout=5s, andfoo\=barfor a literal=.FOR,WHILE,IFandTRYin a test body hide the test's intent; move the logic into a user keyword. The one exception is aFORorIFin a templated test that feeds data rows.Force TagsandDefault Tagsare legacy: useTest Tagsand[Tags] -tag. Inventedrobot:tags are reserved words (robocop TAG03).- Unquoted or lower-case tag patterns break selection:
--include "smoke not slow"selects nothing; write"smoke NOT slow". [Setup]in a test replacesTest Setup, a setup takes one keyword only, and a failedSuite Setupfails every child test without running it.- Keywords in
__init__.robotare not visible to child suites, andTest Setupfrom an init file fails with "No keyword with name" unless each child imports the resource that defines it. robot tests/api/users.robotskipstests/api/__init__.robotand its suite setup; runrobot --suite users tests.[Arguments] ${count}: intis invalid ("Invalid argument syntax");${count: int}needs RF 7.3 and on older versions passes the dry run, then fails at run time.Select Team ${city} ${team}called asSelect Team Los Angeles Lakersbindscity=Los: adjacent default embedded arguments take the shortest match. If the calls cannot be changed, give the one-word argument a pattern:Select Team ${city} ${team:\S+}. Only the:patternpart is a regex; the text between arguments is literal, so${city}\s${team}never matches. Run the test for real, because a passing dry run does not prove which keyword or binding matched.- "No keyword with name 'Select team Los Angeles Lakers' found" for a keyword defined with
[Arguments]or@{args}: the values are part of the called name, so the keyword needs embedded arguments (Select team ${city} ${team:\S+}), not[Arguments]. - BDD step keywords are defined without the prefix (
The Calculator Is Cleared); a keyword defined asGiven the app is opencannot be called asWhen the app is open. - The same keyword name in two imported resources fails with "Multiple keywords with name 'Open App' found"; call
a.Open App, setSet Library Search Order, or rename one. - A YAML variable file without PyYAML fails with "Using YAML variable files requires PyYAML module"; run
uv add pyyaml. Set Test Variablein a suite setup is an error before RF 7.2 and, from 7.2, is not visible to the tests;BREAKandCONTINUEin a called keyword fail with "BREAK is not allowed in this context".- An inline IF with no matching branch assigns
None:${v}= IF $n > 10 Set Variable bigleaves${v}asNone; add anELSEbranch. CatenateandSet Variable Ifare not flagged by robocop but have modern forms:VAR ${s} a b separator=-and an inlineIF/ELSE.- A new file without a section header is not a suite ("contains no tests"); every new
.robotor.resourcefile starts with*** Settings ***,*** Test Cases ***or*** Keywords ***. - Robocop NAME18 flags keyword calls that are not Title Case, BDD steps included; write
Given The Calculator Is Cleared, notGiven the calculator is cleared.
When to read the references
| Read | When |
|---|---|
references/styles.md | Choosing or converting between keyword-driven, data-driven and BDD tests |
references/templates.md | Writing Test Template/[Template] suites, column headers, embedded or looping templates |
references/suites-and-init.md | Writing __init__.robot, suite setup and teardown, suite order and names |
references/tags-and-selection.md | Tagging tests, reserved robot: tags, --include/--test/--suite/--skip/--rerunfailed |
references/arguments.md | Designing [Arguments]: defaults, varargs, named-only, &{kwargs}, types, wrappers |
references/embedded-arguments.md | Keywords with values inside the name, custom patterns, conflicts, BDD step definitions |
references/variables-and-scopes.md | VAR, scopes, variable priority, $var expressions, Secret |
references/control-structures.md | IF, FOR, WHILE, BREAK/CONTINUE, TRY, GROUP in keywords, retries |
references/resources-and-variable-files.md | Organising .resource files, imports, variable files per environment, name conflicts |
references/migration.md | Replacing legacy syntax, with robocop rule IDs |
Examples in assets/examples/ (run robot --dryrun tests from that folder):
tests/with__init__.robot, one suite per style (01__keyword_driven.robot,02__data_driven.robot,03__templates.robot,04__bdd.robot),05__embedded.robot,env.robotandapi/with its own__init__.robot(RF 7.0+)resources/calc.resource,login.resource,api.resource,embedded.resource(RF 7.0+)resources/keywords.resource, the typed keyword template (RF 7.3+)variables/dev.yaml,staging.yaml(PyYAML) andcommon.py(RF 7.0+)
Companion Skills
| Need | Skill |
|---|---|
| Web UI tests with Browser Library (Playwright) | rf-browser |
| API tests with RequestsLibrary | rf-requests |
| Install Robot Framework or a library, fix the environment | rf-setup |
| Write or fix a Python keyword library or listener | rf-python-library |
For running, discovering, keyword documentation, result analysis and debugging with the robotcode CLI, use the robotcode skill of the robotcode plugin (robotcode@robotframework-agent-plugins); the commands above work without it.


