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

PragTob
Hey everyone, this has been on my mind for some time and I’d love your input on it! TLDR: I feel like maps are superioer for storing and...
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 55125 245
New
rms.mrcs
A couple of days ago I was discussing with a friend about different approaches to write microservices. He said that if he was going to w...
New
PragTob
Hello everyone, I know we had quite some threads (read through lots of them) about background job processing but it remains a hotly deba...
New
tomekowal
Hey guys! I want to create a toy project that shows a chart of temperature over time and updates every 5 seconds. I feel LiveView is per...
New
AstonJ
Can you believe the first professionally published Elixir book was published just 8 years ago? Since then I think we’ve seen more books f...
New
paulanthonywilson
I like Umbrella projects and pretty much always use them for personal Elixir stuff, especially Nerves things. But I don’t think this is ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
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
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New

We're in Beta

About us Mission Statement