Docs/Teach Cofactor about your app with an app skill
#

Teach Cofactor about your app with an app skill

Write an app skill, the knowledge base Cofactor's browser agent reads before it tests your application. Have your coding agent author it from your repository with cofactor application skill. Covers sections, import and versions.

Write an app skill for my application

An app skill is a short set of notes about one application: how it navigates, how it signs in, how it shows success and errors. Cofactor gives the notes to the browser agent when it runs your tests and exploratory tests, so the agent starts with what it cannot read from the page alone.

Write the skill

  1. Find the application and see what exists. The skill commands take the application's id.

    bash
    cofactor application list
    cofactor application skill list --application <application id>
    
  2. Start from the guide. It describes what to write in each section.

    bash
    cofactor application skill guide
    

    The agent that reads the skill has a browser and no source code. Write what it can see, such as "the Create button appears only for admins, and other roles do not see it". Do not write file names, class names or a list of every URL.

  3. Write the items. Each item has a section, a key, a label and plain-prose content. Put them in a bundle.json and import them in one call. Use the repository and commit as the source id.

    json
    {
      "items": [
        {
          "section": "navigation",
          "itemKey": "url_grammar",
          "itemLabel": "URL grammar",
          "content": "List pages live at /<things>, and detail pages at /<things>/<id>."
        }
      ]
    }
    
    bash
    cofactor application skill import --application <application id> \
      --file bundle.json --source-id "acme/store@$(git rev-parse --short HEAD)"
    

    To change one item, use set. A value that starts with @ is read from a file.

    bash
    cofactor application skill set --application <application id> \
      --section auth --key login --label "Sign-in" --content @login.md
    

Check it worked

bash
cofactor application skill list --application <application id>
cofactor application skill export --application <application id> --format md

list shows each item by section, with where it came from. Read three items and ask whether the agent could use them with only a browser. Run a test of a feature the skill describes, and check that the agent behaves as the skill says.

Go deeper

Advanced

The sections, versions and how to undo a change.

Sections. cofactor application skill accepts these sections: general, technology, product, navigation, tenancy, auth, roles_permissions, feature_gating, environments, data_lifecycle, async_realtime, localization, ui, feedback_errors and idiosyncrasies. The guide says what belongs in each. Aim for a few focused items where a section has something to say, and one short note where it does not apply.

Versions. Every write adds a version, so importing the same bundle again is safe. history lists the versions of an item and get --version <n> reads an old one. To go back to it, write it again with set, which adds it as a new version.

Other commands. get and delete act on one item, named by --section and --key. export writes the whole skill as md or json. Run cofactor application skill help for every option.