Logo de Rf Python Library

Rf Python Library

Communauté
manykarim
rf-python-library

Use first, before answering, to write or fix Robot Framework keyword libraries or listeners in Python.

Présentation

Éditeurmanykarim
Dépôtrobotframework-agentskills
Nom de la compétencerf-python-library
Étoiles
40
Forks
2
Fichiers inclus
12
LicenceApache-2.0
Liens
  • Instructions en Markdown

    Un fichier SKILL.md que le modèle charge à la demande : il ne consomme donc des tokens que lorsqu’une demande correspond réellement à la compétence.

  • Compatible avec tous les LLM

    Les compétences IA sont en simple Markdown, et non en code propre à un fournisseur. Elles fonctionnent donc avec GPT, Claude, Gemini, Grok ou un modèle local.

  • 12 fichiers inclus

    Des scripts, des modèles de documents et des références que le modèle peut consulter pendant son travail. Les fichiers sont en lecture seule et ne sont jamais exécutés.

  • Open source

    Publiée par manykarim sur GitHub. Consultez les sources avant de l’installer.

Installation

Installez la compétence IA Rf Python Library dans TypingMind pour l’utiliser avec n’importe quel LLM, ou ajoutez-la à un autre agent capable de lire SKILL.md.

1

Installer dans TypingMind

TypingMind installe une compétence directement depuis son dossier GitHub : l’application lit SKILL.md, regroupe les fichiers de ressources et enregistre le tout localement.

  1. Ouvrez l’application et accédez à Plugins → Compétences.
  2. Choisissez « Installer depuis GitHub ».
  3. Collez l’URL du dossier de la compétence indiquée ci-dessous, puis confirmez.
    https://github.com/manykarim/robotframework-agentskills/tree/main/plugins/rf-agentskills/skills/rf-python-library
  4. Activez la compétence dans chaque discussion où vous souhaitez pouvoir l’utiliser.
Plugins → Compétences → Ajouter → Via URL GitHub, puis collez l’URL du dossier et appuyez sur Continuer.
2

Installer dans un autre agent

Tout agent capable de lire le format Agent Skills peut utiliser cette compétence : copiez le dossier dans le répertoire des compétences de cet agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/manykarim/robotframework-agentskills.git /tmp/robotframework-agentskills
mkdir -p .claude/skills
cp -r /tmp/robotframework-agentskills/plugins/rf-agentskills/skills/rf-python-library .claude/skills/rf-python-library
Redémarrez Claude Code après la copie pour que la nouvelle compétence soit prise en compte.

Utilisez cette compétence dans TypingMind

Activez Rf Python Library dans n’importe quelle discussion TypingMind et le modèle s’occupe du reste. Le nom et la description de la compétence figurent dans le prompt système. Dès qu’une demande correspond, le modèle charge lui-même l’intégralité des instructions : vous n’avez jamais à l’invoquer manuellement, et elle ne consomme aucun token tant qu’elle n’est pas utilisée.

Le modèle charge automatiquement Rf Python Library dès qu’une demande correspond à cette compétence.

Compatible avec tous les modèles IA

Les compétences IA sont de simples instructions Markdown, et non du code propre à un fournisseur. Ainsi, Rf Python Library n’est pas lié au modèle pour lequel cette compétence a été conçue. Installez-la une seule fois dans TypingMind et utilisez-la avec GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou un modèle local que vous exécutez vous-même, le tout avec vos propres clés API.

  • Chargée uniquement en cas de besoin

    Le prompt système ne contient que le nom et la description. Les instructions sont récupérées à la première demande correspondante : une compétence inutilisée ne coûte donc rien.

  • Changez de modèle en cours de discussion

    La compétence étant constituée d’instructions et non de code, elle reste fonctionnelle lorsque vous changez de modèle : le nouveau modèle lit le même fichier SKILL.md.

Instructions de la compétence

Voici le contenu de SKILL.md que le modèle charge. Lisez-le avant l’installation : une compétence contient des instructions que votre modèle suivra.

Robot Framework Python Library

Writing and fixing keyword libraries and listeners in Python: the default library shape, scope, argument conversion, failures, logging and the checks that catch Robot Framework-specific defects before a test runs. Tests, user keywords and .resource files belong to rf-language; using an existing library (Browser, RequestsLibrary, …) belongs to that library's skill. Rule of thumb: logic goes into Python, composition of existing keywords into a user keyword.

When to use

