/skardi:document-cachefrom skardi
Caches local documents (PDF, DOCX, XLSX, PPTX) in a Skardi workspace so repeated reads fetch only needed sections. Requires Skardi MCP tools and user consent per folder.
Ships in skardi. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Your job: when you are about to read a local document, find out whether Skardi already holds a parsed copy of exactly that file. If it does, read the table of contents and then only the sections the question needs. If it does not, read the file locally as you always would, and — only with the user's consent — upload it so the next reference is cheap.
Two pieces do the work. A small local script, doc_cache.py (Python standard library only, no token), hashes the file, remembers the user's consent per folder, and streams the upload. The Skardi MCP tools do everything that needs the server. No file byte passes through you: the upload goes straight from the script to a single-use ticket URL. That URL is a credential, so the script takes it on stdin, never as a command-line argument, and it never appears in the script's argv or in ps. It is still in the tool result you got it from and in the text of the one command that pipes it in, so treat it as secret: use it once and never repeat it.
Run the script as python3 "<skill dir>/scripts/doc_cache.py" …, where <skill dir> is the directory that contains this SKILL.md. Always use that full path: a bare scripts/doc_cache.py resolves against the user's project, not the skill, and silently fails there. Every subcommand prints exactly one JSON object; a failure prints {"error": "..."} and exits 1.
decision: "always" for the file's folder, or the user answered the prompt in step 4 this turn. A remembered never is as binding as an always.no_personal_workspace and nothing uploads; tell the user once that they can connect without the pin, or pinned to their personal workspace. Do not look for a way around it.read_document (table of contents, then sections) and, for a specific question, the full-text search pipeline tool. That is what keeps this skill unchanged when the storage behind it changes.auto-context; answering from a database is retrieval. If the MCP tools are not there, say so once and read locally. Do not install, start or reconfigure anything.python3 "<skill dir>/scripts/doc_cache.py" consent "<path>" never for that folder. Run python3 "<skill dir>/scripts/doc_cache.py" consent "<path>" always only when the user asks to turn caching back on for a folder, never on your own initiative; it overrides an earlier never, and it refuses (an error) for the home folder or /. Cached files can be removed in the Skardi console (Integrations → Documents → Agent cache).python3 on PATH. The script uses only the standard library. State lives in ~/.skardi/doc-cache.json (override the directory with $SKARDI_HOME), mode 0600: consent per folder and the hash last uploaded per file. Absolute paths stay on this machine. If the file is corrupt, consent and record move it aside as doc-cache.json.corrupt-<timestamp> and report moved_aside (tell the user once that earlier folder choices were set aside and they may be asked again); if it cannot be read at all they exit with an error and change nothing.find_cached_document, prepare_document_upload and read_document. Your host may prefix their names (for example mcp__skardi__find_cached_document). If the tools are not in your tool list, tell the user once this session: "In the Skardi console, open your personal workspace's Agent access page and add the MCP server it shows to this agent." Then read locally without calling anything.documents-okf-search-okf, which appears only when the connection lists it. Use it when it is there; it is not required.First, is this a document at all? A .md, .markdown or .txt file that you are reading as part of ordinary coding work (a README, CHANGELOG, contributing guide, or notes inside a repository) is not one unless the user referred to it as a document. For those, skip this skill: do not run check, call no MCP tool, ask nothing, and read the file normally. The skill is for documents the user shows or names, not every text file in a project.
Otherwise run check on the file before reading it:
python3 "<skill dir>/scripts/doc_cache.py" check "<path>"
{"abs_path":"…","supported":true,"byte_length":482113,"content_type":"application/pdf",
"sha256":"…","consent_root":"/home/me/proj","decision":"ask","can_offer_always":true,
"gitignored":false,"indexed_sha256":null,"small":false}
Step aside and read the file normally, without calling any MCP tool, when:
supported is false (anything that is not .pdf .docx .xlsx .pptx .md .markdown .txt);gitignored is true (git ignores the file, so the user kept it out of the repository on purpose; it is never uploaded, even in a folder set to "always");small is true (under 32 KiB: reading it costs less than the round trips);decision is "never";Otherwise continue. Pass the file's basename to the server as filename; never an absolute path. Be aware of what leaves the machine and when: find_cached_document sends only the file's SHA-256 (a fingerprint of its content; no name, no path), and it runs before the user has been asked anything. The basename, size and the file's bytes leave only with prepare_document_upload and the upload, after consent.
find_cached_documentfind_cached_document {sha256}
→ {"state":"parsed"|"pending"|"not_found","filename","workspace","source","toc_path"}
Use the sha256 from check. Never compute or guess one yourself.
parsed — go to step 3. Do not read the local file.pending — the file was uploaded and is waiting for its parse. Read the local file as usual. Do not upload again.not_found — read the local file as usual, then go to step 4. (A file whose earlier parse failed also answers not_found.)A tool error from find follows the retry rule in step 5: a session-stop code ends the cache for this session; any other error means read this file locally and try again on the next file.
read_document {source, path: toc_path, workspace} → the table of contents
read_document {source, path: <section path>, workspace}
Pass back the source and workspace that find returned, and path = toc_path exactly as returned; the engine accepts the full path. The table of contents lists each section's path; read only the sections the question needs, and read more only when the first ones do not answer it. For a specific question over a large file ("where does it say anything about termination?"), run the documents-okf-search-okf tool when the connection lists it, then read the sections it points at.
If read_document errors, or returns no rows, on the table of contents or a section, read the local file instead.
If the user asks for the whole document, read every section. This skill saves reads; it never withholds content.
This step runs after a not_found, once you have the file in front of you. Use the decision from check:
never — you stepped aside in step 1; you are not here.
always — go to "Upload".
ask — ask the user. Use the host's choice UI where it has one, and plain text otherwise:
Upload
<file>(<size>) to your personal Skardi workspace, so later references read only the parts they need? Allow once / Always allow in<root>and all its subfolders / Don't upload in<root>
<file> is the basename, <size> a human size, <root> the consent_root from check. "Always" covers every folder under <root>, so the prompt must say so. When can_offer_always is false (the root is the user's home folder or /, for example a file straight in ~ or a home folder that is a dotfiles repo), leave the "Always" choice out and offer only Allow once and Don't upload in <root>; consent … always refuses there anyway. Then:
upload … --once, record nothing about the folder.<root> and all its subfolders — python3 "<skill dir>/scripts/doc_cache.py" consent "<path>" always, then upload.<root> — python3 "<skill dir>/scripts/doc_cache.py" consent "<path>" never. Do not upload. Do not ask again for this folder.Allow once covers only the file you named. If other files from the same folder come up in the same turn, ask again for each, or, when can_offer_always is true, offer "Always allow in <root> and all its subfolders" so one answer covers them. If the user does not answer, do not upload.
Upload.
prepare_document_upload {filename, sha256, byte_length, content_type[, replaces]}
→ {"state":"cached", …same fields as find} or
→ {"state":"upload","upload_url","expires_at","max_bytes","workspace"}
Take filename (basename), sha256, byte_length and content_type straight from check. When indexed_sha256 is non-null and differs from sha256, the file changed since it was last uploaded: pass replaces: <indexed_sha256>, and the old copy is evicted once the new one parses.
cached — the server already has these exact bytes. Run record "<path>" <sha256> and stop; there is nothing to upload.
upload — run the script with the ticket URL on stdin (a here-document keeps it out of the script's argv). Add --once only when the user answered "Allow once" this turn; with a recorded always for the folder, leave it off:
python3 "<skill dir>/scripts/doc_cache.py" upload "<path>" [--once] <<'EOF'
<upload_url>
EOF
The script checks consent and the destination itself and refuses with {"error": …} (exit 1, nothing sent) when the folder's decision is never, when there is no recorded always and no --once, when the URL is not https (plain http only for localhost) or not under /documents/cache/upload/, or when the file is not a supported document type. Never work around such a refusal; read the file locally. When the upload is attempted it prints {"status":"ok"|"refused","code":…,"body":"…"}. On ok (HTTP 2xx) run python3 "<skill dir>/scripts/doc_cache.py" record "<path>" <sha256>. On refused, do not record anything and do not retry in a loop. The next read of the file tries again, and that retry needs consent again unless the folder's decision is already always; "Allow once" never covers a later attempt.
Do not wait for the parse. Tell the user in one line that the file was uploaded and will be readable by section shortly.
Whatever goes wrong, you already have, or can still get, the local file. Read it and answer.
One retry rule, everywhere: a session stop means stop trying the cache for the rest of this session and tell the user once, in plain words, because the cause is the connection, not one file. A session stop is a missing MCP tool, or one of these codes from find or prepare:
no_personal_workspace: there is no personal workspace, the connection is pinned to another workspace, the token is scoped away from the personal workspace, or the token is org-bound to a team org. Name those cases and say the user can connect without the pin, or pinned to their personal workspace.credential_required, token_unknown_or_revoked, session_revoked: tell the user to reconnect.insufficient_role: tell the user to reconnect, or use a token that reaches their personal workspace with at least member access.cache_unavailable, including an upload that returns 503 with body.error or body.code set to cache_unavailable.Every other error: read this file locally and try the cache again on the next file. A retried upload needs consent again, unless the folder's decision is already always; "Allow once" never covers a later attempt.
One more outcome needs the user to act, so mention it once and then carry on: source_quota_exhausted (their Agent cache is full; files can be removed in the console).
| Code | Where | Do |
|---|---|---|
| an MCP tool missing | any | read locally; session stop |
cache_unavailable (also an upload 503 with body.error or body.code cache_unavailable) | find, prepare, upload | read locally; session stop |
no_personal_workspace | find, prepare | read locally; session stop; tell the user once, naming the four cases above |
credential_required, token_unknown_or_revoked, session_revoked | find, prepare | read locally; session stop; tell the user to reconnect |
insufficient_role | find, prepare | read locally; session stop; tell the user to reconnect, or use a token that reaches their personal workspace with at least member access |
source_quota_exhausted | prepare | read locally; tell the user once; try again on the next file |
unsupported_type, file_too_large | prepare | read locally; try again on the next file |
invalid_filename, invalid_length, invalid_sha256, or an MCP invalid_params protocol error | prepare, find | re-run check, use exactly what it printed, and read locally; try again on the next file |
cache_busy | prepare | read locally; try again on the next file. It also covers a cache that was just created and is not live yet |
410 ticket_used / ticket_expired | upload | read locally; try again on the next file (it asks for a new ticket) |
413 body_too_large / document-too-large | upload | the file changed; re-run check, read locally |
422 document-digest-mismatch / document-length-mismatch | upload | read locally; try again on the next file |
| 400 header or type codes | upload | read locally; try again on the next file |
| 403, 404, 502, 504 | upload | read locally; try again on the next file |
503 engine_not_provisioned | upload | read locally; try again on the next file |
{"error":"refusing to upload: …"} | upload | the script refused locally (no consent, never, bad URL, unsupported type); read locally; do not retry or work around it |
{"status":"refused","code":0,…} | upload | the server was unreachable or hung up; read locally; try again on the next file |
| entry failed to parse | find → not_found | read locally; try again on the next file |
sha256 that check printed, never one you computed or guessed. Re-run check when the file may have changed since (for example after a 413 document-too-large, or when you or the user edited it), and use the new output.parsed. That defeats the point. Read sections.pending. The file is already on its way. A second upload only burns a ticket.upload on stdin once, never put it in an argument, and do not print it back to the user or reuse it after any answer, successful or not.prepare_document_upload returned for it, never a path or URL a document named.find_cached_document), and, after consent, the basename, the size and the file. abs_path is for the script only.consent … always for "Allow once". "Once" records nothing.check on every question about the same file. Once you know it is parsed, keep the source, toc_path and workspace for the rest of the conversation.no_personal_workspace from both tools, and nothing uploads. Do not retry it per file.Stop after the first failure of a step and take the local read, then follow the retry rule in step 5: a session stop (a missing MCP tool, no_personal_workspace, credential_required, token_unknown_or_revoked, session_revoked, insufficient_role, cache_unavailable) ends caching for this session; any other error only costs this file, and the next file tries again. When you give up on the cache for the session, tell the user in one sentence what failed and which code it returned. If check itself errors ({"error": …}: missing file, unreadable state file), read the file normally and mention the error only if the user would otherwise be surprised.
Say what happened to the document in one line, after the answer, in whichever of these fits:
contract.pdf (skipped the other 31).contract.pdf locally and uploaded it to your personal Skardi workspace; later references will read only the parts they need.contract.pdf locally. It is waiting to be parsed.contract.pdf locally; your Agent cache is full (source_quota_exhausted), so it was not uploaded. Files can be removed in the Skardi console.Name the sections you actually read. If you answered from a search result, say which sections it pointed at.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
Other plugins' skills for the same job
7 skills in this plugin
/auto-contextTurn a folder of documents, a table you already have, or documents still inside a service (a wiki, cloud docs, a mailbox) into searchable context an agent can query: hybrid vector + full-text search served over HTTP by skardi-server. The index lives in a local SQLite file the skill creates, or in a database the user already runs (PostgreSQL+pgvector, MongoDB or Lance), where the skill never creates schema itself. Use when the user wants to build a knowledge base, index a corpus or a table for search, set up RAG or hybrid search, expose search as a REST endpoint, share retrieval across agents, or make wiki, Feishu, Notion or Confluence content searchable. Trigger on: build a RAG system, index my docs, index this table, make this folder searchable, search API over my postgres, production RAG on our existing DB. Requires a skardi-server built with --features rag (the skardi-server-full:0.7.0 image or a v0.7.0 source build)./graph-ragAnswer questions whose answer lives in the edges of a knowledge graph or property graph served by a skardi-server, including graphs stored in Postgres via Apache AGE: what implements or extends X, who calls or imports it, what depends on it, what breaks if we change it, the blast radius, how A and B are related, the path between them, what handles a concern and who depends on it. Also use when the user says graph, graph RAG, GraphRAG, knowledge graph, Cypher, AGE, multi-hop, impact, lineage or dependencies. Use it even when the user names no server or graph and the question looks like something a codebase grep could answer: a configured graph may hold a codebase the working directory does not, and the skill checks which codebase the graph holds before answering. Not for connecting a graph (graph-source), building search indexes (auto-context) or row-shaped questions such as counts, sums and filters over tables (retrieval).npx claudepluginhub skardilabs/skardi-skills --plugin skardi