Published 2026-11-18.
Last modified 2026-11-23.
Time to read: 2 minutes.
llm collection.
Agentic LLMs are terrific to work with, but there are times when you can make more progress using non-agentic LLMs.
- Agentic LLMs are often slow and relatively stupid.
- Powerful non-agentic LLMs, like the Gemini app are often free, or have generous free usage limits, but they are very fast and produce good code.
The problem is that non-agentic LLMs are not very good at working with directories of files. It can be awkward to use them for this purpose.
When programming, most of the files that need to be communicated just contain
text. My solution is low-tech: a tiny script called spew that
serializes files and directores to a single file for upload to a chat session.
Use spew to serialize a directory of files into a single file, and then
upload that file to a chat session. The LLM will automatically read the file and
will know the contents.
Long paste buffers are truncated by many LLMs, so save to a file and upload that one file to the chat session. The LLM will read the file and know the contents.
Here is an example that spews the contents of docs/,
lib/, and spec/ to a file called /tmp/spew.txt
$ spew Gemfile README.md docs/ lib/ spec/ > /tmp/spew.txt
If you only have a few files and they are not too long, and you are running
WSL, use clip.exe to copy the output to the clipboard and paste
it into the chat session.
$ spew Gemfile *.gemfile README.md | clip.exe
The output of spew looks something like this:
=== Gemfile === line 1 of docs/file1.md line 2 of docs/file1.md ... last line of docs/file1.md === README.md === line 1 of README.md line 2 of README.md ... last line of README.md === docs/file1.md === line 1 of docs/file1.md line 2 of docs/file1.md ... last line of docs/file1.md === docs/file2.md === line 1 of docs/file2.md line 2 of docs/file2.md ... last line of docs/file2.md === lib/file1.rb === line 1 of lib/file1.rb line 2 of lib/file1.rb ... last line of lib/file1.rb === spec/file1_spec.rb === line 1 of spec/file1_spec.rb line 2 of spec/file1_spec.rb ... last line of spec/file1_spec.rb
Scripting
This Bash script searches for files that violate my coding standards for using Nokogiri/XML/XPath to construct value classes. Those files are then spewed to the LLM in the sky that knows all, sees all.
#!/usr/bin/env bash
set -euo pipefail
# Run from the repository root
REPO_ROOT="${1:-.}"
OUT_FILE="${2:-/tmp/spew.txt}"
cd "$REPO_ROOT"
# Select Ruby files under lib/ whose content still references Nokogiri/XML/XPath
# or stores raw @element/@xml state, then serialize them with spew.
mapfile -t MATCHED_FILES < <(
grep \
-rlE 'Nokogiri|XML::Element|\b(at_)?xpath\b|@(element|xml)\b' lib/ \
--include='*.rb' | sort
)
if (( ${#MATCHED_FILES[@]} == 0 )); then
echo "No matching files found." >&2
exit 1
fi
printf 'Matched %d files:\n' "${#MATCHED_FILES[@]}"
printf ' %s\n' "${MATCHED_FILES[@]}"
spew "${MATCHED_FILES[@]}" > "$OUT_FILE"
echo "Wrote $OUT_FILE ($(wc -l < "$OUT_FILE") lines)"
For the curious: mapfile (also aliased as readarray)
is a built-in Bash command that reads lines from standard input or a file
descriptor directly into an indexed array variable. It is significantly faster
than using a traditional while read loop. The -t
option reads a file into an array, stripping trailing newlines.
Here is the output:
$ bash findem Matched 52 files: lib/als_diff/als_diff.rb lib/als_explorer/tree_builder.rb lib/als_nodes/als_nodes.rb lib/als_release_notes/als_release_notes.rb lib/als_report/als_report.rb lib/als_to_version/als_to_version.rb lib/als_to_version/live_set_converter.rb lib/als_to_xsd/als_to_xsd.rb lib/als_to_xsd/xsd_builder.rb lib/als_validate/als_validate.rb lib/common/xml.rb lib/live_set/als_file.rb lib/live_set/demo_sets.rb lib/live_set/live_xml_writer.rb lib/live_set/model/base_classes/live_abstract_recordable_track.rb lib/live_set/model/base_classes/live_abstract_track.rb lib/live_set/model/collections/live_assets.rb lib/live_set/model/collections/live_audio_take_lanes.rb lib/live_set/model/collections/live_audio_tracks.rb lib/live_set/model/collections/live_automation_envelopes.rb lib/live_set/model/collections/live_macro_controls.rb lib/live_set/model/collections/live_midi_take_lanes.rb lib/live_set/model/collections/live_midi_tracks.rb lib/live_set/model/collections/live_return_tracks.rb lib/live_set/model/collections/live_scenes.rb lib/live_set/model/collections/live_tracks.rb lib/live_set/model/leaves/live_asset.rb lib/live_set/model/leaves/live_audio_clip.rb lib/live_set/model/leaves/live_audio_take_lane.rb lib/live_set/model/leaves/live_audio_track.rb lib/live_set/model/leaves/live_automation_envelope.rb lib/live_set/model/leaves/live_automation_event.rb lib/live_set/model/leaves/live_clip_place.rb lib/live_set/model/leaves/live_clip_settings.rb lib/live_set/model/leaves/live_device.rb lib/live_set/model/leaves/live_group.rb lib/live_set/model/leaves/live_macro_control.rb lib/live_set/model/leaves/live_midi_clip.rb lib/live_set/model/leaves/live_midi_take_lane.rb lib/live_set/model/leaves/live_midi_track.rb lib/live_set/model/leaves/live_parameter.rb lib/live_set/model/leaves/live_scene.rb lib/live_set/model/other/header_block.rb lib/live_set/model/other/live_automation.rb lib/live_set/model/other/live_midi_controller_range.rb lib/live_set/model/other/live_mixer.rb lib/live_set/model/other/live_target.rb lib/live_set/model/other/live_track_facts.rb lib/live_set/model/singletons/als_model.rb lib/live_set/tx/live_11_and_12.rb lib/live_set/tx/live_version_converter.rb lib/live_set/tx/live_versions.rb Wrote /tmp/spew.txt (7755 lines)