DEV Community

Cover image for How I Made Legacy Code AI-Friendly with Auto-Generated Docs
Shinsuke KAGAWA
Shinsuke KAGAWA

Posted on

How I Made Legacy Code AI-Friendly with Auto-Generated Docs

AI coding assistants are amazing—until you point them at a legacy codebase.

"What does this module do?"
"I don't have enough context."

Sound familiar?

The Problem

Claude Code (and similar tools) hit context limits fast on existing projects. No documentation means no context, which means the AI can't help effectively.

You could spend weeks writing docs manually. Or you could automate it.

The Fix: Generate Docs First

Instead of fighting the AI, I ended up building a workflow that:

  1. Scans your codebase for features
  2. Generates PRD + Design Docs automatically
  3. Verifies docs against actual code
  4. Now AI has context to work with

Quick Start

# Start Claude Code
claude

# Add the marketplace
/plugin marketplace add shinpr/claude-code-workflows

# Install the plugin
/plugin install dev-workflows@claude-code-workflows
Enter fullscreen mode Exit fullscreen mode

Then point it at your legacy code:

/reverse-engineer "src/auth"
Enter fullscreen mode Exit fullscreen mode

That's it.

What Happens

The workflow runs through multiple specialized agents:

  1. scope-discoverer finds what features exist in your code
  2. prd-creator generates product docs for each feature
  3. code-verifier checks if the docs match reality
  4. document-reviewer catches inconsistencies

Each step verifies against the actual code—so you get docs that reflect what the system actually does, not what someone thought it did years ago.

What You Get

  • PRD for each feature (what it does, why it exists)
  • Design docs (how it's built, what depends on what)

Now when you ask the AI to modify something, it has context.

Before/After

Before: "Explain the auth module" → Context limit, vague answers

After: AI reads generated docs → Specific, actionable suggestions

When to Use This

Works best when:

  • You've inherited a codebase with missing docs
  • Institutional knowledge has left with previous developers
  • You want to onboard AI assistants to existing projects

It's not magic—complex legacy systems still need human review. But it gets you 80% there automatically.

I built this while trying to make Claude Code usable on projects where no one knows how things work anymore.


GitHub logo shinpr / claude-code-workflows

Production-ready development workflows for Claude Code, powered by specialized AI agents.

Claude Code Workflows 🚀

Claude Code License: MIT PRs Welcome

Build production-ready software with Claude Code - Workflow plugins that bring best practices, specialized agents, and automated quality checks to your development process.


⚡ Quick Start

This marketplace includes two plugins:

  • dev-workflows - Backend and general-purpose development
  • dev-workflows-frontend - React/TypeScript specialized workflows

Choose what fits your project:

Backend or General Development

# 1. Start Claude Code
claude

# 2. Install the marketplace
/plugin marketplace add shinpr/claude-code-workflows

# 3. Install backend plugin
/plugin install dev-workflows@claude-code-workflows

# 4. Restart session (required)
# Exit and restart Claude Code

# 5. Start building
/implement <your feature>
Enter fullscreen mode Exit fullscreen mode

Frontend Development (React/TypeScript)

# 1-2. Same as above (start Claude Code and add marketplace)

# 3. Install frontend plugin
/plugin install dev-workflows-frontend@claude-code-workflows

# 4-5. Same as above (restart and start building)

# Use frontend-specific commands
/front-design <your feature>
Enter fullscreen mode Exit fullscreen mode

Full-Stack Development

Install both plugins to get the complete toolkit for backend…

Top comments (0)