classify-and-route
Skill1 starsChanged 5 months agoApache-2.0View on GitHub
Stage 3 of the pipeline. Detect a digitized work's content type and route it to the right target schema and stage-4 prompt set, using readable rules first and a small classifier only for ambiguous cases.
In this repository10 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- build-application-profileSkill
- compute-pass-rateSkill
- describe-collectionSkill
- export-for-repositorySkill
- preprocess-derivativesSkill
- refine-promptsSkill
- resolve-authoritiesSkill
- review-triageSkill
- tune-house-styleSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
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 53
Do not invent a routing field or a classification-confidence field on the record.
- Distinctive: line 91
Small classifier, for the residue only: When the rules leave an item ambiguous, a small, inspectable classifier proposes a content type.
- Distinctive: line 96
Never-fabricate extends to routing.
≈ “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
classify-and-route
Stage 3 of the seven-stage pipeline. You decide what each digitized work is as a form (photograph, document, artwork, object, audio, video, or a compound of these) and route it to the target schema and prompt set that fit that form. The decision is made from deterministic signals first, with a small classifier reserved for the cases the rules cannot settle, and every step is readable and adjustable by the institution.
This stage sits between pre-processing and generation:
[2] Pre-processing → [3] Classification & routing → [4] Generation (LLM)
derivatives, detect content type, first-pass record against
OCR, transcription, pick target schema + the routed schema + prompt set
format metadata prompt setSee ../../docs/architecture.md for the full pipeline and ../../docs/the-improvement-loop.md for how routing changes are classified as generalizable improvements or local overrides.
What it reads and what it sets
Reads:
- The institution's
application-profile.json(conforms to ../../schemas/application-profile.schema.json). Itstarget_schemaandcontrolled_vocabulariesare the institutional default. This stage refines that default per item. - Stage 1 intake evidence, which rides on the record as
collection_context.source_metadatain ../../schemas/metadata-record.schema.json: filename, folder path, accession notes, partial legacy records. - Stage 2 pre-processing output: MIME type, file extension, technical/format metadata (dimensions, duration, page count), and the presence of OCR text or an AV transcript.
Sets:
target_schemaon the metadata record. The record schema is closed, sotarget_schemais the one field this stage writes. It carries the routed schema string (for exampleDublin Core + VRA Core,PBCore, orMETS (compound) + per-constituent schemas) into stage 4.- The stage-4 prompt set: the base prompt
../../prompts/system/metadata-generation.v1.md
plus the matching modality overlay under
../../prompts/modalities/(for example a PBCore overlay for audiovisual works). The overlay adds the technical fields and the modality-specific guidance; the base descriptive logic is unchanged.
Do not invent a routing field or a classification-confidence field on the record. The record schema
is additionalProperties: false and will reject one. When you want to record why an item routed
the way it did, write it to the run manifest's notes
(../../schemas/run-manifest.schema.json), not to the record.
The routing table
These are the default rules. They are deliberately in the open so a cataloguer can read exactly why an item was routed and described the way it was, and can adjust the rules without a vendor in the loop. There is no opaque service call here.
| Content type | Primary signals | Target schema | Stage-4 prompt set |
| photograph | raster image MIME; photographic source metadata; no dominant text layer | Dublin Core + VRA Core | base + modalities/visual |
| document | image or PDF with a dominant OCR text layer; textual source metadata | Dublin Core (MODS where the institution catalogs at bibliographic granularity) | base + modalities/text |
| artwork | raster image; source metadata indicating a painting, drawing, print, or other visual-culture work | Dublin Core + VRA Core | base + modalities/visual |
| object | image of a three-dimensional artifact (sculpture, tool, garment, specimen) | Dublin Core + VRA Core | base + modalities/visual |
| audio | audio MIME; AV transcript present from stage 2 | PBCore | base + modalities/av |
| video | video MIME; AV transcript present from stage 2 | PBCore | base + modalities/av |
| compound | METS or IIIF manifest, multi-page object, or a directory of constituents | METS (structural wrapper) + per-constituent schemas | base + the overlay each constituent routes to |
The schema choices follow the metadata-standards reference: Dublin Core
is the interoperable baseline, VRA Core adds the Work/Image distinction visual works need, PBCore
carries audiovisual technical and descriptive fields, MODS suits bibliographic-granularity textual
material, and METS is the structural wrapper for compound objects. If a target schema you need is not
in the table, add it to your overrides/ routing rules and contribute the detection improvement
upstream if it is generalizable.
Rules first, classifier second
Resolve content type in this order, stopping at the first confident answer:
- Deterministic signals. MIME type and extension from stage 2 settle most items: an audio MIME routes to PBCore, a video MIME routes to PBCore, a multi-page or manifest-wrapped object routes to compound. A dominant OCR text layer distinguishes a document from a photograph of text.
- Source-metadata hints. Filename, folder path, and accession notes from stage 1 disambiguate the visual cases the MIME type cannot, for example separating a photograph from a digitized artwork or a three-dimensional object.
- Small classifier, for the residue only. When the rules leave an item ambiguous, a small, inspectable classifier proposes a content type. Model is a parameter here as everywhere: a lightweight local model is appropriate, since this is a coarse form decision rather than the descriptive generation in stage 4. The classifier proposes; the rules and the human dispose.
Never-fabricate extends to routing. An item the rules cannot settle and the classifier rates low-confidence is surfaced for a human routing decision rather than routed on a confident guess. A wrong route sends the wrong prompt set to stage 4 and corrupts the record before review sees it, so a held routing decision is cheaper than a confident error.
Classify by form
This stage is where hard rule 4 is enforced first. Classify a work by the form of the digitized object rather than by what the object depicts. A photograph of a building is a photograph (still image, routed to Dublin Core + VRA Core); the building is a depicted subject that stage 4 describes with AAT and TGN, and it is never the basis for the route. A scanned letter about a sculpture routes as a document, since the form is textual even when the subject is an object. Getting this wrong at stage 3 is the most consequential routing error available, because it sends the entire work to the wrong schema and prompt set.
Compound objects
A compound object is a structural whole made of constituents (a multi-page diary, a folder of related images, an oral-history recording with a companion transcript document). Route it in two parts:
- The whole gets a structural wrapper, METS by default, which links the constituents and carries the object-level descriptive record.
- Each constituent routes through this same table on its own form, so the pages of a diary route as documents and a photograph inside a mixed folder routes as a photograph.
Preserve the parent relationship on every constituent record via
collection_context.is_part_of so stage 4 describes each piece as part of the whole rather than as
an atomized item.
Local rules versus upstream contributions
Institution-specific routing rules stay in the adjacent overrides/ workspace: a rule that one
folder is always maps, or that a given accession is entirely glass-plate negatives, encodes one
collection's layout and should not ship to other institutions. Generalizable detection improvements,
for example better discrimination between a digitized document and a photograph of text, return to the
shared repo. See ../../docs/the-improvement-loop.md and
../../CONTRIBUTING.md for the test and the process.
Usage
This is the cited audiovisual case (sample user prompt 6). The routing decision is the first thing that happens: detecting audio routes the collection to PBCore and prepends the local transcription stage, so generation reads the transcript rather than attempting vision on the audio.
This collection is digitized oral-history audio (./collections/oral-histories/).
Run the transcription stage locally first (Whisper, nothing leaves this machine),
then generate metadata using the PBCore target schema instead of Dublin Core, pulling
description and subjects from the transcript. Flag any named people for LCNAF verification.Here the audio MIME type settles the content type by rule, the route sets target_schema to PBCore
and selects the modalities/av overlay, and the dependency on a stage 2 transcript is why the
transcription step runs before generation. The named-people flag is handled downstream by hard rule
5 in stage 4 and confirmed by the deterministic authority stage; this stage's only job is the form
decision and the route it implies.
A second, classify-specific example, for a mixed collection where the rules need to run per item:
Read the manifest at ./runs/2026-week-of-civil-war/manifest.json. For each item, classify
its content type from the MIME type, the OCR-text presence, and the folder path, then set
target_schema and the stage-4 prompt set per the default routing table. Where an item is
ambiguous, list it with the competing types and let me decide rather than routing it
automatically. Write the routing rationale for the ambiguous items to the run manifest notes.Output of this stage
For each work this stage produces:
target_schemaset on the record (conforming to ../../schemas/metadata-record.schema.json).- The selected stage-4 prompt set (base prompt plus modality overlay), passed to generation.
- An optional routing rationale for ambiguous or human-decided items, recorded in the run manifest's
notes(../../schemas/run-manifest.schema.json).
Items held for a human routing decision do not advance to stage 4 until the route is set.
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.

