I went crazy and tried to do some hard stuff because I'm an adult and can just do things

I want to combine 2 things that I love more than anything.

  1. Crystal
  2. AI

Not necessarily in that order.

I vibe code with Crystal all the time, it’s been perfect because of the type system, but the syntax is clean and makes it easy for Claude to mimic the patterns within the files easily. The rate of writing Ruby by accident from the models has also gone down a lot. I’m very grateful for these advancements!

So I decided to do 2 things, that are only related by Crystal and AI.

  1. I forked shards and I added some tooling to allow writing documentation for agents within a library. So now you can write docs for your peferred AI coding assistant and then pass along the skills, subagents and MCPs for that library. The shards-alpha project is what I called it so that there is an easy but different command from the real shards, this way you can try it out without disrupting the normal shards installation. This is just for testing the idea out as my workflow improves. I think others will enjoy the level of plug-and-play that I have achieved with this.

shards-alpha

If you want to try it:

# Via Homebrew
brew tap crimson-knight/shards
brew install shards-alpha

# -- OR --

# Install from source
git clone https://github.com/crimson-knight/shards.git

cd shards
crystal build src/shards.cr -o bin/shards-alpha --release
# Copy bin/shards-alpha somewhere on your PATH or symlink it into your /local/usr/bin

Then in your project:

# Set up Claude Code with compliance skills + agents
shards-alpha assistant init

# Use it like normal shards — everything is compatible
shards-alpha install
  1. I went really crazy and decided to see if I could create a ralph-loop and get Claude Opus 4.6 to figure out how to implement WASM 3.0 as a compile target with garbage collection.

And it works! There’s support for all kinds of features that are part of the spec, but I’m still working through linking all of the C libraries that we depend on being linked/compiled into the WASM target. This took over six hours while running on a loop and at one point it gave up because it couldn’t figure out the path it was on. I had it think from a more first-principles perspective about it’s original architectural decisions and then it realized it had made an assumption too briefly–found the fig that worked that unlocked GC support–and it chugged away until done from there.

You can check it out here Implement WebAssembly (wasm32-wasi) as a compile target by crimson-knight · Pull Request #2 · crimson-knight/crystal · GitHub

My plan is to experiment with building full stack apps with Crystal so that I can create a mono repo, and serve the web API and the entire browser app from Crystal+Amber.

What a world we live in. This is just so cool.

6 Likes

The Exception Handling (EH) part is interesting.

It outlines a limitation in Crystal: while we can declare a global function symbol with fun name (where name isn’t mangled), we can only reference an external symbol with $name in a lib definition, we can’t declare one (AFAIK). Maybe we can though inline assembly?

We again miss an option to specify the exception model in TargetOptions (EH is disabled by default for WASM), and that’s probably the only option we need to set through a new LLVMTargetMachineOptionsSetExceptionModel function (and enum) that should be proposed upstream.

I’ll see if I can take your feedback and provide it to another Claude session next week.

My real purpose for trying something so hard and abstract was to see how far I can push the $200/mo subscription, and thus far I’ve used about 50% of my weekly limit across all models.

My next insane adventure is to see if I can get maximized parallelism for compiling and doing incremental compilation. That’s what is currently chugging away. Maybe we’ll see if it’s successful in another 4-5 hours.

1 Like

It’s definitely possible to do lol Enable parallel compilation by default in release mode by russ · Pull Request #1 · russ/crystal · GitHub :joy:

I did it, and I made a brew formula for others to test out.

1 Like

I took your feedback into consideration and was able to have Claude integrate it into the proposed WASM solution on that same PR .

Please take a look.

I’ve built off of this PR to also improve compile times.