agentleFS
WingedGuardianWingedGuardian/skyrimvr-claude-toolkit/.agents/skills/xelib/SKILL.md

xelib

Skill22 starsChanged 3 days agoMITView on GitHub

Write or run xelib / XEditLib.dll scripts (Node + koffi) -- UTF-16 strings, VOID init, WordBool, the string-return pattern, game mode, the SSE registry key, loading the REAL active load order, and judging success by stdout not the exit code. Use before writing, running or debugging any xelib script.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Every xelib / koffi-based Node helper (tools/resaver-resolve-names.js, the tools/xelib/ scripts, your own) can exit non-zero (e.g.

    line 47

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md
<!-- GENERATED by scripts/gen_agent_trees.py from agent/skills/xelib/SKILL.md. Toolkit contributors: edit the source. Your own notes belong in KNOWLEDGEBASE.local.md, which updates never replace. -->

XEditLib / xelib

XEditLib.dll API (Critical Notes)

The DLL is Delphi-compiled. These quirks caused hours of debugging:

  1. All strings are UCS-2/UTF-16LE (Delphi PWideChar), never UTF-8:
    function wcb(s) { const b = Buffer.alloc((s.length+1)*2,0); b.write(s,0,'ucs2'); return b; }
  2. InitXEdit() and CloseXEdit() are VOID, not bool. Declaring them as bool corrupts the call stack.
  3. WordBool = uint16 (2 bytes), not bool/uint8.
  4. String return pattern: Functions don't return strings directly. They write a length to a PInteger param, then you call GetResultString(buffer, len) to retrieve the actual value:
    function getString(fn) {
        const lenBuf = Buffer.alloc(4, 0);
        fn(lenBuf);
        const len = lenBuf.readInt32LE(0);
        if (len < 1) return '';
        const strBuf = Buffer.alloc(len * 2, 0);
        GetResultString(strBuf, len);
        return strBuf.toString('utf16le', 0, len * 2);
    }
  5. Game mode enum: gmFNV=0, gmFO3=1, gmTES4=2, gmTES5=3, gmSSE=4 (use this for Skyrim VR), gmFO4=5
  6. Registry requirement: XEditLib reads game path from HKLM\SOFTWARE\WOW6432Node\Bethesda Softworks\Skyrim Special Edition (the SSE key, not the VR key, because game mode 4 = SSE).
  7. xelib.js wrapper: See xeditlib on GitHub for the full wrapper with all 163 functions.

Load the real active order

  1. xelib — in GM_SSE mode the loader reads the SSE plugins.txt, which may be absent on a VR install → the load fails silently. It may also be present and stale, which is worse: measured on the dev machine (VR-only), the SSE file holds 659 plugins, is 18 days old, and disagrees with the VR file about which plugins are active — a complete, plausible, wrong load order that nothing rejects. loadActive() prefers the VR file, names every rival it ignored, and honours $PLUGINS_TXT. Use tools/xelib/active-plugins.js loadActive() to read and load the real active order explicitly, and always run xelib via a .js file (node script.js), never node -e '...' (inline eval deterministically breaks SetGameMode).

Judge success by stdout, never the exit code

Every xelib / koffi-based Node helper (tools/resaver-resolve-names.js, the tools/xelib/ scripts, your own) can exit non-zero (e.g. 127) even on full success on Windows / Git Bash: Node's stdio flush at exit races the resident native DLL's teardown. Parse the output the script prints to decide success, never $?, and never &&-chain on it; a wrapper that gates on the exit code reports phantom failures. Where a wrapper exists it does this for you (tools/skyrim-winner.sh parses the RESULT: line and returns a real exit code). Source: KNOWLEDGEBASE.md → Node/koffi helper exit codes are unreliable on Windows.

For who-wins questions use bash tools/skyrim-winner.sh (skill triage-and-conflicts), not a new script.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.