Load this skill first, before exploring the project, reading or creating .py files, or answering from memory, when Robot Framework keywords, libraries or listeners are written in Python:

  • a new keyword library (around an API, database or device client), @keyword and @library decorators;
  • ROBOT_LIBRARY_SCOPE and state kept between tests (a library that loses its state, a connection scope);
  • argument conversion from type hints (Enum, Literal, custom converters), failures and logging via robot.api, libdoc docs;
  • a library that "contains no keywords";
  • a listener that reacts to or reports results (chat, dashboards).

Not this skill: keywords in .robot/.resource files use rf-language; using an existing library such as Browser or RequestsLibrary uses its library skill.

Quick reference and version gate

Check the version in the project environment first (robot --version exits 251 even on success):

bash
uv run python -c "import robot; print(robot.__version__)"
FeatureMin RF
async def keywords, BuiltIn().dry_run_active6.1
Literal conversion, embedded plus normal arguments in one library keyword, listener API v3 as the default7.0
ROBOT_LISTENER_PRIORITY7.1
@library selects the decorated class in a module whose name differs7.2
robot.errors.TimeoutExceeded (named TimeoutError before 7.3)7.3
Secret (robot.api.types) and object type hints7.4
Markdown doc format (doc_format="MARKDOWN"); RF timeouts no longer derive from Exception7.5

Default library template

Save it as libraries/<Name>.py; the class name equals the file name.

python
# file: MyLibrary.py
"""Keywords for <what the library does>."""

from enum import Enum

from robot.api import logger
from robot.api.deco import keyword, library


class Mode(Enum):
    ON = "ON"
    OFF = "OFF"


# scope: pick it by how long the library state must live (scope table below).
@library(scope="TEST", version="0.1.0")
class MyLibrary:
    """One-line summary: libdoc shows it as the library introduction.

    Import: ``Library    MyLibrary    timeout=5``.
    """

    def __init__(self, timeout: float = 5.0) -> None:
        self._timeout = timeout  # state is set here only

    @keyword
    def set_mode(self, mode: Mode) -> str:
        """Switch the mode; ``on`` and ``off`` are accepted case-insensitively.

        Args:
            mode: ``ON`` or ``OFF``.
        """
        logger.info(f"mode {mode.name}, timeout {self._timeout}")
        return mode.name

    @keyword
    def value_should_be(self, actual: int, expected: int) -> None:
        """Fail unless ``actual`` equals ``expected``."""
        if actual != expected:
            raise AssertionError(f"expected {expected}, got {actual}")

Why each part: @library turns off automatic discovery, so only @keyword methods become keywords; type hints drive argument conversion and libdoc; the docstring's first line is the short doc; AssertionError marks a verification failure; robot.api.logger writes to the log.

Decisions

Module or class

Library needsUse
A few stateless functionsModule library; set ROBOT_AUTO_KEYWORDS = False and decorate keywords with @keyword, so imported names do not become keywords
State, init arguments, converters or a listenerClass library with @library (the template)

Library scope (Robot Framework User Guide, "Creating test libraries" → "Library scope"). Choose by how long the state must live:

State must live …ScopeNote
per test, or must not leak between testsTEST (default)a new instance for every test keeps tests independent; suite setup and teardown share another instance
across the tests of one suite (client, connection, accumulated data)SUITEa new instance per suite; add a cleanup keyword (Clear …) for a suite setup or teardown
across suites for the whole run (one browser or session)GLOBALone instance for the run; add a cleanup keyword (Close All …); module libraries are always global
no state at allany; GLOBAL avoids needless instancesa stateless library does not need new instances

Importing the same library with different arguments creates a new instance regardless of scope; give each import a name with AS.

Static, hybrid or dynamic API

SituationAPI
Normal libraryStatic: methods are keywords (the template)
Keyword names computed at runtime, implementations are real methodsHybrid: get_keyword_names
Proxy to another tool or process, or keywords generated from a specDynamic: get_keyword_names + run_keyword; PythonLibCore helps compose large libraries

Failures and logging

WantUse
Verification failedAssertionError (or robot.api.Failure)
Fail but continue the testrobot.api.ContinuableFailure
Mark the test skippedrobot.api.SkipExecution
Stop the whole runrobot.api.FatalError
Keyword used incorrectlyValueError / robot.api.Error
Log for the reportlogger.info / logger.debug; html=True for HTML; logger.warn for warnings
Show progress on the consolelogger.console

Placement and import

Project libraries live in libraries/ on the python-path that rf-setup's project layout defines, and are imported by name:

toml
# robot.toml
python-path = ["resources", "libraries"]
robotframework
*** Settings ***
Library    MyLibrary    timeout=10
Library    MyLibrary    timeout=60    AS    SlowLibrary

