Backward
Backward mode reverse-documents an existing Lex codebase across 18 steps, pausing once for the discovery questionnaire, and writes every output to the working tree without touching git.
Backward
Backward mode reverse-documents an existing codebase across 18 steps (0–17): it scans the code, builds a technical map, asks you a focused set of questions, and produces canonical business and technical documentation. Unlike forward mode it never commits or pushes — every output lands in the project's working tree for you to review and commit yourself.
Slash commands: /lex-reverse <path-or-URL>, /lex-reverse-resume. Brief hands over to this mode when the job you describe is documenting something that already exists.
The pipeline
/lex-reverse "<path or GitHub URL>"
↓
reverse_kickstart(project_path=... OR github_url=..., project_name=...)
scan_project() # AST scan → R-00..R-02 artifacts
generate_wiki() # technical-map/ + per-module CONTEXT.md
loop step 3..6: # Phase B — LLM wiki review
get_reverse_step(step=N) → runSubagent("lex-reverse-step-NN") → notify_reverse_complete
generate_questionnaire() # writes discovery-questionnaire.md
↓
### PAUSE — you fill in the [USER-REQUIRED] answers
↓
submit_questionnaire(path=".../discovery-questionnaire.md")
loop step 8..16: # Phase D — canonical business docs
get_reverse_step(step=N) → runSubagent → notify_reverse_complete
finalize_reverse()
runSubagent("lex-reverse-step-17", ...) # gap report
notify_reverse_complete(step=17, ...)Given a GitHub URL instead of a local path, reverse_kickstart takes a shallow clone into a temporary directory — enough to read the code, not a working copy you are meant to keep.
Phase map
Steps | Phase |
|---|---|
00–02 | Setup and AST scan bookkeeping (paired with |
03–06 | Phase B — LLM wiki review and enrichment |
07 | Discovery questionnaire authoring |
08–16 | Phase D — canonical business document generation |
17 | Finalization and gap report |
The one mandatory pause
Backward mode halts exactly once, after generate_questionnaire(). The step 7 agent answers what it can read out of the code and marks those answers [LLM-FILLED]; what is left is [USER-REQUIRED] — the questions only a human who knows the business can settle. Validate the first set, fill in the second, then call submit_questionnaire(...) to unblock Phase D. This is what turns a mechanical code scan into documentation that captures real business intent, and it uses the same provenance vocabulary as Brief.
Where output lands
Everything is written under the target project: technical-map/ for the AST-derived wiki and its per-module CONTEXT.md files, plans/business_docs/business/ for the numbered business documents, and plans/business_docs/discovery-questionnaire.md for the questionnaire. Session state sits in .lex-reverse/manifest.json, which reverse_kickstart re-reads to pick a run back up. /lex-reverse-resume starts by calling get_reverse_status, a read-only progress probe over the live session that neither starts nor resumes a run — if the server has been restarted, call reverse_kickstart again and it auto-resumes from the manifest.
Note that generate_wiki() rebuilds technical-map/ and every CONTEXT.md from the current scan, so re-running it replaces what is there. Forward mode's step-15 scaffold behaves the opposite way and is written only once. If you have hand-edited a CONTEXT.md, copy it out before scanning again.
When to use it
- You inherited a Lex app with no documentation.
- You need business-level docs that match what the code actually does.
- You want a permanent knowledge layer future AI sessions can rely on.
- Test sent you here. A test run will not open without a user-story document, because assertions derived from the implementation only pin current behaviour, bugs included. Test mode dispatches the project to backward mode and records the pending return, so the test session resumes once the documentation exists.
Was this helpful?
Your feedback shapes what we write next.
