Logo vun Reverse Engineering Business Logic

Reverse Engineering Business Logic

Communautéit
meirm
reverse-engineering-business-logic

Reverse engineers business logic from source code by extracting operational business truth. Use when user asks to understand what the system actually does, analyze business rules, extract domain logic, infer workflows from code, explain state transitions, or identify decision logic. Works with API views (Django, FastAPI, etc.), domain models, background tasks, and multi-step workflows.

Iwwersiicht

Editeurmeirm
Repositoryreverse-engineering-skill
Skill-Nummreverse-engineering-business-logic
Stären
46
Forks
7
Matgeliwwert Fichieren
8
LizenzMIT
Linken
  • Instruktiounen am Markdown-Format

    Eng SKILL.md-Datei, déi de Modell bei Bedarf luet, soudatt nëmmen Token ufalen, wann eng Ufro tatsächlech dozou passt.

  • Funktionéiert mat all LLM

    KI-Skills si reng Markdown, keen ubidderspezifesche Code. Dofir funktionéiert dëse Skill mat GPT, Claude, Gemini, Grok oder engem lokale Modell.

  • 8 matgeliwwert Dateien

    Skripten, Virlagen a Referenzen, déi de Modell beim Schaffe liese kann. D'Dateie kënnen nëmme gelies ginn a ginn ni ausgeféiert.

  • Open Source

    Vum meirm op GitHub verëffentlecht. Liest de Quelltext, ier Dir de Skill installéiert.

Installatioun

Installéiert de KI-Skill Reverse Engineering Business Logic an TypingMind, fir e mat all LLM ze benotzen, oder füügt en an en anere KI-Agent an, deen SKILL.md liest.

1

An TypingMind installéieren

TypingMind installéiert e Skill direkt aus sengem GitHub-Dossier — dobäi gëtt SKILL.md gelies, d'Ressourcedateie gi gebëndelt an d'Resultat gëtt lokal gespäichert.

  1. Maacht d'App op a gitt op Plugins → Skills.
  2. Wielt „Vun GitHub installéieren“.
  3. Pecht d'URL vum Skill-Dossier hei drënner an a bestätegt.
    https://github.com/meirm/reverse-engineering-skill/tree/main/skills/reverse-engineering-business-logic
  4. Aktivéiert de Skill an all Chat, an deem Dir e benotze wëllt.
Plugins → Skills → Skill afügen → Vu GitHub-URL, pecht dann d'URL vum Dossier an a klickt op Weider.
2

An engem anere KI-Agent installéieren

All KI-Agent, deen d'Format Agent Skills liest, kann dëse Skill benotzen — kopéiert den Dossier an de Skill-Verzeechnes vun deem KI-Agent.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/meirm/reverse-engineering-skill.git /tmp/reverse-engineering-skill
mkdir -p .claude/skills
cp -r /tmp/reverse-engineering-skill/skills/reverse-engineering-business-logic .claude/skills/reverse-engineering-business-logic
Start Claude Code nom Kopéieren nei, fir datt den neie Skill erkannt gëtt.

An TypingMind benotzen

Aktivéiert Reverse Engineering Business Logic an engem Chat vun TypingMind, an de Modell iwwerhëlt de Rescht. Den Numm an d'Beschreiwung stinn am System-Prompt. Soubal eng Ufro dozou passt, luet de Modell déi komplett Instruktioune selwer — Dir musst de Skill ni manuell opruffen, an et fale keng Token un, bis en tatsächlech benotzt gëtt.

De Modell luet Reverse Engineering Business Logic automatesch, soubal eng Ufro dozou passt.

Funktionéiert mat all KI-Modell

KI-Skills si reng Markdown-Instruktiounen amplaz vun ubidderspezifeschem Code. Dofir ass Reverse Engineering Business Logic net un de Modell gebonnen, fir deen de Skill geschriwwe gouf. Installéiert en eemol an TypingMind a benotzt e mat GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder engem lokale Modell, deen Dir selwer bedreift — alles mat Ären eegenen API-Keys.

  • Gëtt nëmme gelueden, wann et néideg ass

    De System-Prompt enthält nëmmen den Numm an d'Beschreiwung. D'Instruktioune gi bei der éischter passender Ufro gelueden, soudatt en onbenotzte Skill näischt kascht.

  • De Modell am lafende Chat wiesselen

    Well de Skill aus Instruktiounen amplaz vu Code besteet, funktionéiert en och no engem Modellwiessel — den nächste Modell liest déi selwecht SKILL.md-Datei.

