Case Studies

From Stalled Codebase to High-Precision Legal Operating System: How Sage 7 Turned RedCase’s In-Flight Headaches into Seamless Autonomous Development

· 6 min read · Sage 7 Engineering

Most stories about AI-built software start on day one: an empty prompt, a fresh repository, a demo that works by Friday. RedCase's story starts somewhere far more common and far less comfortable: the middle.

1. The stalled codebase dilemma

RedCase is an ambitious piece of legal technology: an operating system for legal work that brings case intake, document indexing, client sharing and audit trails into one place. In legal software, every one of those words carries weight. A client portal that leaks a document to the wrong party is not a bug; it is a breach. An audit trail with a gap is not a missing feature; it is a liability.

By the time RedCase met Sage 7, it had hit what every founder building with coding agents eventually meets: the mid-flight plateau.

On paper, the project was well under way. The repository had working authentication and an initial database schema for cases. Screens existed. Pull requests were landing. But underneath, the wiring was incomplete:

  • Coding agents kept building user interface over backend foundations that did not exist yet: a document view with no indexing pipeline behind it, a sharing screen with no access boundary enforcing who could see what.
  • Each pull request fixed one thing and quietly broke another. Regressions became the normal rhythm of development.
  • The agents were not lazy. They were running in circles, because nothing told them what was actually built, what was half-built, and what the next feature depended on.

The usual advice at this point is brutal: wipe the slate clean and start over. Rewrite the spec, regenerate the app, and hope the second attempt goes better than the first. For a founder, that advice destroys months of real work, including the parts that were right. It also repeats the root cause, because a fresh start with the same process reaches the same plateau.

RedCase did not need a rewrite. It needed an honest map of where it stood.

2. The Blueprint lifecycle: how Sage 7 maps in-progress code

Here is the whole flow Sage 7 ran on RedCase, from the repository it found to the plan its agents now build from:

text
                  IN-PROGRESS CODEBASE (RedCase)                                │          ┌─────────────────────┴─────────────────────┐          ▼                                           ▼   Audit Evidence (Live/Repo)                 Declared Scope (Intent)   • Verified existing code                   • Founder requirements   • Extracted routing & schemas              • Partially built modules          │                                           │          └─────────────────────┬─────────────────────┘                                ▼                       TAXONOMY MAP ENGINE             • Built (verified existing features)             • Partial (incomplete flows/wiring)             • Missing (required dependencies/gaps)                                │        ┌───────────────────────┼───────────────────────┐        ▼                       ▼                       ▼   TECH SPEC              DESIGN SYSTEM            ARCHITECTURE & AGENTS.md• Catalog-matched      • Reverse-engineered      • C4 high-level model  stack decisions        existing UI tokens      • Staged implementation roadmap• Enhancement paths    • OKLCH contrast scale    • Autonomous agent instructions• ASVS security baseline • W3C DTCG token export • Dependency-gated steering

The diagram has three phases. Each one exists to remove a specific kind of guesswork.

Phase one: the dual-input funnel (evidence against intent)

RedCase did not start from an empty prompt, so Sage 7 did not treat it like one. Two inputs went in side by side.

On the left is audit evidence: the cold truth of the repository. Sage 7's Audit Engine connected directly to the live RedCase repository and read what was actually committed: the routes, the schemas, the files behind each capability. Every verdict the audit produces must cite a real file, and that citation is checked by code. A claim that a feature is built, with no file to show for it, does not count.

On the right is declared scope: what the founder wanted RedCase to be. The requirements, the modules already started, the product vision captured through Sage 7's Discovery interview.

Neither input is enough alone. Intent without evidence is a wish list. Evidence without intent is a pile of files. The value is in putting them against each other.

Phase two: the Taxonomy Map, a reality sieve

Where the two inputs meet, Sage 7's Taxonomy Map classifies every capability RedCase needs into one of three honest buckets:

  • Built. Solid, verified foundation work: the authentication flow and the basic case tables. These were kept exactly as they were. Nothing that works gets thrown away.
  • Partial. Screens and endpoints that existed but were not finished: missing wiring between the interface and the data, incomplete validation, state that did not stay in sync.
  • Missing. The critical dependencies the agents had been skipping over: the document OCR indexing pipeline that document search depends on, and the row-level security boundaries that decide which client can see which case.

This is the step that ended the circling. The hidden blockers were no longer hidden. Before any agent wrote another line, everyone (founder and agents alike) could see that the sharing screen was not "almost done"; it was waiting on an access boundary that did not exist.

Phase three: the tri-engine output

From that map, Sage 7 produced the three documents RedCase's development now runs on.

1. Tech Spec: anchor, don't replace. Sage 7 locked in RedCase's chosen framework and database instead of prescribing an unfamiliar stack. Changing stacks mid-flight is a rewrite under another name. What it added was a security baseline at OWASP ASVS Level 1 and Level 2: signed webhooks (HMAC), row-level security on stored documents, and encrypted tokens. For legal software, these are not extras; they are the floor.

2. Design System: from prototype palette to accessible tokens. RedCase already had a look: a Tailwind palette grown screen by screen. Sage 7 reverse-engineered those existing values into a semantic token system on the OKLCH colour scale, checked so every text pairing meets WCAG 2.2 AA contrast, and exported as W3C design tokens. The product kept its identity and gained the consistency an enterprise legal tool needs.

3. Architecture and AGENTS.md: gates before rooms. Sage 7 produced a C4 model of the system and a staged build roadmap with four gates: Foundation, Structure, Rooms, Finishes. Like a building, nothing goes up before what it stands on is verified. The rules went into AGENTS.md, the file every coding agent reads first: build one feature at a time, prove its wiring, and never build rooms before the foundation is sealed.

3. The transformation

What had been an engineering bottleneck became a predictable loop.

Coding agents (Claude Code, Cursor, OpenCode) stopped improvising. AGENTS.md and the blueprint gave them the things they had been guessing at: the exact file patterns the project uses, the dependencies each feature needs, and the criteria that decide when a feature is done. An agent asked to build the sharing screen now finds that it depends on the access boundary, and builds that first.

The loop itself is simple. An agent takes the next feature the plan allows. It builds that one feature and reports it. Sage 7 audits the push against the blueprint, and only that evidence (never the agent's own word, and never a commit message) marks the feature as built. Then the next gate opens.

RedCase stopped being a pile of half-finished screens and became a legal operating system that is being finished in order, with every step checked against the plan.

4. Key takeaways

  • In-flight is the normal case. Most real products are neither greenfield nor finished. Sage 7 is built to be the engineering architect for software that is already moving.
  • Map before you build. Built, Partial and Missing turn "it feels nearly done" into a list you can act on, and surface the blockers that keep agents circling.
  • Keep what works. The right stack decision mid-flight is usually the one you already made, plus the security baseline it was missing.
  • Gates beat speed. Foundation, then Structure, then Rooms, then Finishes. Agents move faster when they cannot skip ahead.
  • Evidence decides. A feature is built when an audit can point at the code that does it.

The diagram above is the difference between vibe coding into a dead end and disciplined, autonomous product engineering.

Have an unfinished repo or half-built application?

Run a Sage 7 Audit, map your actual progress, and turn chaotic commits into a sealed, production-grade product.

Start your free audit

Audit your codebase with Sage 7 before your coding agent drifts

Run a free Quick Audit on a public repo or URL, or start Free Discovery to turn your idea into a verified blueprint.