Tom Ho avatar

Tom Ho

June 9, 2025

Scanex, quick copy code for llms

Scanex, quick copy code for llms

I’m deep into a Rails project, bouncing around files in my editor, and whenever I hit a snag, I’d copy-paste a bunch of code into a Markdown file and paste it into ChatGPT or Gemini. It looked something like this:

“I’ve got this problem… Here’s my codebase: <code>…files…</code>

Rinse and repeat. It got old fast, and honestly, it felt like I was doing the same busywork over and over. Plus, I had a daily quota of free messages, so I wanted each one to count.

That’s when I thought, “Why not automate this?” So I built a little CLI tool called scanex. It scours your repo (or just the file you’re interested in), grabs all the related files, and dumps them into a Markdown file ready to plug into any AI chat. Yeah, I know—it sounds a bit silly. But trust me, it’s a huge time saver.

Here’s how it looks in action:

scanex --input="app/controllers/app/posts_controller.rb" > scanex.md
[scanex] plugin css ready
[scanex] plugin dockerfile ready
[…other plugins…]
[scanex] Repository root detected as: /path/to/rails_social_scheduler
[scanex] ⊕ app/controllers/app_controller.rb
[scanex] ⊕ app/controllers/concerns/media_formatting.rb
[scanex] ⊕ app/models/post.rb
[…more files…]
 processed 7 files

Boom—seven files in one go, with syntax highlighting for Ruby, ERB, SQL, you name it.

You might wonder, “Why not just tag the code in Cursor or ask directly in the Rails console?” Sometimes, copying into the ChatGPT UI feels snappier, and hey, it’s cheaper when you’re using OpenAI’s free-tier messages.


A couple of other scenarios

Inspecting logs with Kamal

When I’m using the kamal CLI to fetch logs, I’ll clone the entire repo locally, run:

scanex > kamal.md

Then I drop kamal.md into Google AI Studio and ask questions like “Can you review the logs from the last two days?” This way, I can quickly distinguish between 2d (two days) and 48h (forty-eight hours) flags—Ruby’s parsing vs Go’s parsing trips me up otherwise.

Refactoring React components

Let’s say I want to clean up a React component in my Rails app’s frontend. I’ll run:

scanex --input="app/frontend/components/app/posts/composer-form.tsx" \
       --exclude="components/ui" > composer_form.md

And it automatically picks up helper utilities, type definitions, and the nested previews I use for Facebook, Instagram, TikTok, etc.:

[scanex] ⊕ app/frontend/lib/utils.ts
[scanex] ⊕ app/frontend/components/app/posts/platform-preview-container.tsx
[…more TSX files…]
✅ processed 14 files

Then I hand composer_form.md over to ChatGPT to get feedback on cleanup, performance tweaks, or better TypeScript patterns.


I’m constantly refining scanex, so apologies in advance for any rough edges or the “stupid code.” If you’re curious to try it out:

npm install -g scanex

You can peek at the source on GitHub: https://github.com/darkamenosa/scanex

I’d love to hear any thoughts or suggestions you have. Thanks for reading!

About Tom Ho

Working on turnedninja.com and ninzap.com.
Posting at X: @hxtxmu.