Skill-Instruktiounen

Dëst ass den Inhalt vu SKILL.md, deen de Modell luet. Liest e virun der Installatioun — e Skill besteet aus Instruktiounen, déi Äre Modell befollegt.

Reverse Engineer Business Logic from Code

Project setup

This skill is project-agnostic. Before use, ensure the project has a BDD config so output paths and terminology are defined. If BDD/project_config.yaml (or .cursor/bdd_project_config.yaml) exists, read it for bl_output.root, bl_output.categories, and terminology. If not, run the tailor-bdd-skills-for-project skill first to create it.

Default when no config exists: write BL under business_logic/ with categories endpoints, models, workflows, billing.


Quick Start (5 minutes)

Extract business logic from code in 3 steps:

1. Say "extract business logic from [file/function/feature]"

  • Example: "extract business logic from order creation"
  • Example: "explain what the payment charging flow actually does"

2. Review the generated markdown in the BL output directory (from project config, or business_logic/)

  • 11 sections covering purpose, actors, flow, rules, billing, edge cases
  • All with line number references to source code

3. Verify completeness using the validation checklist (below)

Where outputs go (organized by state): Use paths from project config bl_output when present; otherwise:

  • Current production code → [bl_root]/current/[category]/[name].md
  • Proposed changes → [bl_root]/proposal/[category]/[name].md
  • Work in progress → [bl_root]/under_development/[category]/[name].md
  • Historical reference → [bl_root]/historical/[category]/[name].md

Categories: From config or default: endpoints, models, workflows, billing

Most common pattern:

User: "Extract business logic from the order creation flow"
Agent: [Reads project config, analyzes code, generates 11-section BL document]
Output: [bl_root]/current/endpoints/order-creation.md

When to Use This Skill

Use this skill when you hear phrases like:

  • "explain what this code actually does"
  • "what are the business rules for [feature]"
  • "how does billing work"
  • "what happens when [condition] occurs"
  • "why did this [state/transaction/failure] happen"
  • "what's the flow for [feature]"
  • "document the business logic"
  • "reverse engineer the business rules"

Good use cases: ✅ API endpoints that need documentation ✅ Complex state machines or workflows ✅ Billing/credit logic that must be accurate ✅ Features being refactored (need to understand current behavior) ✅ Onboarding new developers (show them what the system does)

Not for: ❌ Code structure or architecture diagrams ❌ Performance analysis ❌ Security audits ❌ Test generation


Core Workflow

Core Principle

Never confuse code structure with business structure.

  • Technical structure: view -> serializer -> service -> provider -> model
  • Business structure: validate request -> determine eligibility -> choose route -> execute lookup -> normalize result -> update record -> charge credits

The distinction is the whole value.

Step 1: Identify the Analysis Scope

Ask the user which mode they need:

  1. Endpoint-to-BL: API views, handlers, endpoints

    • Best for understanding request/response flows
    • Focus on validation, routing, charging, responses
  2. Model-to-BL: Domain models, entities, schemas

    • Best for understanding lifecycle rules
    • Focus on state transitions, invariants, side effects
  3. Workflow-to-BL: Multi-step features spanning files

    • Best for complex business processes
    • Focus on orchestration, retries, fallbacks
  4. Billing-to-BL: Credit, quota, charging logic

    • Best for understanding when money moves
    • Focus on charges, refunds, adjustments, race conditions

Step 2: Identify Entry Points

For the chosen scope, locate:

  • Endpoints: Views, handlers, routes (use Grep for "class.*ViewSet")
  • Commands: Management commands, CLI operations
  • Schedulers: Cron jobs, periodic tasks
  • Queue Workers: Celery tasks, background jobs
  • Models: Domain entities with business methods

Step 3: Trace Execution Path

Follow the code from entry point through:

controller → service → provider → DB updates → response

Look for:

  • Method calls and their sequence
  • External service integration
  • Database operations
  • Background task dispatch
  • State changes

Step 4: Extract Business Decisions

Identify and document:

  • Validations: What gets rejected and why
  • Routing: How requests are directed to different handlers
  • Charging: When credits are consumed, refunded, or adjusted
  • Retries: What gets retried, backoff strategies
  • Fallback logic: Alternative providers, default values
  • Termination conditions: When flows stop early
  • Prioritization: How concurrent requests are ordered

Step 5: Separate Technical from Business

Rewrite technical mechanics in domain language:

