dogweather

dogweather

Here's how I'm coding Elixir with AI. Results are mixed, mostly positive. How about you?

First, the downsides. I periodically fire the AI. :smiling_face_with_tear:

^^ This was earlier today in Cursor AI, working with “Claude 4 Sonnet / Thinking”.

I bounce back and forth between Claude Code (w/ Claude 4 Opus) and Cursor AI (w/ Claude 4 Sonnet Thinking and ChatGPT o3). I find that each tool has its own ‘secret sauce’ of patterns for AI assistance that come through, even when using the same model with each. (I.e., w/ Claude 4 Opus in Cursor, it acts differently than Claude Code.)

My Claude.md File

This is what Claude Code writes and then reads. Here’s how I edited the start:


CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Engineering Principles we Follow

  • Security first. If we detect a security issue like mismatching user_id and customer_id, fail loudly.
  • Never, ever write demo code. Instead, we write a test that fails for a new feature or function. Then we implement the feature or function to production quality.
  • Fail fast
  • Use compile-time checking as much as possible.
  • No silent failures (So, e.g., don’t do this plan = Map.get(plan_map, frequency, "starter")
    instead fail loudly with an ‘unknown frequency’ error.
  • Make illegal states unrepresentable.
  • Lazyness is a virtue.
  • Every feature idea must overcome the YAGNI argument.
  • TDD

Definition of Done

A set of todos is only complete when ALL of the following conditions are met:

  1. All tests pass (mix test)
  2. Dialyzer passes (mix dialyzer)
  3. Credo passes (mix credo)

^^ That all works…most of the time. :sweat_smile: In Cursor, I have similar configuration in “User Rules”.

Now, my favorite hack that helps pair programming with AI: in every project, I create a /docs directory in the root. I have the AI assistants create documentation there, plans, and to do lists. Then I set it up as an Obsidian Vault. That’s pretty lightweight - Obsidian is basically a fancy markdown reader and editor. So in a nutshell, I “collaborate” with the AI this way.

I asked it to document what it learned — both for future AI sessions to refer back to, and for me. And then, of course, it’s very easy for me to edit and search:

I still have frequent very frustrating episodes: Claude Code deciding that a certain number of Credo warnings is acceptable. Or, the test failures are ok because it’s “demo code”. (What?? Who told you to write “demo code”?)

And I frequently need to steer the assistants in the right direction. The feeling I get is like working with a junior/mid-level programmer—but who never gets defensive and is happy to rewrite their code when asked. I do often have to do massive refactors and cleanups. But the AI did get me started, and got some kind of working code shipped.

So even though Elixir is more niche than Javascript or Python, I’m getting value from AI. When we’re really “clicking” well, I come back to my desk and see Claude Code’s latest message to me:

Most Liked

ErikNaslund

ErikNaslund

I’m just a lightweight Cursor user building webapps. I rarely ask the AI to code Elixir for me. I often find myself unhappy with the result, or it simply takes more time to steer the AI into the right direction than it takes to write the code myself. Adding the Tidewave MCP server helped improve the workflow with the AI agent quite a bit, but I still find it lacking.

The hallucinations and stubbornness of the AI is a real problem for me. I have had repeated “arguments” trying to convince it that a function it hallucinated doesn’t exist…just to have it go “Oh you’re right, I’m so sorry…here’s a version that is guaranteed to work: produces similar output with hallucinated functions still there

However, I do get real value out of Cursor when it comes to doing the stuff I don’t know that well - especially CSS. An oversimplified example might be me selecting a block of HTML, ctrl+k → “center this horizontally”, and Cursor spits out the correct Tailwind CSS to center the content (which varies based on context).

gtcode

gtcode

Claude doesn’t really know how to write OTP code by default. And I’m not a senior OTP dev by any means, not even a junior one yet. But, I have studied OTP, and with my limited background, it’s obvious that Claude really prefers (as of Sonnet and Opus 4) to write crappy OTP, when unrestricted.

Without explicit direction, Claude will sneak in brittle tests with concurrency issues, unsupervised processes, overuse of potentially runaway atoms, and all sorts of other beginner-level gotchas.

I’m working on enhancing credo checks to help enforce OTP compliance. You want to spawn? Is it supervised? Robust specification for OTP compliance are a must, for every context. The issues I’ve faced are also related to not having explicit definitions of the OTP design in-context. Going back to having the design worked out in advance, with the supervision tree worked out, clearly specified in the prompts, has been working better for me in testing. Going to try this approach again on the next go-around for my OTP app. Vibe coding for these scenarios isn’t really feasible at this time, except to prototype, sketch, or learn (how not to do things).

As for prompting, the best success I’ve had is to have Claude break down a complicated set of technical documents into self-contained prompts that, for each, assume no previous context, and include all required reading. Even then, I have to review the prompt file to ensure that all of the refs are self contained. Then it’s just a matter of ensuring all dialyzer/warnings/failures/credo issues are resolved before moving onto the next prompt. But, still, Claude will take shortcuts from time to time, so a skilled human reviewer ensuring Claude stays on track is still worth a lot.

Once the prompt is finished, I either /clear or just restart Claude Code from scratch for the next prompt.

Short prompts are better (in the sense of fewer TODO’s per prompt, all else equal). It might seem to take longer because now you’re recontextualizing on relatively smaller changes, but the shorter the context, the better. Less drift.

Another thought I had is that long sets of rules to follow don’t work consistently. Simply saying, “here are my OTP rules, build robust OTP” has mixed results. “Don’t use sleep to solve concurrency issues” works, until it drifts (happens faster than you’d expect, due to fighting the grain on Claude’s preferences). On my next go, the design will be worked out in advance with tight audit/checks for every prompt to ensure compliance. Just because all of your tests pass doesn’t mean the code is good. Just reiterating this main point: generalized guidelines at length will fall apart.

sevenseacat

sevenseacat

Author of Ash Framework

I love the idea of using an Obsidian vault for the docs!

Where Next?

Popular in AI / LLMs Top

DaAnalyst
Note: Not a strictly Elixir question but relates to us as well. A year or so ago I asked Grok (or ChatGPT, can’t remember) what would ha...
New
water
interesting thread Please wake me up when I can run it locally. I prefer privacy over convenience. This thread/fork split from: AI is...
New
FedericoAlcantara
Hi guys, I’ve been running Qwen locally for the last two weeks using an opencode + Ollama + qwen3.6:35b-A3B setup with q4_k_m quantizati...
New
bradley
Hi everyone, I’m curious how people in the Elixir community are approaching evaluation frameworks for AI applications, whether you’re us...
New
Cheezy
I am using Claude Remote Control for the first time this morning. AMAZING! I’m running one remote session on my iPad while running anothe...
New
benja123
I just wanted to say that I recently got back into Elixir after many years of barely touching it (not really by choice). Funnily enough, ...
New
NickGnd
Hey :waving_hand: Tidewave has just been announced by José Valim :fire: Watch Tidewave transform Claude Desktop into an agent by runni...
New
mudasobwa
I never put a “Donate” button on any of my OSS efforts. Not because I’m rich (I’m not.) I just don’t like the “donation” term. I feel lik...
New
FlyingNoodle
Hi all I have been doing some pretty intensive research over the last few days around agents/vibe coding. I tried some commercial offeri...
New
DaAnalyst
The new langauge/framework/library.. developers better start writing very exhaustive docs, ..and intent proving tests/examples, ..and int...
New

Other popular topics Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 127089 1222
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement