Skip to main content
Chemistry LibreTexts

8.2: Knowledge Documents for AI Agents

  • Page ID
    557415
  • ​

    ​

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \( \newcommand{\dsum}{\displaystyle\sum\limits} \)

    \( \newcommand{\dint}{\displaystyle\int\limits} \)

    \( \newcommand{\dlim}{\displaystyle\lim\limits} \)

    \( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)

    ( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\id}{\mathrm{id}}\)

    \( \newcommand{\Span}{\mathrm{span}}\)

    \( \newcommand{\kernel}{\mathrm{null}\,}\)

    \( \newcommand{\range}{\mathrm{range}\,}\)

    \( \newcommand{\RealPart}{\mathrm{Re}}\)

    \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)

    \( \newcommand{\Argument}{\mathrm{Arg}}\)

    \( \newcommand{\norm}[1]{\| #1 \|}\)

    \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)

    \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \(\newcommand{\longvect}{\overrightarrow}\)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\ket}[1]{\left| #1 \right>}\)
    \(\newcommand{\bra}[1]{\left< #1 \right|}\)
    \(\newcommand{\braket}[2]{\left< #1 \vphantom{#2} \right| \left. #2 \vphantom{#1} \right>}\)
    \(\newcommand{\braopket}[3]{\left< #1 \vphantom{#2}\vphantom{#3} \right| #2 \vphantom{#1}\vphantom{#3} \left| #3 \vphantom{#1}\vphantom{#2} \right>}\)
    \(\newcommand{\qmvec}[1]{\mathbf{\vec{#1}}}\)
    \(\newcommand{\op}[1]{\hat{\mathbf{#1}}}\)
    \(\newcommand{\expect}[1]{\langle #1 \rangle}\)
    \(\newcommand{\dfn}[1]{\emph{\textbf{#1}}}\)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    Without WeBWorK-specific documentation, AI agents fall back on their general Perl training data and write code that looks syntactically correct but fails inside the PG sandbox. Curated reference documents prevent this. The analogy is straightforward: you would not hand a lab technician a set of reagents without a protocol and expect a reliable result. The same principle applies to AI agents. As one practitioner put it: "all the documents it needs is in the skill. So please don't search my hard drive."

    This page explains what knowledge documents are, introduces a ready-to-install skill that contains them, describes what those documents cover, and shows how to build your own set if you prefer to customize.

    Skills and forums: same idea, different names

    Different AI agents use different terminology for the same concept: a curated collection of reference documents that the agent reads before it starts writing code.

    Terminology for knowledge documents across AI agents.
    Term Used by Where docs live
    Skill Claude Code .claude/skills/ directory in your project
    Forum OpenAI Codex Forum panel in the Codex interface or a repository

    The rest of this page uses "knowledge documents" as the agent-neutral term. Wherever you see it, substitute the word your agent uses.

    The WeBWorK Writer skill (ready to install)

    The fastest path for most users is to install a pre-built skill that already contains curated WeBWorK authoring documents. The webwork-writer skill is publicly available and maintained alongside this textbook.

    Claude Code install (one command)

    claude plugin add https://github.com/vosslab/vosslab-skills/vosslab-skills:webwork-writer
    

    GitHub repository: The source documents are hosted at https://github.com/vosslab/vosslab-skills/tree/main/skills/webwork-writer

    For Codex users: Download the reference documents from the same GitHub repository and add them to a forum in the Codex interface.

    The skill contains approximately ten reference documents covering PGML structure, common mistakes, macro allowlists, renderer API usage, CSS-based color and emphasis, advanced randomization, matching problems, niceTables, linting rules, and OPL header metadata. Installing this single skill gives the agent everything it needs to write most WeBWorK problems correctly, with no manual document assembly required.

    Why agents need WeBWorK-specific documents

    PG looks like Perl, but it is not standard Perl. Agents trained on general Perl code will confidently use patterns that break inside the PG sandbox. Here are the most common traps:

    • PG runs in a sandbox that blocks most Perl builtins. Calls to open, system, and die will fail silently or throw errors.
    • The my keyword breaks radio buttons and checkboxes. PG scoping rules differ from standard Perl, and lexical variables declared with my become invisible to the answer evaluator.
    • Backslash references like \@array behave differently inside PGML than in regular Perl.
    • PGML is single-pass. You cannot nest PGML commands or use Perl control-flow statements (like if or for) inside a BEGIN_PGML block.
    • Standard HTML tags are blocked in PGML. Use CSS classes injected via HEADER_TEXT instead.
    • Colors must use CSS, not TeX \color{} commands. The TeX color commands are escaped before MathJax processes them.
    • Only PG 2.17 macros are available. Newer Perl modules are not loaded in the renderer.

    Without documentation that explains these differences, agents will hit every one of these traps. For detailed examples and fixes, see Common Mistakes and How to Fix Them and Common PG Macros.

    What the skill documents cover

    The following table lists the topics included in the webwork-writer skill. Think of this as a table of contents for what is already inside the skill rather than a list of documents you need to assemble yourself.

    Reference documents included in the webwork-writer skill.
    Topic Why the agent needs it Textbook reference
    PG authoring basics Correct file structure and PGML syntax so every problem compiles on the first attempt Problem Generation
    Common mistakes Avoid known PG traps like my scoping and backslash escaping Common Mistakes and How to Fix Them
    Macro allowlist Only load macros that exist in PG 2.17 to avoid undefined-subroutine errors Common PG Macros
    Renderer API POST problems to the renderer and read JSON responses for self-testing Setting Up the PG Renderer
    Color and emphasis CSS-only styling that works inside the PG sandbox Text Coloring and Emphasis
    Randomization Correct use of random(), list_random(), and NchooseK() Advanced Randomization
    niceTables Build HTML tables inside PGML without blocked tags niceTables
    Matching problems Randomized matching with PopUp menus or RadioButtons Matching Problems
    Lint rules Static and renderer-based checks to catch errors before students see them Linting
    OPL header Required metadata fields for the Open Problem Library OPL Header and Metadata

    Building your own document set

    If you want to customize the reference material or use an agent that does not support skills, you can assemble your own document set. Keep these guidelines in mind:

    • Keep all documents in a single directory so the agent does not search your entire filesystem. A dedicated folder like webwork-docs/ works well.
    • Include an explicit instruction in your agent configuration: "Use only the provided documents. Do not search for other files."
    • Start with a minimal set and add documents only as you encounter gaps. Four documents are enough to get started: a PG authoring guide, the common mistakes list, the macro allowlist, and the renderer API reference.
    • When you find a new trap or pattern, add it to your documents instead of relying on the agent to remember it from a previous conversation.

    The textbook pages listed in the table above are a good source for building your own documents. You can adapt their content into plain-text or Markdown files that your agent can read.

    Apply it today

    • Install the webwork-writer skill with one command:
      claude plugin add https://github.com/vosslab/vosslab-skills/vosslab-skills:webwork-writer
      
    • Test with a simple problem. Ask your agent to write a multiple-choice question about your favorite color. If the agent produces a working PG file that renders without errors, the skill is installed correctly and the agent can find the documentation.
    • Once the skill is confirmed, move on to Connecting AI Agents to the PG Renderer so the agent can compile and test its own output automatically.

    This page titled 8.2: Knowledge Documents for AI Agents was last modified on Fri, 27 Feb 2026 14:54:22 GMT and is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Neil R. Voss.