TechnicalBusiness
calls function Xattempts provider A, then provider B if A fails
updates status fieldmarks investigation as completed
throws ValidationErrorrejects invalid target identifier
check quota >= costverifies sufficient credits before lookup

Step 6: Use Domain Language

Replace technical terms with business terms. Use the project's terminology from BDD/project_config.yaml (or tailor skill); if missing, infer from the codebase and document in the BL glossary. Example mappings (adapt to project):

  • Prefer the project's canonical term for "request" / "operation" (e.g. "order", "query")
  • Prefer the project's term for "background job" (e.g. "job", "task", "investigation")
  • Prefer the project's term for "account" (e.g. "tenant", "organization", "customer")
  • Prefer the project's term for "balance" or "credits" if the domain uses one

See expertise.yaml for a generic mapping template; project config overrides with project-specific terms.

Step 7: Produce Structured Output

Use the output template in output_template.md to structure findings as:

  1. Business Purpose
  2. Actors
  3. Preconditions
  4. Main Flow
  5. Decision Rules
  6. State Transitions
  7. Billing / Credit Impact
  8. Exceptions / Edge Cases
  9. Data Written / Read
  10. Ambiguities / Questions
  11. Code References

Step 8: Save to BL Output Directory

CRITICAL: Always save the analysis to a file in the project's BL output directory (from BDD/project_config.yaml → bl_output.root, or default business_logic/) to create persistent, linkable documentation.

Directory structure (organized by state): Use paths from project config when present. Generic layout:

[bl_output.root]/
├── current/                    # Production business logic (currently deployed)
│   ├── index.md                # Master index of current BL analyses
│   ├── endpoints/              # API endpoint business logic
│   ├── models/                 # Domain entity lifecycle rules
│   ├── workflows/              # Multi-step business processes
│   ├── billing/                # Charging / payment logic
│   ├── glossary.md             # Business terms and definitions
│   └── DISCOVERY.md            # Complete inventory of discovered BL
├── proposal/                   # Proposed changes (not yet implemented)
│   ├── index.md                # Index of proposed BL changes
│   └── [same subdirectories as current/]
├── under_development/          # Work in progress (partially implemented)
│   ├── index.md                # Index of BL under development
│   └── [same subdirectories as current/]
└── historical/                 # Old/outdated business logic
    ├── index.md                # Index of historical BL (for reference)
    └── [same subdirectories as current/]

Choosing the right directory:

Use [bl_root]/current/ when:

  • Analyzing production code that's currently deployed
  • Documenting existing, stable business logic
  • Creating initial BL documentation for live features

Use [bl_root]/proposal/ when:

  • Documenting proposed business logic changes
  • Analyzing RFCs, design docs, or specifications
  • Exploring "what if" scenarios before implementation
  • BL is not yet implemented in code

Use [bl_root]/under_development/ when:

  • Analyzing code in feature branches
  • Documenting partially implemented features
  • Tracking BL changes during active development
  • Code exists but is not yet in production

Use [bl_root]/historical/ when:

  • Documenting deprecated or removed features
  • Preserving old BL for reference/audit purposes
  • Code has been replaced but understanding is needed

File naming:

  • Use lowercase with hyphens: e.g. order-creation.md, payment-charging.md
  • Use descriptive names that reflect business capability, not code file names

Saving workflow:

  1. Write the analysis using the output_template.md
  2. Choose the appropriate state directory (current/proposal/under_development/historical)
  3. Update the index.md in that directory with file name, purpose, and code locations
  4. Update glossary.md if new terms were discovered; align with project config terminology when present

Quality Validation Checklist

After generating BL documentation, verify:

Completeness (all 11 sections present): □ 1. Business Purpose - What capability this provides □ 2. Actors - Who triggers or uses it □ 3. Preconditions - What must be true before it runs □ 4. Main Flow - Step-by-step business flow (not code structure!) □ 5. Decision Rules - Explicit if/then rules □ 6. State Transitions - How statuses change (with diagram) □ 7. Billing/Credit Impact - When credits are charged/refunded □ 8. Exceptions/Edge Cases - Invalid input, unsupported paths □ 9. Data Written/Read - Key persistence effects □ 10. Ambiguities/Questions - What cannot be inferred □ 11. Code References - Specific files and line numbers

Quality Checks: □ Business language used (not "calls function X") □ Domain terminology from expertise.yaml □ Line numbers included for all references □ State transitions have Mermaid diagrams □ Billing logic is explicit (no "TODO: verify billing") □ Ambiguities are honestly documented

