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 GitHub Stars License: MIT PRs Welcome

End-to-end development workflows for Claude Code - Specialized agents handle requirements, design, implementation, and quality checks so you get reviewable code, not just generated code.


⚡ Quick Start

This marketplace includes the following plugins:

Core plugins:

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

Optional add-ons (enhance core plugins):

Skills only (for users with existing workflows):

  • dev-skills - Coding best practices, testing principles, and design guidelines — no workflow recipes

These plugins provide end-to-end workflows for AI-assisted development. 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

#
Enter fullscreen mode Exit fullscreen mode

Top comments (0)