This is an absolutely fantastic setup. You’ve done three crucial things:
- Built a flexible AI orchestration tool (
pipeline_ex
) that can chain different providers. - Identified a deep, complex, and valuable problem domain: The architectural refactoring of a large Elixir/OTP application.
- Documented the manual, painful process of solving that problem, highlighting the exact steps, analysis, and code changes required.
You’re not just building a toy. You’re on the verge of creating a system that solves a real, high-value software engineering problem. Your question, “what else do I need now,” is the perfect next step. You’re moving from building the tool to building the system that uses the tool.
Let’s break down exactly what you need to build your “system for building complex Elixir OTP projects.” The goal is to automate the nightmare you documented in your worklogs.
The Grand Vision: The “OTP-Genesis System”
Your “Genesis Pipeline” is the right idea. Let’s expand it. You are building an OTP-Genesis System: an AI-powered system that takes a high-level architectural goal (e.g., “Refactor this codebase to be truly fault-tolerant”) and orchestrates the entire development lifecycleâplanning, coding, testing, and refactoringâto achieve it.
Here is the roadmap, broken down into what you need to build using your pipeline_ex
tool.
Phase 1: The “Meta-Pipeline” - Your Chief Architect AI
Your immediate next step is to build the master pipeline that generates the detailed plans, just like the JULY_1_2025...
documents you created manually. This is the core of your system.
Objective: Create a pipeline that takes a high-level goal and outputs a multi-stage plan.
What you need:
A
plan.generate
Pipeline: This will be your most important pipeline. It takes your massive codebase (repomix-output.xml
) and a high-level prompt, and outputs a structured plan (like your markdown files).Example
pipeline.run
command:# Feed the entire codebase and the goal to your new planning pipeline mix pipeline.run pipelines/generate_refactor_plan.yaml \ --input-file repomix-output.xml \ --prompt "Analyze this Elixir codebase for OTP anti-patterns. Based on the analysis, create a multi-stage refactoring plan, starting with the most critical fixes. The output should be a series of structured markdown documents, similar to the provided worklogs."
The
generate_refactor_plan.yaml
file: This is the pipeline you need to write.# pipelines/generate_refactor_plan.yaml workflow: name: "OTP Refactoring Plan Generator" description: "Analyzes a codebase and generates a multi-stage OTP refactor plan." steps: - name: "analyze_codebase" type: "claude" # Or Gemini, Claude is great at this kind of analysis prompt: - type: "static" content: | You are a world-class Elixir/OTP architect. Your task is to analyze the provided codebase for critical OTP anti-patterns. Focus on: - Unsupervised processes (`spawn` vs `Task.Supervisor`) - Volatile state in GenServers (state lost on crash) - Unreliable messaging (`send` vs `GenServer.call/cast`) - "God" agents with too many responsibilities - Misuse of telemetry for control flow Analyze the following codebase: - type: "file" path: "{{ input_file }}" # This injects repomix-output.xml - type: "static" content: | Based on your analysis, produce a detailed list of all critical flaws found. Output this analysis in a structured format. - name: "generate_plan_documents" type: "claude_smart" # Using your enhanced steps preset: "development" # Optimized for code generation prompt: - type: "static" content: | Based on the previous analysis of OTP flaws, create a detailed, multi-stage refactoring plan. The plan should be broken into 5 separate markdown documents, similar to the provided worklog files. Each document should represent a logical phase of the refactor: 1. **Critical Fixes (Stop the Bleeding):** Address memory leaks, race conditions, and banned primitives. 2. **State Persistence:** Refactor agents to persist state and survive crashes. 3. **Architectural Decomposition:** Break down God agents into smaller, supervised processes. 4. **Testing & Communication:** Fix test anti-patterns and unreliable messaging. 5. **Integration & Rollout:** Create a deployment plan with feature flags and monitoring. For each stage, provide: - A clear summary of the problem. - Action items with specific file paths and code snippets for the fix. - A plan for testing the fix. Here is the analysis to use: - type: "previous_response" name: "analyze_codebase" - type: "static" content: "Generate the markdown documents now."
Phase 2: Building Blocks - Atomic Pipelines for Each Development Task
Your meta-pipeline generates the plan. Now, you need a suite of smaller, reusable pipelines that execute the individual steps from that plan.
What you need:
A directory of focused pipelines, e.g., pipelines/atomic/
:
find_anti_pattern.yaml
:- Prompt:
"Find all instances of raw Process.spawn/1 in the codebase."
- Action: Uses Claude with the
grep
orsearch
tool to scan the codebase. - Output: A list of file paths and line numbers.
- Prompt:
refactor_file.yaml
:- Prompt:
"In the file 'lib/foundation/task_helper.ex', replace the fallback 'spawn(fun)' with 'raise \"TaskSupervisor not available!\"' to prevent creating unsupervised processes."
- Action: Uses Claude with the
read
andedit
tools. - Output: A git diff of the changes.
- Prompt:
generate_test.yaml
:- Prompt:
"Based on the changes in this diff, generate a new ExUnit test case in 'test/foundation/task_helper_test.exs' that verifies the new 'raise' behavior when the supervisor is not running."
- Action: Takes a diff as input, generates Elixir test code.
- Output: The new test file content.
- Prompt:
run_verification.yaml
:- Prompt:
"Run 'mix credo --strict' and 'mix test test/the_new_test.exs' and report if they pass or fail."
- Action: Uses Claude with the
bash
tool to execute commands. - Output: The stdout/stderr and exit code from the commands.
- Prompt:
Phase 3: The Full Orchestration - Your Self-Improving System
This is where it all comes together. You need a higher-level pipeline that uses your “Genesis Pipeline” to create and then execute a full development workflow.
The Self-Improving Loop:
master_workflow.yaml
is the entry point.It calls the
plan.generate
pipeline (from Phase 1) to create a set of refactoring steps.It then iterates through each step from the generated plan.
For each step, it calls the appropriate atomic pipeline (from Phase 2).
refactor_file.yaml
to make a code change.generate_test.yaml
to write a test for the change.run_verification.yaml
to run the new test and credo.
This is the crucial part: The output of the verification step (
run_verification.yaml
) is fed back into the next step.Example
master_workflow.yaml
step:# ... previous steps for planning and refactoring ... - name: "verify_fix" type: "claude_smart" preset: "analysis" prompt: - type: "static" content: | The refactoring change has been applied and the test has been generated. The following is the output from `mix test`. Analyze the output. Did the test pass? Did the refactoring introduce new errors? If it failed, identify the root cause of the failure. If it passed, the next step is to commit the changes. Test Output: - type: "previous_response" name: "run_verification" # The step that ran `mix test` - type: "static" content: "Provide a JSON response with 'status': 'passed' or 'status': 'failed', and a 'next_action' key." # This is a conceptual step showing how you would use conditional logic - name: "commit_changes" type: "claude" # This step would only run if the 'verify_fix' status was 'passed' # Your pipeline executor would need to support this conditional logic. prompt: - type: "static" content: "Generate a git commit message for the changes and then run 'git commit'." - type: "file" path: "{{ diff_file }}"
What Your pipeline_ex
Needs Next (The Missing Pieces)
Your README
shows a powerful system for chaining LLM calls. To achieve the vision above, you’ll need to enhance it with features that bridge the gap between AI text generation and real-world software development.
Robust File I/O: Your
claude
steps need to reliablyread
,write
, andedit
files in the project workspace. You’ve already got the tools for this; ensure they are robust.Structured Data Exchange: Steps need to pass more than just text. The output of one step should be structured data (JSON/YAML) that the next step can parse and use. The
InstructorLite
integration with Gemini is perfect for this. Apply the same structured output principle to your Claude steps.Conditional Execution: A pipeline isn’t just linear. You need to be able to say, “If
step_A
’s output contains'status': 'passed'
, then runstep_B
, otherwise runstep_C
.” This is the most critical feature for building intelligent, self-correcting workflows.State Management & Looping: For complex tasks like a full refactor, the pipeline might need to loop. “Analyze -> Refactor -> Test -> Repeat until all tests pass.” This requires the pipeline executor to manage state across iterations.
A “Codebase” Context Object: Instead of passing file paths around, consider creating a first-class “Codebase” object that can be passed between steps. This object would provide a sandboxed, stateful interface for the AI to interact with the code (e.g.,
codebase.read('lib/file.ex')
,codebase.run_test('test/file_test.exs')
).
You’ve already built an impressive engine. Now, it’s time to build the car around it. Start with the Meta-Pipeline to automate the planning you did manually. That will give you the most immediate and powerful return on your work.