Self-Review Questions:

  • Could a new developer understand what this code does from this doc?
  • Are all billing/credit impacts explicit?
  • Would this document catch a breaking change?
  • Are there "I don't know" sections where appropriate?

Analysis Modes Summary

Endpoint-to-BL: API views, handlers, endpoints → [bl_root]/endpoints/ (or config category)

  • Focus: Request/response flows, validation, routing, charging, responses

Model-to-BL: Domain models, entities, schemas → [bl_root]/models/

  • Focus: Lifecycle rules, state transitions, invariants, side effects

Workflow-to-BL: Multi-step features → [bl_root]/workflows/

  • Focus: Orchestration, retries, fallbacks, background tasks

Billing-to-BL: Charges, refunds, payments → [bl_root]/billing/

  • Focus: When charges occur, refunds, adjustments, partial charges

Best Practices

Do:

  • Start from entry points and trace forward
  • Look for hidden logic in model methods, property decorators, signals
  • Check config flags and environment variables for behavioral switches
  • Examine exception handlers for silent fallbacks
  • Document what you cannot safely infer

Don't:

  • Describe code structure instead of business flow
  • Ignore background tasks and async operations
  • Skip billing/credit logic (often the most critical)
  • Assume docstrings match implementation
  • Omit "impossible" states the code actually handles

Red Flags to Investigate

  • Empty except blocks (silent failures)
  • TODO comments with business implications
  • Commented-out code with "removed" logic
  • Multiple return paths with different semantics
  • State checks that don't match enum definitions
  • Billing logic without clear audit trail
  • Fallback providers with different semantics
  • Partial success states

Advanced Analysis (See References)

This skill includes three advanced analysis modes for validation, discovery, and impact analysis:

📖 Diff Mode: BL Docs vs Code

  • Validate that business logic documentation matches actual code implementation
  • Detect stale docs, unimplemented rules, and hidden behavior
  • Use before/after code changes or during code reviews

📖 Change Impact Analysis: Code → BL

  • Analyze how code changes affect business logic
  • Generate business impact summaries for pull requests and releases
  • Translate code changes to business language for stakeholders

📖 Gap Analysis: Finding Undocumented BL

  • Identify business logic that exists in code but lacks documentation
  • Answer "What are we missing?" and prioritize documentation efforts
  • Use for periodic reviews or before audits

Bootstrapping (See Reference)

📖 Bootstrapping Guide - Systematic approach for documenting an entire codebase:

  • Phase 1: Discovery - Map all entry points (endpoints, models, workflows, billing)
  • Phase 2: Prioritization - Tier 1 (critical), Tier 2 (important), Tier 3 (nice to have)
  • Phase 3: Initial Documentation - Set up directory structure and index
  • Phase 4: Batch Processing - Systematic documentation of prioritized items
  • Phase 5: Cross-Linking - Connect related analyses

Use this for initial documentation projects or comprehensive knowledge base builds.


Examples

Example 1: Endpoint-to-BL (API view)

User request:

What does the OrderCreateView actually do when someone creates an order?

You would:

  1. Find the entry point using project config entry_points.endpoints (e.g. grep -r "class OrderCreateView" or the configured path/grep patterns)
  2. Read the view/handler file
  3. Trace the create flow through validation → service → persistence → response
  4. Extract business logic into the structured template
  5. Save analysis to file: [bl_root]/current/endpoints/order-creation.md
  6. Update the index: Add entry to that state's index.md

Output file: [bl_root]/current/endpoints/order-creation.md

markdown
## 1. Business Purpose
Creates a new order from validated request data and reserves inventory.

## 5. Decision Rules
- If item out of stock → reject with "Item unavailable"
- If account balance < order total → reject with "Insufficient balance"
- If payment gateway timeout → retry once, then fail with "Payment unavailable"
- If both payment attempts fail → mark order as FAILED, release reservation

## Related Business Logic
- [Charging Rules](../billing/charging-rules.md) - When and how charges are applied
- [Order Lifecycle](../models/order-lifecycle.md) - State transitions

References

📖 Quick Start Guide - Detailed getting started guide with 3-5 complete walkthrough examples

📖 Bootstrapping - Systematic codebase documentation workflow for large-scale projects

📖 Advanced Modes - Diff, Change Impact, and Gap Analysis modes with workflows and examples

📖 Validation - Quality assurance, common issues, peer review process, and ambiguity handling

