Pyskills Core
A pyskill is a Python module that gives an LLM instructions or functions to use. Packages register these modules through Python entry points. A host such as Solveit first shows the LLM a catalogue of short descriptions. It reads those descriptions from source without loading the skill. The LLM then chooses which modules to import and read in full.
Entry Point Convention
Register a module in the pyskills entry-point group:
Use the module path as the value. You don’t need a :attribute suffix.
Skill Module Contract
Give the module a docstring. Its first paragraph describes when to choose the skill. The rest tells the LLM how to use it. An optional __all__ controls which symbols the module exposes.
list_pyskills() returns a sorted Pyskills dictionary of module paths and descriptions, displayed one name: description line per entry. It locates each source file with find_spec_noimport and reads its docstring with Python’s AST parser.
After choosing a skill, import it and read its documentation:
These inspection functions work on any Python module, not just pyskills.
A host such as Solveit, Claude Code, or Codex can use this sequence:
Call list_pyskills() at startup.
Include the catalogue with each prompt.
Import each selected module and read doc(module) .
Finding modules without importing them
Find the spec for an absolute module name without importing its parents
importlib.util.find_spec('email.mime.text') imports the parent packages to find their paths. For a catalogue, we want to locate a module before deciding whether to load it. find_spec_noimport follows package paths without running their __init__.py files. It returns a ModuleSpec , or None if the module cannot be found.
Here we locate a standard-library module and check that lookup leaves the imported modules unchanged:
Ordinary packages and namespace packages both work. Child namespace locations are a snapshot of the paths found during lookup. A package that changes __path__ in its initialization code cannot supply those extra paths without running that code. Child modules supplied only by custom meta-path finders are outside this lookup’s scope.
First paragraph of docstring for entry point ep , without importing it
ep_desc reads the module’s first docstring paragraph from its source. The description is available before the skill is imported.
Returns sorted {module: description} for all pyskills, displayed one name: description line per entry. To load a module, use import {module} then view doc({module}) .
NB : pyskills are THE critical way to extend functionality. ALWAYS check for pyskills to help with tasks. If unsure whether a particular pyskill might help, load it and grab its docs to see!
Sorted {module: description} mapping displayed one name: description line per entry
The catalogue returns a sorted Pyskills dictionary mapping importable module names to their descriptions, displayed one name: description line per entry. Use a name from this listing to choose which module to import.
Use allow to register trusted functions, class methods, or callable instances in __pytools__ . A dictionary such as {cls: ['method']} selects methods by name. Use ... to select all public methods. A group object can return its operations from __allow__ .
Registration is a permission request, not sandbox enforcement. allow emits a pyskills.allow audit event before making changes. A sandbox must reject that event if untrusted code tries to expand its permissions. Without an audit handler that rejects the event, registration proceeds.
Add all items in c to __pytools__ , optionally constrained by allow_policy
__pytools__ maps each module, class, or callable instance to a set of allowed names. A function belongs to its module. A method belongs to its class. A callable instance has an entry for '__call__' under the instance itself.
Set entries are names, ... for all public methods, or (name, policy) tuples. A policy checks the arguments of a permitted call. You can supply it through allow_policy or in a dictionary.
A method passed directly is registered against its owning class.
A policy can restrict a registered function’s arguments. This policy accepts HTTPS URLs.
Decorated functions retain their original module registration.
Spec-driven clients often create callable operation objects at runtime. These objects don’t have a function’s useful __qualname__ . allow registers each object itself and wraps its class’s __call__ for call tracking:
A group can expose its operations through __allow__ . Registration applies to those operations rather than the group itself.
Safepyrun rejects pyskills.allow inside its sandbox audit context. Code in that context cannot register new permissions for itself. Outside that context, an audit hook can observe the event without rejecting it:
chk_dest expands ~ and resolves the path. It accepts an allowed destination or a path inside it. Otherwise it raises PermissionError . Pass None to allow every destination, or () to allow none. The destination policies below use this check.
Check positional/keyword path arg is an allowed destination; non-path buffers/handles are skipped
Base for allow destination policies
PosAllowPolicy checks a path passed at a selected argument position or keyword. Paths outside ok_dests raise PermissionError .
PosAllowPolicy decodes byte paths before checking them. It leaves buffers and open file handles alone. Check the destination when opening a handle, before passing it to another operation.
Check resolved Path self, optionally also target args
PathWritePolicy checks the Path instance itself. It can also check a destination argument for operations such as rename.
Check open() only when mode is writable
OpenWritePolicy restricts writable modes. Reading a file outside ok_dests is allowed.
Allow policies are stored as (name, AllowPolicy) tuples directly inside __pytools__ sets.
Resolve a dotted symbol string to its Python object, with optional [n] indexing
Common base class for all non-exit exceptions.
resolve looks up a name in the notebook namespace or builtins. A dotted path can include nonnegative indexes, such as module.items[1] . An unknown root name raises SymbolNotFound .
Public names without evaluating instance properties; a plain instance lists its class’s names, and a SimpleNamespace its own
Use xdir to find public names before asking for their documentation. For a module, it uses __all__ when present. Otherwise it lists the module’s own definitions and sibling submodules, excluding imports from unrelated packages. It also includes explicitly imported sibling submodules in either case.
For a class, it lists public members and a non-default constructor. A plain instance uses its class’s listing. An instance with a custom __dir__ supplies its dynamic names instead. Pass q to filter the list with a case-insensitive regular expression.
A dynamic namespace can expose a property that performs work when read. This example raises if inspection evaluates sound_now .
_xdir retains property descriptors instead of evaluating them. Ordinary methods remain bound to the instance.
Full callable documentation or a module/class/namespace overview; custom Markdown displays are preserved
Editing a source file can leave a live kernel with functions whose recorded line numbers are out of date. If fastcore cannot read a function’s source, its renderer shows the signature without parameter docments and warns with the symbol’s name. If rendering itself fails, doc returns the docstring and an error note. Restart the kernel to load the current source.
For a function, doc renders the docstring and full signature with docments (parameter ). Its FullString return displays readably and tells tools to retain the complete documentation during compaction:
fmt_sig omits module prefixes from annotations. It retains generic arguments and unions in both parameters and return annotations.
Some functions use Parameter.empty as a default value. fasthtml.core.add_sig_param is one example. Plain inspect.signature treats that sentinel as a missing default, which can make a rebuilt signature invalid. fmt_sig uses signature_ex to keep the declared default:
For a class, doc shows the inheritance hierarchy, class docstring, and full constructor documentation. It lists public methods and properties in an overview. Read doc(Class.member) for a member’s parameter docments.
Dataclasses with a synthesized __init__ render their signature via DocmentText without warnings or duplicating the class docstring.
An inherited constructor retains its signature and parameter docments. Its prose appears once, beside that signature.
Patched classmethods appear in the class overview. Read the method separately for its parameter docments.
Skill cross-references
has_public_api checks via AST whether a .py file defines public functions or classes, or declares a non-empty literal __all__ . pkg_mods uses it to find a package’s companion guidance module and its public submodules (including compiled extension modules) without importing them, skipping _private modules, skill.py , and plain re-export barrels.
True when path defines public functions or classes, or declares a non-empty literal __all__
Discover (guidance, mods) for a package without importing it, skipping _private and skill
Compiled extension modules and nested subpackages are also discovered without importing them.
norm_docs merges a skill’s __docs__ dictionary (flat lists or nested {desc?, items?, Sub: ...} dicts) with auto-discovered modules: an unlisted pkg.guidance is placed first under Docs , and remaining sibling modules go under API .
Normalize __docs__ and append auto-discovered guidance ( Docs ) and sibling modules ( API )
_pkg_doc_url reads [project.urls].Documentation from installed package metadata so doc(pkg.skill) shows the base URL for relative links without duplicating __base_url__ , and _fmt_docs renders a skill’s sections for _doc_module .
Return module top-level Markdown strings and public members in AST definition order
A module overview lists public classes, functions, and submodules. Each function entry includes its signature and first docstring line. Compare these three functions: one has no documentation, one has a parameter docment, and one has a longer docstring.
An overview line ending in … has more documentation than it shows. Read doc(callable) before using that operation to see its parameter docments and remaining docstring.
Class and namespace overviews inspect properties without evaluating them. An object’s custom _repr_markdown_ supplies its own display, including generated API documentation or a data-oriented result view.
mod_items walks a module’s AST in definition order while filtering by __all__ (or _xnames ). Any non-first top-level string literal (unless its first line is #| hide ) becomes a ('md', text) section block that _doc_module interleaves with class and function summaries; unmatched dynamic exports append at the end.
Set __pyskill_sigs__ = False when listings are too large for an overview. Set it at module level for a module, or on the class for an instance. If the object serves some names through __getattr__ , doc() hides only those and lists the rest. Otherwise it hides every entry except submodules. The overview keeps the docstring, reports how many entries it hid, and points to xdir , docfind and all=True .
A package docstring can explain which submodules a reader needs, as nbdev’s generated package documentation does. When the cleaned docstring has more than three lines, doc() hides the automatic submodule list. A default summary and documentation link do not meet that threshold. Pass all=True to show the list.
A skill module can declare __docs__ (mixing Python module-name strings resolved via AST and (title, href[, desc]) doc links) and optional __base_url__ . On pkg.skill modules, pkg.guidance is auto- under Docs and other documented sibling modules are appended under Optional . Non-skill packages with a .skill submodule show a one-line LLM docs pointer without importing .skill .
When __base_url__ is omitted on a skill module with relative links, doc() falls back to the package’s [project.urls].Documentation metadata.
Some APIs repeat a set of parameters across many functions. For example, rgapi shares walk filters across fd , ls , rg , and nbrg . Fastcore’s editing functions repeat parameters across variants for different source objects. Showing the same documentation on every overview line wastes space.
Declare __pyskill_params__ on the module as a dictionary from group names to parameter names. An overview can then show **group instead of those parameters. The ## shared params: section documents each group once, using docments from the first matching function.
Both functions expose the same root and hidden parameters. Their overview signatures reference one shared group with the original parameter docments.
A function must contain every parameter in a group to use its abbreviation. The types and defaults must match those of the first matching function. If a default differs, the overview keeps the parameters inline and emits a warning. That difference can matter: ls uses listing defaults where fd uses finding defaults.
A dynamic instance’s overview shows its members and class documentation. Read a method separately for any docments that its overview marks with … .
A dynamic namespace can also be callable. Its overview includes both the call signature and the other members:
A plain instance without a custom __dir__ uses its class’s names in xdir . You can inspect a client such as Kaggle’s KaggleApi this way without listing its internal state. This rule changes name discovery, not how doc displays an ordinary instance’s repr.
doc() recursively through xdir(o) , looking at submodules, classes, and functions, to depth n
docfind searches rendered documentation with a case-insensitive regular expression. It follows names from xdir recursively and returns matching paths with a summary line. Set n to limit the depth when exploring a large module.
Pass multiple objects to doc to read their documentation in one call. Each object has its own section, separated by a blank line. For example, read a module overview alongside a function you plan to call:
IPython’s ? (or ?? with source=True ) for obj , as Markdown
info_md renders what IPython’s ? shows, as Markdown: the signature with its docments and docstring, the file and line, and the type. With source=True it shows the source instead, like ?? . Unlike ? , it returns a string, so an agent can read it as a tool result:
An instance reports its type’s documentation and file, plus its own string form. A builtin has no file:
You don’t need to build a package to add a personal pyskill. Put its module in the user pyskills directory under XDG data . Pyskills adds that directory to sys.path . Package entry points remain an option for skills you distribute with a library.
Create xdg pyskills dir and .pth file if needed
Directory for user pyskills
pyskills_dir() gives you the user skill directory. ensure_pyskills_dir() creates it and adds it to the current sys.path . It also writes pyskills.pth in a writable site-packages directory for later Python sessions.
Virtual environments can the same XDG skill directory. Each environment needs the path setup to import those skills.
Clear modules starting with prefix from python caches
clear_mod removes entries whose names start with the given prefix from sys.modules . It also invalidates import caches. Enabling or disabling a skill uses this to make the import look it up again. Existing references to imported objects remain valid.
Write pyskill module name (docstring docstr , body code ) to the xdg pyskills dir, and create its dist-info entry point so list_pyskills() shows it at once
Enable pyskill name by creating its dist-info entry point
For an existing module, enable_pyskill writes a minimal dist-info directory with its entry point. To create the module too, call register_pyskill with its docstring and code. It writes the module in the user skill directory and creates __init__.py files for any nested packages.
Disable pyskill name by removing its dist-info entry point
disable_pyskill removes the skill’s dist-info directory from the user skill directory and clears its import-cache entries. The module file remains. delete_pyskill removes that file as well.
Delete pyskill name module files and dist-info
Call enable_local_skills(folder) when opening a dialog to find skills near that folder. It searches _pyskills/ in the opening folder and each ancestor. Public top-level .py files and packages supply skill entry points. A package uses its __init__.py as the skill module. Its other modules remain ordinary implementation modules. Names starting with an underscore are private.
The nearest folder wins when local folders contain the same name. A name that conflicts with an import outside those folders raises an error instead of replacing that import.
The opening folder stays fixed after chdir . Discovery rescans those locations for new files without executing skill code or writing metadata files. Imports still use Python’s module cache. Repeating activation for the same folder returns the existing finder. Use a fresh kernel to activate a different folder.
The finder supplies entry-point metadata in memory. It lists source files without running them and uses PathFinder to load a selected module. Its roots come from the opening folder, not the current working directory.
Enable folder-local skill imports and entry points for this interpreter.
Call once at host startup. Later cwd changes do not alter the scope. A different folder after activation raises ValueError; use a new kernel. Local skill names conflicting with other importable modules also raise ValueError. No skill code is executed during activation or discovery, and no metadata files are written.
Local skills appear in the same catalogue as installed skills. This example checks that discovery reads the description without importing the module. It removes the temporary finder afterwards.
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
