AI-assisted analysis with the XplainPy skill
XplainPy includes an agent skill: a set of instructions that helps a compatible
AI coding agent use the xplain Python package for Xplain/XOE data analysis.
It explains how to inspect the object hierarchy, choose an analysis route and
check common Xplain query pitfalls. The skill complements the Python API; it is
not a separate server or a guarantee that an answer is correct.
The bundled skill is distinct from any separately installed specialist Xplain
skills. Its contents correspond to the installed package version; use
xplain skill path to find that copy.
Prerequisites
A compatible coding agent that supports skills, and permission to use it with the data involved. Agent capabilities and skill discovery vary by product.
An installation of
xplainthat includes the skill. The skill was added in version 0.0.44. Check the versions available from your package source before installing a specific release.Access to an Xplain server and the appropriate dataset and credentials. See Authentication & Credential Management and Quick Start for connection setup.
Install the skill
Use the xplain command from the same Python environment as your package:
xplain skill path
xplain skill install
The first command prints the bundled skill directory. The second copies it to
~/.claude/skills/xplainpy by default. To install it into a different agent’s
skills directory, provide --target; for example, for a Codex installation
that discovers skills in ~/.codex/skills:
xplain skill install --target "$HOME/.codex/skills"
The installer creates an xplainpy subdirectory inside the target. If that
subdirectory already exists, the command stops without replacing it. After
reviewing the existing copy, pass --force to replace the entire directory:
xplain skill install --target "$HOME/.codex/skills" --force
Installation copies files; it does not update an existing copy automatically when the package is upgraded. Reinstall the skill to use the copy shipped with another version. Follow your agent’s documentation for when it discovers new skills; a new session may be needed.
Example workflow
Connect the agent to an authorized environment and ask a question with a clear population, unit of analysis and time window. For example:
Using the XplainPy skill, count patients who had at least one diagnosis of X during 2024. State how you identify the diagnosis, what each count represents, and how you checked the result.
Names such as Patients and diagnosis labels depend on the loaded dataset.
The agent should inspect the actual object structure and state labels, then
choose an appropriate query. A selection on a child object does not, by itself,
restrict a static count of its parent; the skill describes approaches such as a
parent-level flag or counting distinct parent identifiers on the child object.
See pitfalls for the server semantics and their limitations.
Review and data handling
Review the generated code, population, denominator, filters, time boundaries and output before relying on the result. Investigate surprising counts and compare important results with an independent calculation when feasible. An agent-generated statistical model describes the supplied data; interpreting an association as causal requires additional assumptions and validation.
The agent may execute code, inspect metadata, or retrieve results according to its configuration and permissions. Use only an environment and data that you are authorized to share with that agent, and consult its data-handling settings. Do not include passwords or tokens in prompts. For credentials and session setup, use the supported mechanisms described in Authentication & Credential Management.