📖 Collaboration - Team workflows, versioning, conflict resolution, and maintenance guidelines

📖 Domain Expertise - Template for business language mappings; use project config terminology for project-specific terms

📖 Output Template - 11-section template for generating BL documentation

Matgeliwwert Fichieren

De Modell liest dës Dateie bei Bedarf, wärend de Skill gelueden ass. Si ginn als liesbar Dateie bereetgestallt a ginn ni ausgeféiert.

Heefeg gestallte Froen

Wat mécht de KI-Skill Reverse Engineering Business Logic?

Reverse engineers business logic from source code by extracting operational business truth. Use when user asks to understand what the system actually does, analyze business rules, extract domain logic, infer workflows from code, explain state transitions, or identify decision logic. Works with API views (Django, FastAPI, etc.), domain models, background tasks, and multi-step workflows.

Firwat Reverse Engineering Business Logic op TypingMind benotzen?

Well Dir en eemol installéiert a mat all Modell benotze kënnt. Reverse Engineering Business Logic besteet aus einfachem Markdown amplaz vun ubidderspezifeschem Code. Dee selwechte Skill funktionéiert also mat GPT-5, Claude, Gemini, Grok oder engem lokale Modell – an Dir kënnt de Modell matzen am Chat wiesselen, ouni datt de Skill ophält ze funktionéieren. TypingMind benotzt Är eegen API-Schlësselen, sou datt Dir d'Ubidder direkt bezuelt amplaz vun engem Abonnement pro Benotzerplaz. Är Skills a Chats bleiwen an Ärem eegene Späicher.

Wéi installéieren ech Reverse Engineering Business Logic an TypingMind?

Maacht an TypingMind Plugins → Skills → Vu GitHub installéieren op a setzt https://github.com/meirm/reverse-engineering-skill/tree/main/skills/reverse-engineering-business-logic an. TypingMind liest d'Datei SKILL.md, bündelt déi zougehéiereg Dateien an installéiert dat Ganzt als Skill, deen Dir pro Chat aktivéiere kënnt.

Wéi eng KI-Modeller kënnen Reverse Engineering Business Logic benotzen?

All Modell, deen Dir an TypingMind verbënnt. KI-Skills sinn einfach Markdown-Instruktiounen an net ubidderspezifesche Code. Dofir kënne GPT, Claude, Gemini, Grok a lokal Modeller dëse Skill lueden, wann eng Ufro dozou passt.

Wéi vill KI-Modeller kann ech mat Reverse Engineering Business Logic benotzen?

Esou vill Dir wëllt. Soulaang e Modell Skills ënnerstëtzt, kënnt Dir Reverse Engineering Business Logic domat benotzen – GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama a méi – alles op TypingMind mat Ären eegenen API-Schlësselen.

Ass de KI-Skill Reverse Engineering Business Logic gratis?

Jo. De Skill gëtt vum meirm ënner der Lizenz MIT op GitHub publizéiert. Dir bezuelt nëmmen Ären eegene KI-Ubidder fir d'Token, déi Dir benotzt.

Wat si KI-Skills?

E KI-Skill ass e weiderverwendbaart Pak vun Instruktiounen, dat engem KI-Modell bäibréngt, wéi en eng bestëmmt Aufgab erfëllt. E follegt dem oppenen Agent Skills-Format: eng Datei SKILL.md mat engem Numm an enger Beschreiwung, plus all Scripten, Virlagen oder Referenzdateien, déi de Modell eventuell brauch. De Modell liest d'Instruktiounen eréischt, wann Är Ufro zum Skill passt. En installéierte Skill kascht also näischt, bis e benotzt gëtt.

Wéi ënnerscheede sech KI-Skills vu Plugins oder MCP-Serveren?

E Plugin oder MCP-Server gëtt engem Modell nei Tools, déi en opruffe kann – Code, deen iergendwou leeft an e Resultat zeréckgëtt. E KI-Skill gëtt dem Modell dogéint Wëssen an eng Virgoensweis: wéi en eng Aufgab ugeet, wéi eng Schrëtt en nokënnt a wéi eng gutt Ausgab ausgesäit. Skills bestinn aus einfachem Markdown, brauche kee Server, keen API-Schlëssel a keng Lafzäitëmfeld a funktionéiere mat all Modell.

All weisen

Elo Ären eegene KI-Workspace ariichten

Abonnéiert Iech op eisen Newsletter, fir iwwer nei Funktiounen an zukünfteg Gewënnspiller informéiert ze ginn 👇