When a user drops a feature spec into Merjax's spec editor and hits "Generate PR," a pull request lands in their repository. Here's exactly what happens on the way.
Phase 1: Parsing
The spec text is sent to Claude Sonnet 4 with a structured prompt that extracts:
- The target repository and base branch
- A list of file changes (create, edit, delete) with natural-language descriptions
- A PR title and body draft
- Any explicit constraints ("don't touch the auth layer", "keep the test suite green")
The model returns a structured JSON plan.
Phase 2: Context loading
For each file the plan touches, we fetch the current content from the git object store and pass it
into the context window. We also load the repository's CLAUDE.md (if present) as
system-level instructions, and the last 10 commits to the files in scope (for coding style reference).
Large repos stay cheap here because we only fetch the specific blobs we need, not the whole tree. The git object model is extremely efficient for point lookups.
Phase 3: Code generation
The file edit plan is executed by a second Claude call (Sonnet 4) that writes the actual diffs. We run file edits in parallel where there are no inter-file dependencies — typically 60–70% of all edits in a spec. The remainder run sequentially so that a later file can reference changes made in an earlier one.
Each generated file goes through a lightweight AST sanity check: TypeScript files are parsed with
ts.createSourceFile, and any file that fails to parse gets one retry with the parse
error appended to the prompt.
Phase 4: Commit and push
We use git plumbing directly — git hash-object, git update-index,
git write-tree, git commit-tree — to build the commit object without
touching a working directory. The branch is created and the commit pushed atomically.
Phase 5: PR creation and AI review
The PR is created via our internal API (same endpoint the web UI and MCP server use). Immediately after creation, our standard AI review hook fires — a third Claude call reads the diff and posts inline review comments. This is the same review that runs on every human-authored PR. Spec-generated PRs get no special treatment.
The spec-to-PR feature has been live since April 2026.
What we don't do
We don't run the generated code. We don't check out a working copy. We don't call any external tool-execution API. Everything happens in-process using git plumbing, Bun, and Claude. The simplicity is what keeps it small.