:orphan: .. _agents-label: LLMs and agents ====================== A typed, checked specification grounds a coding agent far better than prose in a markdown file: every term an agent uses is declared, every reference is resolved, and a checker tells it exactly what is wrong. This page lists what is published for language models and how to wire ``reqtool`` into an agent loop. Machine-readable documentation ******************************** Everything is plain text and public. No HTML scraping is needed. .. list-table:: :widths: 30 70 :header-rows: 1 * - Address - Content * - ``/llms.txt`` - An index of the documentation with one line per page, following the `llms.txt `__ convention. Start here. * - ``/llms-full.txt`` - The documentation in a single file, in reading order. It is small enough for the context window of current long-context models. * - ``/md/.md`` - Each page as Markdown, for example ``/md/reference/entity.md``. Every page of this site links to its Markdown version at the top, and declares it with ````. * - ``/sitemap.xml`` - Every page of the site. The reference is the specification of the language. When writing req, prefer it, and :doc:`req by example `, over knowledge from training data: the language is young and changes between versions. Close the loop with the checker ******************************** ``reqtool check`` turns a specification into feedback an agent can act on. With ``--json`` it prints a machine-readable report: .. code-block:: bash reqtool check --json spec.req .. code-block:: json :caption: Report for a formal expression of the wrong type [ { "code": "E03010", "path": "System::Deceleration_bound", "span": { "start": { "line": 17, "column": 4, "index": 328 }, "end": { "line": 17, "column": 40, "index": 364 } }, "message": "expected type Number got Boolean", "severity": "critical", "kind": "typing", "snippet": "Wheel::deceleration_duration < false" } ] * The report is a list with one object per diagnostic. An empty list, ``[]``, means the specification is clean. * ``path`` is the entity the diagnostic is about (``null`` for a syntax error), ``message`` says what is wrong, ``span`` says where, and ``snippet`` is the text found there. Lines and columns are counted from zero (line 17 is the 18th line of the file) and ``index`` is the byte offset. * ``code`` identifies the kind of issue and never changes, ``kind`` is what the issue is about (``syntax``, ``path``, ``reference``, ``typing`` or ``connection``). Every code is explained in :ref:`reference-diagnostics-label`, with an example and the fix: read it before guessing a fix. * ``severity`` is one of ``light``, ``moderate``, ``severe`` and ``critical``. * A syntax error is in the same list, with the kind ``syntax`` and the severity ``critical``. It means the parser could not read the source: fix these first, the other diagnostics around them may be consequences. .. warning:: ``reqtool check`` currently exits with status 0 even when it reports issues. An agent or a CI job must read the report (an empty list when the specification is clean), not the exit status. What the checker enforces today ******************************** An agent writing req should know these rules. They are how ``reqtool`` behaves today, and each one corresponds to a diagnostic. * Every part and attribute must be *used* (referenced by a requirement) and *restricted* (named after ``on`` in a requirement). * A requirement uses the entity it is ``on``: an identifier in its expression when it is formal, a ``[[...]]`` reference in its text when it is informal. * A requirement needs a parent through ``refines`` or ``derives`` unless it is marked ``top``, and children unless it is marked ``bottom``. A requirement marked with both stands alone. * The root of the specification is a package. Requirements are written in packages, attributes in parts. * Identifiers are made of letters, digits and ``_``, and do not start with a digit. * A refining requirement must restrict an entity inside what the refined requirement restricts. * References are written ``[[Path::To::Entity]]`` inside informal text between ``@@`` markers. They are resolved against the enclosing scopes, or as a full path. * Units go between backslashes and are free-form: ``let speed in real \ m/s \``. * There is no ``forall``, ``exists``, ``select`` nor ``if``: write ``all … for … end``, ``any … for … end``, ``choose``, ``argmax`` or ``argmin``, and ``when``. A range of values is ``x in 3000 tol 50``. A complete specification that follows all of them: .. literalinclude:: tutorials/examples/03-refinement.req :language: req A snippet for your agent instructions **************************************** Put this in ``AGENTS.md``, ``CLAUDE.md`` or the equivalent file of your repository: .. code-block:: markdown ## Specifications (req) - Requirements are written in the req language, in `.req` files. - Language documentation for agents: https://req-lang.org/llms.txt (the whole documentation in one file: https://req-lang.org/llms-full.txt). - Do not invent syntax. If a construct is not in the documentation, ask. - After every edit to a `.req` file, run `reqtool check --json ` and fix every issue until the report is the empty list `[]`. The exit status is 0 even when issues are reported. - Each issue has a `code`. The Diagnostics page of the documentation explains each code, with an example and the fix. - Keep informal text in `@@ ... @@` and reference entities with `[[Path::To::Entity]]`.