marcxrand

marcxrand

Rewriting Phoenix for Agent-Driven Development

A thought experiment I’m interested in people’s thoughts on: If we were designing Phoenix specifically for agents rather than humans, how would we approach it?

Some ideas:

Kill the macro DSLs, or make them introspectable.
router.ex with pipe_through, resources, scope are compact for humans but opaque for agents — you can’t grep for the actual URL /users/:id/posts because it’s synthesized at compile time. Instead use explicit route definitions:

route "GET", "/users/:id/posts", UserController, :list_posts,
  pipeline: [:browser, :authenticated]

An agent editing this never has to simulate macro expansion in its head. Same treatment for Ecto.Schema, use MyAppWeb, :controller, and the LiveView lifecycle macros — either eliminate them or require that every macro emit a .expanded.ex sibling file that agents can read.

Make use statements concrete.
use MyAppWeb, :controller is the single biggest source of “where does this function come from?” confusion. Replace it with explicit imports listing every symbol brought into scope.

One behavior per file, predictable paths.
Current Phoenix scatters a single feature across lib/my_app/accounts.ex, lib/my_app/accounts/user.ex, lib/my_app_web/controllers/user_controller.ex, lib/my_app_web/live/user_live.ex, templates, and tests. Agents do much better when a feature is a directory they can load entirely, ie features/users/

LiveView assigns as a declared struct.
Currently assigns are a loose map and you discover what’s in them by reading every assign/3 call in the module. Declaring defassigns as a typed struct up front means an agent editing a template knows exactly what’s available.

Deterministic generators with reversible diffs.
For agents, generators should produce a manifest so a later “regenerate with these options” command produces a clean diff rather than conflicts.

Eliminate the MyApp / MyAppWeb split, or formalize it.
The convention that business logic lives in MyApp and web concerns in MyAppWeb is real but unenforced. Either make it a hard compile-time boundary (web modules cannot be called from business modules, full stop) or drop it. Agents waste tokens figuring out which side of the line they’re on.

Where Next?

Popular in Discussions Top

matthias_toepp
I’d love to hear what people think about Wisp, the new Gleam web framework started by Gleam’s primary creator Louis Pilfold. Gleam, alon...
New
sashaafm
I’m trying to evaluate the best combo/stack for a BEAM Web app. Right now I’m exploring Yaws a bit, after having dealt with Phoenix for a...
New
owaisqayum
I have a sample string sentence = "Hello, world ... 123 *** ^%&*())^% %%:>" From this string, I want to only keep the integers, ...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New
Fl4m3Ph03n1x
Background This question comes mainly from my ignorance. Today is Black Friday, one of my favorite days of the year to buy books. One boo...
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
marciol
Please, let me know if this kind of discussion already took place in another topic . Hi all, how do you consider if is better to build ...
New
jer
I’ve been using umbrellas for a while, and generally started off (on greenfield projects at least) by isolating subapps based on clearly ...
New
jsonify
So, is Heroku the only free option for hosting Phoenix/Elixir at this point? I’m not ready to commit to paying monthly and was wondering ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New

Other popular topics Top

AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
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
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 53690 245
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

We're in Beta

About us Mission Statement