•
6 min read
Improve the Prompt, Not the Code: Cowork and Skills From Working Examples
How Failed Attempts and Working Examples Become Clearer Instructions and Reusable Skills

Hello Curious Coders,

You ask an agent to build a word game, and it puts the dictionary inside a hard-coded tuple. You wanted curated word lists, but the prompt never said where the words should live, so the model picked the most direct option it had. The generated code tells you exactly which instruction was missing.

In the last post, we threw that branch away. Deleting code feels like losing work, and it only pays off if the next attempt is actually different. The code we threw away can’t make it different. What changes the next attempt is the prompt.

That is the move this post is about. When a result doesn’t fit, you don’t fix the output. You improve the input and run it again. Bruce does this twice in class: once for the dictionaries, and once for a component pattern that ends up as a reusable skill.

Separate the Content From the Mechanism

The dictionary problem contained two jobs. Someone needed to research the words, and the application needed a way to load them. A hard-coded tuple tangled those responsibilities together.

So Bruce gave each job a home. He wrote the rules into the project’s architecture document first: word games get separate answer and guess dictionaries, themes generally restrict answers, and guesses can come from a shared dictionary. An answer must also be accepted as a guess.

Then the seeding requirement became much more specific. Build a mix task that reads separate answer and guess files from the idiomatic place in priv. He ended the prompt with two words that matter more than they look: “prompt for details.” That invites Claude to ask questions before it guesses.

The pull request came back with what we wanted. The task read both paths and loaded the records with insert_all, while small demo lists sat in priv, separate from the code that loads them. The word lists could change without rewriting the loader.

Notice where the detail came from. Nobody sat down and imagined the perfect prompt. The failed branch told us which decisions the first prompt had left open, and the second prompt closed them.

The real word lists were research, not coding, so Bruce sent that work to Claude Cowork, which can run longer tasks in the background and keep memory across conversations. He pointed it at the architecture document for the themed-dictionary rules. The first result still needed steering, so he directed it toward the New York Times version for a more plausible standard list. The prompt carried the architecture, and the output landed in the right shape.

🎯 Join Groxio's Newsletter

Weekly lessons on Elixir, system design, and AI-assisted development – plus stories from our training and mentoring sessions.

We respect your privacy. No spam, unsubscribe anytime.

Give the Model a Working Example

The UI needed a less familiar pattern. Bruce wanted one place for state, the parent LiveView socket, with the logic still split into pieces. Left alone, Claude tends to reach for classic live components, which keep state in a second place and invite conflicts.

He could have described the pattern in a long prompt. Instead, he built a tiny counter first and refined it in small steps. First, push the event handling into a component module and make the LiveView delegate matching events, explicitly excluding live components. Then delegate mount too, so the counter owns its own initialization.

Here is the shift, starting with where initialization used to live:

# Before: initialization lives directly in the LiveView
def mount(_params, _session, socket),
  do: {:ok, assign(socket, :count, 0)}

And after the refinement:

defmodule MyAppWeb.CounterComponent do
  use MyAppWeb, :html

  def mount(socket), do: assign(socket, count: 0)

  def handle_event("counter:inc", _params, socket),
    do: update(socket, :count, &(&1 + 1))

  def handle_event("counter:dec", _params, socket),
    do: update(socket, :count, &(&1 - 1))
end

# In the LiveView
def mount(_params, _session, socket),
  do: {:ok, CounterComponent.mount(socket)}

def handle_event("counter:" <> _ = event, params, socket),
  do: {:noreply, CounterComponent.handle_event(event, params, socket)}

The component returns a plain socket, and the LiveView wraps it in the tuple Phoenix expects. The LiveView stays thin, and every delegate is visible. You can read the mount pipeline as a manifest of every component the view manages.

Turn the Example Into a Skill

Once the counter worked, Bruce didn’t hand it to Claude as a template. He asked Claude to build a skill that captured it.

This works because the model generalizes from something concrete that already compiles and runs. A hand-written template describes what you think the pattern is. A working example shows what the pattern actually is, and the model can see both the code and the steps that produced it.

“But rather than say, hey, follow the template in the counter, we asked Claude to build a skill based on that template. And it came up with some ideas that we wouldn’t have had.”

– Bruce Tate

The skill’s configuration has two details worth copying. It lists trigger phrases like “stateful component,” “component with events,” and “delegating components,” so using that language pulls the pattern into context automatically. It also runs on Haiku. When the slice of work is this small and this well defined, a cheaper model is enough.

If you want to try this today, pick one pattern you keep re-explaining to the model. Build the smallest working version of it, refine it in two or three small prompts, and then ask Claude to turn it into a skill. Review the skill the way you would review code.

Supervised Prompting

Bruce calls this rhythm supervised prompting: build a limited feature, review it, throw it away if it doesn’t fit, and adjust the prompt before trying again.

The word “supervised” matters. You are not handing the model a goal and walking away, and you are not writing every line yourself. Your judgment flows back into the prompts, the docs, and the skills.

Once you work this way, a bad result stops being a setback and becomes information for the next prompt. The thing that improves over time is not the code from any single run. It’s everything you feed the model.

Next, all of it pays off. With the infrastructure, the improved prompts, and the stateful component skill in place, we rebuild the UI, and the result looks like pure vibing even though it’s the opposite.

If you want to practice this loop in a real Phoenix project, join us in the Groxio AI course.


🤖 Turn Working Examples Into Anti-Vibe-Coding Skills

This comes from Bruce's AI Agents course – the anti-vibe-coding curriculum. Learn structured oversight through the Ask → Plan → Agent framework, turning failed attempts and working examples into reusable instructions without losing architecture decisions. Available via monthly subscription – try it for one month, with no annual commitment.

– Paulo & Bruce

Bruce Tate's avatar
Bruce Tate
System architecture expert and author of 10+ Elixir books.
Paulo Valim's avatar
Paulo Valim
Full‑stack Elixir developer and educator teaching modern Elixir and AI‑assisted development.