Telling a skill exactly which files it may read
My literature note skill in Claude Code was reading through my notes vault for every paper, so I had it rewritten to read only its instructions, the template and the PDF text.
I keep literature notes on journal articles in my Obsidian vault, and I have a skill in Claude Code that writes them from the PDF. A skill is a folder with a file of written instructions in it, and Claude follows those instructions when I run the command. I drop PDFs into an inbox folder and run the command, and it writes a note for each paper that does not have one yet.
This time there was one new paper waiting, a 33 page review. Claude read the whole paper. Then it went through my vault to pull context for a Connections section in the note, and on wrap up it also added a dated entry to one of my hub notes and made a Log section there, because the hub did not have one.
I was watching the run and I noticed the agent reading a lot of files. Every file it reads costs tokens. I think a skill reads whatever it can reach unless its instructions say what to read. So I told Claude what I want from this skill. I just want it to extract the data from the PDF and make the Markdown file in the literature folder inside my vault. I do not want it to consume any more tokens than it absolutely has to to do the job accurately.
Claude rewrote the skill so that it reads only its own instructions, the note template and the text of the PDF. It also added a small script, extract.sh, that pulls the text out of the PDF, and it saved the rule to its memory.
It had tested the extraction step on the PDFs in the inbox but not the full rewritten skill. So I ran the command again, and it wrote a note from the one PDF that did not have a note yet. I did not measure the tokens before and after.
Sources
- Anthropic (n.d.). Extend Claude with skills. Claude Code documentation. https://code.claude.com/docs/en/skills