context-setup
Skill2 starsChanged 6 months agoMITView on GitHub
Guides correct setup of pydita's DitaContext for a DITA processing pipeline. Use this skill when you need to wire together resolveMap(), KeyspaceManager, DitavalFilter, and DitaContext, or when a pipeline is failing because of incorrect initialisation order, missing DITA-OT configuration, or a mismatched errors dictionary.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- conorbronsdon/agent-context-ostheir own version, first seen Oct 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- conorbronsdon/agent-context-os★ 30same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository18 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- dita-best-practicesSkill
- ditaval-helperSkill
- error-handlingSkill
- generate-bookmapSkill
- generate-ditamapSkill
- generate-dita-topicSkill
- generate-keyrefsSkill
- keyspace-debugSkill
- map-resolveSkill
- pdf-to-ditaSkill
- refactor-dita-contentSkill
- review-dita-guideSkill
- validate-bookmapSkill
- validate-ditamapSkill
- validate-dita-topicSkill
- visitor-extendSkill
- xslt-dita-helperSkill
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
- Very specific: line 84
Use one errors = {} dict and pass it to every pydita call.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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.
Files
Overview
DitaContext is pydita's central processing object. It bundles:
- a
KeyspaceManager(key spaces built from the resolved map) - a
DitavalFilter(conditional filtering) - a shared
errorsdict (error accumulation across all pydita calls) - an optional
mapContextelement (current position in the map tree)
Initialisation must follow a strict order — every step depends on the output of the previous one.
Canonical setup pattern
from pydita import resolvemap, xmlutils
from pydita.ditaval import DitavalFilter
from pydita.keyspacemgr import KeyspaceManager
from pydita.ditacontext import DitaContext
# 1. Shared error collector (pass the same dict everywhere)
errors: dict = {}
# 2. Optionally load a DITAVAL filter
ditaval_filter = DitavalFilter(errors=errors)
# — or load from a file (pass a list of paths):
# ditaval_filter = DitavalFilter(ditavalFiles=["path/to/filter.ditaval"], errors=errors)
# 3. Resolve the root map (flattens the map tree into a single document)
resolved_map = resolvemap.resolveMap(
"path/to/root.ditamap",
ditavalFilter=ditaval_filter,
errors=errors,
debug=False,
)
# 4. Build the key space manager from the resolved map
ksm = KeyspaceManager(resolvedMap=resolved_map, errors=errors)
# 5. Assemble DitaContext
ctx = DitaContext(
keySpaceManager=ksm,
ditavalFilter=ditaval_filter,
errors=errors,
)DitaContext constructor parameters
| Parameter | Type | Default | Notes |
keySpaceManager | KeyspaceManager | required | Must be pre-populated |
keySpace | KeySpace | None | Defaults to ksm.getRootKeyspace() |
mapContext | Element | None | Current <topicref> or map element |
ditavalFilter | DitavalFilter | None | Defaults to a pass-through filter |
errors | dict | {} | Always pass the same dict you used in steps 2–4 |
debug | bool | False | Enables verbose print output |
Common mistakes
Wrong order: KeyspaceManager built before resolveMap
# WRONG — KeyspaceManager receives an unresolved ElementTree
ksm = KeyspaceManager(resolvedMap=etree.parse("root.ditamap"))KeyspaceManager expects a map that has already had submaps inlined by resolvemap.resolveMap(). Building it from a raw parse result silently produces an incomplete key space.
Separate errors dicts
# WRONG — errors reported during resolveMap() are not visible in DitaContext
resolved_map = resolvemap.resolveMap("root.ditamap", errors={})
ctx = DitaContext(ksm, errors={})Use one errors = {} dict and pass it to every pydita call.
Missing DITA-OT
resolveMap() calls xmlutils.getDTDAwareParser() which requires DITA-OT. If DITA_OT_DIR is not set:
KeyError: 'DITA_OT_DIR'Set the environment variable or add dita.ot.dir=/path/to/dita-ot to ~/.build.properties.
Updating the context during processing
# Switch the active key space (e.g., when entering a keyscoped submap)
ctx._keySpace = ctx.getKeyspaceManager().getKeyspaceByMapUri(submap_uri)
# Replace the DITAVAL filter
ctx.setDitavalFilter(new_filter)
# Record an error from within processing code
ctx.recordError("my-key", exception, operation="myFunction()")
# Enable debug logging
ctx.setDebug(True)Checking for errors after processing
from pydita import loggingutils
if ctx.getErrors():
print(loggingutils.reportErrors(ctx.getErrors(), showTraceBack=True))See also
map-resolve— detailedresolveMap()API referencekeyspace-debug— how to inspect and debug key spaceserror-handling— full error model reference
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
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.

