MACGPi is a maintainability-focused, LLM-powered code generation pipeline designed to produce production-quality, testable, and well-documented software artifacts. It is built to run with the mini-swe-agent orchestration and integrates prompt templates, phase schemas, and validation tooling to guide generation, evaluation, and iteration.
MACGPi requires a separate vLLM server running to communicate with. This is not orchestrated by the architecture.
- Maintainability-first prompts and schemas for reproducible artifact generation
- Phase-based pipeline (planning, implementation, evaluation) with JSON schemas
- Templates and evaluators to produce structured outputs and machine-validated results
- Lightweight integration with batch runners and local experimentation
macgpi/— core package and prompts used by the pipelineprompts/— phase templates and JSON schemas.configs/— configuration files.
See the prompts directory for examples and canonical templates:
Prerequisites
- Python 3.10+ recommended (or the project's specified environment)
- Conda/Anaconda is commonly used in this workspace for environment management
Quick local steps
- Create or activate a Python environment (optional):
conda create -n macgpi python=3.10 -y
conda activate macgpi- Install project dependencies (if a
requirements.txtorpyproject.tomlexists):
pip install -r requirements.txt-
Ensure a vLLM server is running with the required LLM.
-
Run MACGPi
python3 -m macgpi <problem description> <model name> <output directory> [options] - input (str): The input prompt/problem description which MACGPI should solve as a string.
- model_name (str): The model name of an LLM that the vLLM server is hosting. A list of models for your vLLM server can be found by calling
GET <model_host>:<model_port>/v1/models. - output_dir (str): The destination of the produces code and documentation artifacts.
- --model-host (str): The hostname of the local vLLM server (default "localhost").
- --model-port (int): The port of the local vLLM server (default 8000).
- --prompt-dir (str): The directory in which the phases and their corresponding prompts/schemas are located (default
macgpi/prompts). - --model-config (str): The path to the config file for the LLM (default
macgpi/configs/model.config.yaml, containing the default mini-swe-agent model config). See this page for more information. - --agent-config (str): The path to the config file for the agent (default
macgpi/configs/agent.config.yaml, containing the default mini-swe-agent agent config). See this page for more information. - --log-level (str): The verbosity of MACGPi and underlying models. Either
DEBUG,INFO,WARNING, orERROR(defaultINFO)
- Templates live in
prompts/and are paired with machine-readable schemas to constrain output. Theimplementandrevisephases do not require a schema. - Each phase has a subdirectory under the prompts directory, which the phase config points to.
MACGPi is customizable. You can swap the system prompts for your own prompts using the same phase design or even design your own phase pipeline.
Assigning the --prompt-dir to a different prompt directory redirects MACGPis engine to use the custom prompts. Each phase should have a subdirectory with a prompt and schema, as defined in the phase config. The inputs for the prompts can only be altered by updating the MACGPi pipeline configuration.
The default inputs can be seen in the table below. All phases are provided a output_dir argument, containing the generated artifact root. The prompts can use this argument or ignore it. All phases that make use of an output schema have the schema_format and output_file inputs. The schema is always taken from the phase directory, and the output file is defined per phase in the MACGPi pipeline configuration. The rest of the inputs change per phase.
| Phase | Inputs |
|---|---|
| 01_plan | system_prd (project description) |
| 02_implement | system_prd (project description), implementation_plan (path to the implementation plan generated by phase 01_plan) |
| 03_evaluate | system_prd (project description), implementation_plan (path to the implementation plan generated by phase 01_plan) |
| 04_revise | system_prd (project description), implementation_plan (path to the implementation plan generated by phase 01_plan), evaluation_report (path to the evaluation report generated by phase 03_evaluate) |
Respecting these inputs, the prompt can be modified at will.
Fully customizing the MACGPi pipeline is possibly by editing the phase config (default macgpi/configs/macgpi_phases.json) and assigning a custom prompt directory with the --prompt-dir argument.
The configuration is a JSON format, containing the single top-level objects, entry, and phases.
The entry property contains a string containing the entry point of the application. This should be equal to a phase configured in the phases object. If not present, the first phase in the phases list is used as the entry point.
The phases object is required and contains the definitions of all MACGPi phases. The first phase in this object is the entry point for the pipeline. After that the definitions decide the flow of the pipeline. Each phase object defines its inputs, outputs, subsequent phase, prompt location, etc. A full list of object properties is shown below.
inputs: A list of files (relative to the artifact root) which are the inputs to the prompt. The name used as the key is the name with which it will be accessible in the prompt. E.g."system_prd": "path/to/prd"(seephase_1in the example configuration) means that the contents of the file located atpath/to/prdwill be accessible in the prompt using{{ system_prd }}.path: The path (relative to the prompt directory) of the phase prompt(s) and, optionally, the schema file. Note that phases can contain multiple prompts (see MultiPrompt Phases).schema: Whether or not the output must adhere to a schema. This schema is expected to be readable in aschema.jsonfile located inpath.output_file: The path (relative to the artifact root), to which the output file will be written.next: The name of the phase which should be visited after this phase is completed. If empty orfinish, MACGPi will terminate. A specialdynamicvalue is reserved for LLM-decided phase flow. With this option, the LLM output will decide the next phase. Ifdynamicis used, the output schema MUST contain anextvalue, with the name of the next phase (orfinishfor termination), decided by the LLM. This means thatdynamiccan ONLY be used when the phase makes use of a schema.max_visits: The maximum amount of times a phase is allowed to be visited. If this limit is exceeded, the pipeline stops. If not provided, a maximum of 1 is inferred.max_visits_exceeded_next: The phase that will be entered in themax_visitsis exceeded. This should only happen ifnextis dynamic, ornextis the current phase.
An example configuration can be seen below.
{
"entry": "phase_1",
"phases": {
"phase_1": {
"inputs": {
"system_prd": "path/to/prd"
},
"schema": true,
"path": "phase_1/",
"output_file": "path/to/phase1_output",
"next": "phase_2"
},
"phase_2": {
"inputs": {
"system_prd": "path/to/prd",
"phase_1_output": "path/to/phase1_output"
},
"schema": false,
"path": "phase_02/",
"next": "dynamic",
"max_visits": 5,
"max_visits_exceeded_next": "finish
},
}
}In some cases, you might want to perform multiple distinct prompts in the same phase. For example, using Structured Chain-of-Thought (SCoT) requires two prompts, one for generating the SCoT and another for translating it to functional code. It can be argued that those two prompts belong to the same phase, the implementation phase.
With MACGPi multiprompt phases are possible. By simply adding more template files to the path directory. All template files should have the format template*.md, that is, they should be markdown files starting with template.
MACGPi reads all files conforming to this structure and runs them in alphabetical order. It is therefore recommended, but not strictly enforced, to format the templates as follows:
template_01_<description>.mdtemplate_02_<description>.mdtemplate_03_<description>.md- etc.
This is to prevent confusion of execution order.