Plain robot needs --pythonpath libraries. Import by name, not by a relative ../libraries/X.py path, so the same import works from every suite. Add third-party runtime dependencies with the project's tool (uv add <package>; see rf-setup).

Agent workflow

  1. Check the version: uv run python -c "import robot; print(robot.__version__)", then use only features from the gate table.

  2. Write or edit libraries/<Name>.py from the template; pick the scope from the scope table.

  3. Run the checker and fix every error and warning finding (or state why one stays). It runs the library's import and __init__ code, so use it on your own project libraries only:

    bash
    uv run python "${CLAUDE_SKILL_DIR}/scripts/check_library.py" libraries/<Name>.py
  4. List the keyword names the tests will call: uv run robotcode doc keywords libraries/<Name>.py (one keyword in full: uv run robotcode doc keyword libraries/<Name>.py "<Keyword>").

  5. Pure Python logic with branches gets pytest unit tests.

  6. uv run robotcode analyze code tests/ on the suites that import the library (with libraries on the python-path in robot.toml). It finds unknown keywords and wrong argument counts without running anything, so it misses variables set at run time, named-argument typos, embedded-argument mismatches and str in unions; the real run in step 7 catches them.

  7. uv run robot --pythonpath libraries --outputdir results tests/ (or uv run robotcode robot with the robot.toml python-path); on failure rerun with --loglevel DEBUG for tracebacks and read the results with uv run robotcode results show --failed and uv run robotcode results log --failed.

  8. Fix and go back to step 3.

The script path is relative to this skill's directory; library paths are relative to the project root. More checker calls:

bash
uv run python "${CLAUDE_SKILL_DIR}/scripts/check_library.py" libraries/*.py --pretty
uv run python "${CLAUDE_SKILL_DIR}/scripts/check_library.py" Client --init-arg https://staging.example.com --pythonpath libraries
uv run python "${CLAUDE_SKILL_DIR}/scripts/check_library.py" libraries/Inventory.py --json-out results/check_library.json

Not using uv? Run the same commands with .venv/bin/python or poetry run python instead of uv run python; see rf-setup.

The JSON lists per library the scope, API style and keywords with arguments, plus findings (id, severity, keyword, message, hint), errors first. Exit 0 means checked (findings do not change it); 4 means the input is outside the project root or no library loaded (stderr has the error line and a hint); 3 means Robot Framework is missing from the interpreter.

Gotchas

  • @library disables automatic keyword discovery: a public method without @keyword is silently not a keyword (→ public_method_not_keyword); mark helpers @not_keyword or prefix them with _.
  • Functions imported into a module library, and public base-class methods, become keywords: from os.path import join adds Join (→ leaked_keyword). Import modules (import os) or use ROBOT_AUTO_KEYWORDS = False.
  • The default TEST scope creates a new instance for every test, by design, so tests stay independent: a counter or cache set in one test is gone in the next (→ state_in_test_scope). State that must span tests needs SUITE or GLOBAL plus a cleanup keyword. __init__ also runs during libdoc and --dryrun, so it must not connect anywhere unguarded (→ output_during_import).
  • An inline type in a library embedded-argument name, @keyword("Take ${qty: int} pears"), makes RF 7.3+ reject the keyword, and the library then "contains no keywords" (→ keyword_creation_failed, no_keywords; before 7.3, : int is read as a regex and the keyword never matches). Put the type on the Python argument: def take(self, qty: int).
  • A union that contains str, such as int | str, never converts a string argument: "10" stays a string (→ union_with_str). Drop str or convert explicitly.
  • Implicit typing from defaults is lenient: def kw(n=3) passes abc through as a string (not detected). Use real type hints.
  • bool conversion passes unknown strings through: flag: bool with maybe gives the string maybe (not detected). Use Literal or an Enum when only fixed values are valid.
  • Positional-only arguments (def kw(a, /)) cannot be passed by name: a=1 arrives as the string a=1 (→ positional_only_argument).
  • A broad except Exception: swallows Robot Framework timeouts before RF 7.5 (they derive from Exception until then) (→ broad_except). Catch specific exceptions, or re-raise robot.errors.TimeoutExceeded.
  • Logging or raising from a non-main thread is silently dropped from the log (not detected). Collect results in the thread and log them from the keyword's own thread.
  • A decorator without functools.wraps hides the signature: the keyword takes only *args, **kwargs and loses conversion (→ signature_lost). Add @functools.wraps(func) to the wrapper.
  • Listener methods (end_test, close, …) on a class that is also a library become keywords unless the class uses @library(listener="SELF") (→ listener_method_exposed).
  • Importing the same library twice with different arguments needs AS names, otherwise the second import is ignored with a warning (not detected; it lives in .robot data).

When to read the references

ReadWhen
references/conversion.mdChoosing argument types: built-ins, Enum, Literal, TypedDict, containers, unions, Secret, custom converters
references/api-variants.mdModule vs class details, scope and init arguments, embedded arguments, async, hybrid and dynamic APIs, PythonLibCore, Remote
references/listeners.mdWriting a listener (API v3), a library that is also a listener, listener priority, changing results
references/communication.mdExceptions, HTML messages, logging levels, threads, timeouts, calling BuiltIn from a library
references/packaging-and-docs.mdlibdoc output, doc formats, versioning, packaging a library with resources, tests for a library

The runnable examples in assets/examples/ (ExampleLibrary.py, converters.py, ResultListener.py and their suites) pass with uv run robot --pythonpath assets/examples --listener ResultListener assets/examples.

Companion Skills

NeedSkill
Write tests, suites, user keywords, resources and variables in Robot Framework syntaxrf-language
Install Robot Framework or a library, fix the environmentrf-setup

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.

Fichiers inclus

Le modèle lit ces fichiers à la demande lorsque la compétence est chargée. Ils sont accessibles en lecture et ne sont jamais exécutés.

Foire aux questions

À quoi sert la compétence IA Rf Python Library ?

Use first, before answering, to write or fix Robot Framework keyword libraries or listeners in Python.

Pourquoi utiliser Rf Python Library sur TypingMind ?

Parce que vous l’installez une seule fois pour l’utiliser avec n’importe quel modèle. Rf Python Library se compose de simples instructions en Markdown plutôt que de code propre à un fournisseur. La même compétence fonctionne donc avec GPT-5, Claude, Gemini, Grok ou un modèle local, et vous pouvez changer de modèle en cours de discussion sans perturber son fonctionnement. TypingMind utilise vos propres clés API : vous payez donc directement les fournisseurs plutôt qu’un abonnement par siège, et vos compétences et discussions restent dans votre propre espace de stockage.

Comment installer Rf Python Library dans TypingMind ?

Dans TypingMind, ouvrez Plugins → Compétences → Installer depuis GitHub et collez https://github.com/manykarim/robotframework-agentskills/tree/main/plugins/rf-agentskills/skills/rf-python-library. TypingMind lit le fichier SKILL.md, regroupe les fichiers associés et installe le tout sous forme de compétence que vous pouvez activer pour chaque discussion.

Quels modèles d’IA peuvent utiliser Rf Python Library ?

N’importe quel modèle que vous connectez dans TypingMind. Les compétences IA sont de simples instructions en Markdown, et non du code propre à un fournisseur. GPT, Claude, Gemini, Grok et les modèles locaux peuvent donc tous charger cette compétence lorsqu’une demande lui correspond.

Combien de modèles d’IA puis-je utiliser avec Rf Python Library ?

Autant que vous le souhaitez. Tant qu’un modèle prend en charge les compétences, vous pouvez utiliser Rf Python Library avec lui : GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama et bien d’autres, le tout dans TypingMind avec vos propres clés API.

La compétence IA Rf Python Library est-elle gratuite ?

Oui. Cette compétence est publiée sur GitHub par manykarim sous licence Apache-2.0. Vous ne payez que votre propre fournisseur d’IA pour les tokens utilisés.

Que sont les compétences IA ?

Une compétence IA est un ensemble d’instructions réutilisables qui apprend à un modèle d’IA à accomplir une tâche précise. Elle suit le format ouvert Agent Skills : un fichier SKILL.md contenant un nom et une description, ainsi que les éventuels scripts, modèles de documents ou fichiers de référence dont le modèle peut avoir besoin. Le modèle ne lit les instructions que lorsque votre demande correspond à la compétence. Une compétence installée ne coûte donc rien tant qu’elle n’est pas utilisée.

En quoi les compétences IA diffèrent-elles des plugins ou des serveurs MCP ?

Un plugin ou un serveur MCP fournit au modèle de nouveaux outils à appeler : du code qui s’exécute quelque part et renvoie un résultat. Une compétence IA lui apporte plutôt des connaissances et une méthode : comment aborder une tâche, quelles étapes suivre et à quoi ressemble un bon résultat. Les compétences sont de simples instructions en Markdown. Elles ne nécessitent donc ni serveur, ni clé API, ni environnement d’exécution, et fonctionnent avec n’importe quel modèle.

Tout voir

Créez votre propre espace IA dès maintenant

Abonnez-vous à notre newsletter pour être informé des nouvelles fonctionnalités et des prochains cadeaux à gagner 👇