@thierrynakoa/fire-flow 12.2.2 → 13.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CREDITS.md +25 -0
- package/DOMINION-FLOW-OVERVIEW.md +182 -38
- package/README.md +399 -690
- package/TROUBLESHOOTING.md +264 -367
- package/agents/fire-debugger.md +54 -0
- package/agents/fire-executor.md +1610 -1033
- package/agents/fire-fact-checker.md +1 -1
- package/agents/fire-planner.md +85 -17
- package/agents/fire-project-researcher.md +1 -1
- package/agents/fire-researcher.md +4 -22
- package/agents/{fire-phoenix-analyst.md → fire-resurrection-analyst.md} +394 -394
- package/agents/fire-reviewer.md +552 -499
- package/agents/fire-verifier.md +114 -19
- package/bin/cli.js +18 -101
- package/commands/fire-0-orient.md +2 -2
- package/commands/fire-1a-new.md +50 -15
- package/commands/fire-1c-setup.md +33 -5
- package/commands/fire-1d-discuss.md +87 -1
- package/commands/fire-2-plan.md +556 -527
- package/commands/fire-3-execute.md +2046 -1356
- package/commands/fire-4-verify.md +975 -906
- package/commands/fire-5-handoff.md +46 -5
- package/commands/fire-6-resume.md +2 -31
- package/commands/fire-add-new-skill.md +138 -19
- package/commands/fire-autonomous.md +14 -2
- package/commands/fire-complete-milestone.md +1 -1
- package/commands/fire-cost.md +179 -183
- package/commands/fire-debug.md +1 -6
- package/commands/fire-loop-resume.md +2 -2
- package/commands/fire-loop-stop.md +1 -1
- package/commands/fire-loop.md +2 -15
- package/commands/fire-map-codebase.md +1 -1
- package/commands/fire-migrate-database.md +548 -0
- package/commands/fire-new-milestone.md +1 -1
- package/commands/fire-reflect.md +1 -2
- package/commands/fire-research.md +142 -21
- package/commands/{fire-phoenix.md → fire-resurrect.md} +859 -603
- package/commands/fire-scaffold.md +297 -0
- package/commands/fire-search.md +1 -2
- package/commands/fire-security-scan.md +483 -484
- package/commands/fire-setup.md +359 -0
- package/commands/fire-skill.md +770 -0
- package/commands/fire-skills-diff.md +506 -506
- package/commands/fire-skills-history.md +388 -388
- package/commands/fire-skills-rollback.md +7 -7
- package/commands/fire-skills-sync.md +470 -470
- package/commands/fire-test.md +5 -5
- package/commands/fire-todos.md +1 -1
- package/commands/fire-update.md +5 -5
- package/commands/fire-validate-skills.md +282 -0
- package/commands/fire-verify-uat.md +9 -177
- package/commands/fire-vuln-scan.md +492 -493
- package/hooks/run-hook.sh +8 -8
- package/hooks/run-session-end.sh +7 -7
- package/hooks/session-end.sh +90 -90
- package/hooks/session-start.sh +1 -1
- package/package.json +4 -25
- package/plugin.json +7 -7
- package/references/autonomy-levels.md +235 -0
- package/references/behavioral-directives.md +95 -3
- package/references/blocker-tracking.md +1 -1
- package/references/circuit-breaker.md +93 -2
- package/references/context-engineering.md +227 -9
- package/references/honesty-protocols.md +70 -1
- package/references/issue-to-pr-pipeline.md +149 -150
- package/references/metrics-and-trends.md +1 -2
- package/references/research-improvements.md +4 -108
- package/references/sdlc-mapping.md +73 -0
- package/references/state-machine.md +151 -0
- package/skills-library/AVAILABLE_TOOLS_REFERENCE.md +333 -0
- package/skills-library/SKILLS-INDEX.md +57 -558
- package/skills-library/SKILLS_LIBRARY_INDEX.md +532 -0
- package/skills-library/_general/api-patterns/api-field-name-mismatch.md +107 -0
- package/skills-library/_general/api-patterns/streaming-command-timeout.md +122 -0
- package/skills-library/_general/api-patterns/streaming-proxy-cors-bypass.md +102 -0
- package/skills-library/_general/automation/settings-gui-generator.md +172 -0
- package/skills-library/_general/database-solutions/data-type-mapping-reference.md +181 -0
- package/skills-library/_general/database-solutions/mysql-limit-offset-string-coercion.md +102 -0
- package/skills-library/_general/database-solutions/mysql-to-pg-migration.md +195 -0
- package/skills-library/_general/database-solutions/orm-schema-portability.md +193 -0
- package/skills-library/_general/database-solutions/persistent-analysis-storage.md +207 -0
- package/skills-library/_general/database-solutions/pg-to-mysql-schema-migration-methodology.md +190 -0
- package/skills-library/_general/database-solutions/sql-dialect-compatibility-matrix.md +306 -0
- package/skills-library/_general/database-solutions/sqlite-to-pg-migration.md +219 -0
- package/skills-library/_general/frontend/canvas-bubble-animation-grouping.md +270 -0
- package/skills-library/_general/frontend/color-token-migration.md +112 -0
- package/skills-library/_general/frontend/framer-motion-layoutid-grouping.md +150 -0
- package/skills-library/_general/frontend/pyqt6-settings-dialog.md +191 -0
- package/skills-library/_general/frontend/react-flow-animated-layout-switching.md +101 -0
- package/skills-library/_general/frontend/react-hooks-order-debugging.md +141 -0
- package/skills-library/_general/frontend/redux-localstorage-auth-desync.md +126 -0
- package/skills-library/_general/frontend/safari-csp-theme-color-debugging.md +124 -0
- package/skills-library/_general/frontend/safari-sw-cache-poisoning.md +138 -0
- package/skills-library/_general/frontend/svg-sparkline-no-charting-library.md +131 -0
- package/skills-library/_general/growth-marketing/oss-daily-growth-intelligence.md +224 -0
- package/skills-library/_general/integrations/claude-code-local-mcp-integration.md +250 -0
- package/skills-library/_general/integrations/mcp-composite-tool-orchestration.md +200 -0
- package/skills-library/_general/methodology/AGENT_SDK_STANDALONE_TOOLING.md +181 -0
- package/skills-library/_general/methodology/AGENT_TEAMS_GUIDE.md +169 -0
- package/skills-library/_general/methodology/ALAS_STATEFUL_EXECUTION.md +207 -0
- package/skills-library/_general/methodology/AUTO_REVIEWER_SUBAGENT.md +211 -0
- package/skills-library/_general/methodology/CONSISTENCY_CHECK_AMBIGUITY_GATE.md +96 -0
- package/skills-library/_general/methodology/DEAD_ENDS_SHELF.md +4 -4
- package/skills-library/_general/methodology/DISTILL_NOT_DUMP.md +108 -0
- package/skills-library/_general/methodology/EXECUTION_PROGRESS_MONITOR.md +157 -0
- package/skills-library/_general/methodology/HIERARCHICAL_REVIEW_MARS.md +122 -0
- package/skills-library/_general/methodology/MCP_INTER_AGENT_BRIDGE.md +207 -0
- package/skills-library/_general/methodology/MERMAID_WIZARD_DIAGRAMS.md +77 -0
- package/skills-library/_general/methodology/MISSING_DIMENSION_DETECTOR.md +89 -0
- package/skills-library/_general/methodology/MULTI_AGENT_COORDINATION.md +397 -0
- package/skills-library/_general/methodology/OBSERVATION_MASKING.md +100 -0
- package/skills-library/_general/methodology/PHOENIX_REBUILD_METHODOLOGY.md +82 -11
- package/skills-library/_general/methodology/REVIEW_BACKTRACK_PANEL.md +140 -0
- package/skills-library/_general/methodology/REVIEW_FIX_LOOP.md +117 -0
- package/skills-library/_general/methodology/VOTING_VERDICT_ARBITRATION.md +155 -0
- package/skills-library/_general/methodology/ZERO_FRICTION_CLI_SETUP.md +2 -2
- package/skills-library/_general/methodology/dead-code-activation.md +123 -0
- package/skills-library/_general/methodology/debug-swarm-researcher-escape-hatch.md +240 -240
- package/skills-library/_general/methodology/shell-autonomous-loop-fixplan.md +1 -1
- package/skills-library/_general/patterns-standards/GOF_DESIGN_PATTERNS_FOR_AI_AGENTS.md +5 -5
- package/skills-library/_general/patterns-standards/cascading-failure-diagnosis.md +119 -0
- package/skills-library/_general/patterns-standards/domain-specific-layout-algorithms.md +209 -0
- package/skills-library/_general/patterns-standards/python-desktop-app-architecture.md +399 -0
- package/skills-library/_general/patterns-standards/realtime-monitoring-dashboard.md +457 -0
- package/skills-library/_general/patterns-standards/togglable-processing-pipeline.md +169 -0
- package/skills-library/_general/performance/liveclock-extraction.md +112 -0
- package/skills-library/_general/performance/ref-based-canvas-animation.md +117 -0
- package/skills-library/_general/performance/use-visible-interval.md +131 -0
- package/skills-library/_general/testing/playwright-firefox-withcredentials-auth-issue.md +104 -0
- package/skills-library/_quarantine/README.md +30 -0
- package/skills-library/api-patterns/BROADCAST_SCHEDULER_SHARED_EXECUTE_FUNCTION.md +150 -0
- package/skills-library/api-patterns/ERROR_RESPONSE_STANDARDS.md +145 -0
- package/skills-library/api-patterns/EXPRESS_ROUTE_ORDERING_MIDDLEWARE_INTERCEPTION.md +326 -0
- package/skills-library/api-patterns/PAGINATION_PATTERNS.md +137 -0
- package/skills-library/api-patterns/PODCAST_PROGRESS_TRACKING_THREE_ROOT_CAUSES.md +277 -0
- package/skills-library/api-patterns/RATE_LIMITING_TOGGLE.md +155 -0
- package/skills-library/api-patterns/graphql-content-queries.md +708 -0
- package/skills-library/appointment-scheduler-design.md +423 -0
- package/skills-library/automation/AUTO_POPULATE_COMPLETE_GUIDE.md +631 -0
- package/skills-library/automation/CC_WORKFLOW_STUDIO.md +83 -0
- package/skills-library/automation/CLAUDE_CODE_SWARM_MODE.md +95 -0
- package/skills-library/automation/DAEMON_TRIGGER_FILE_IPC.md +195 -0
- package/skills-library/automation/scheduled-content-publishing.md +608 -0
- package/skills-library/awesome-workflows/Blogging-Platform-Instructions/view_commands.md +25 -0
- package/skills-library/awesome-workflows/CREDENTIAL-SECURITY-WORKFLOW.md +109 -0
- package/skills-library/awesome-workflows/DEBUGGING-WORKFLOW.md +124 -0
- package/skills-library/awesome-workflows/Design-Review-Workflow/README.md +31 -0
- package/skills-library/awesome-workflows/Design-Review-Workflow/design-principles-example.md +129 -0
- package/skills-library/awesome-workflows/Design-Review-Workflow/design-review-agent.md +107 -0
- package/skills-library/awesome-workflows/Design-Review-Workflow/design-review-claude-md-snippet.md +24 -0
- package/skills-library/awesome-workflows/Design-Review-Workflow/design-review-slash-command.md +38 -0
- package/skills-library/awesome-workflows/PARALLEL-RESEARCH-WORKFLOW.md +89 -0
- package/skills-library/awesome-workflows/PHASE-EXECUTION-WORKFLOW.md +97 -0
- package/skills-library/awesome-workflows/SESSION-HANDOFF-WORKFLOW.md +116 -0
- package/skills-library/cms-patterns/content-branch-preview.md +515 -0
- package/skills-library/cms-patterns/inline-visual-editing.md +666 -0
- package/skills-library/cms-patterns/mdx-component-content.md +649 -0
- package/skills-library/cms-patterns/media-manager-abstraction.md +827 -0
- package/skills-library/cms-patterns/schema-driven-form-generator.md +838 -0
- package/skills-library/complexity-metrics/complexity-divider.md +707 -0
- package/skills-library/complexity-metrics/work-with-complexity.md +193 -0
- package/skills-library/creative-multimedia/animation-stack-guide.md +577 -0
- package/skills-library/creative-multimedia/audio-enhancement-pipeline.md +625 -0
- package/skills-library/creative-multimedia/content-repurposing-pipeline.md +1146 -0
- package/skills-library/creative-multimedia/data-visualization-generator.md +862 -0
- package/skills-library/creative-multimedia/doc-to-podcast-pipeline.md +2184 -0
- package/skills-library/creative-multimedia/ffmpeg-command-generator.md +405 -0
- package/skills-library/creative-multimedia/image-optimization-pipeline.md +605 -0
- package/skills-library/creative-multimedia/multi-format-content-generator.md +1759 -0
- package/skills-library/creative-multimedia/og-image-generator.md +635 -0
- package/skills-library/creative-multimedia/podcast-audio-composition.md +1355 -0
- package/skills-library/creative-multimedia/podcast-quality-evaluation.md +1452 -0
- package/skills-library/creative-multimedia/podcast-script-generation.md +1841 -0
- package/skills-library/creative-multimedia/svg-generation.md +750 -0
- package/skills-library/creative-multimedia/text-to-speech-provider-selector.md +1414 -0
- package/skills-library/creative-multimedia/transcription-pipeline-selector.md +677 -0
- package/skills-library/creative-multimedia/video-streaming-setup.md +559 -0
- package/skills-library/database-solutions/AI_RESPONSE_DATABASE_CACHING.md +520 -0
- package/skills-library/database-solutions/CONDITIONAL_SQL_MIGRATION_PATTERN.md +119 -0
- package/skills-library/database-solutions/DATABASE_COLUMN_NAME_MISMATCH.md +393 -0
- package/skills-library/database-solutions/DATABASE_SCHEMA.md +394 -0
- package/skills-library/database-solutions/DATABASE_SCHEMA_VERIFICATION_GUIDE.md +348 -0
- package/skills-library/database-solutions/DATABASE_STRATEGY.md +71 -0
- package/skills-library/database-solutions/ES_MODULE_SEED_SCRIPT_PATTERN.md +52 -0
- package/skills-library/database-solutions/MIGRATION_GUIDE.md +3 -0
- package/skills-library/database-solutions/PLPGSQL_VARIABLE_CONFLICT_FIX.md +208 -0
- package/skills-library/database-solutions/POSTGRESQL_JSONB_DOUBLE_STRINGIFY_FIX.md +245 -0
- package/skills-library/database-solutions/POSTGRESQL_LICENSE_TABLE_DESIGN.md +393 -0
- package/skills-library/database-solutions/POSTGRESQL_UUID_DOCUMENT_RAG_DUAL_SCOPE.md +732 -0
- package/skills-library/database-solutions/POSTGRES_SQL_TEMPLATE_BINDING_ERROR.md +240 -0
- package/skills-library/database-solutions/PRISMA_DB_PUSH_DATA_LOSS_PREVENTION.md +141 -0
- package/skills-library/database-solutions/PRODUCTION_QUERY_OPTIMIZATION_RESTART_FIX.md +389 -0
- package/skills-library/database-solutions/RLS_SECURITY_GUIDE.md +107 -0
- package/skills-library/database-solutions/SCHEMA_ENHANCEMENTS_GUIDE.md +373 -0
- package/skills-library/database-solutions/SCHEMA_MIGRATION_GUIDE.md +368 -0
- package/skills-library/database-solutions/SCHEMA_VERIFICATION_QUICK_REFERENCE.md +104 -0
- package/skills-library/database-solutions/ai-erd-generator.md +1213 -0
- package/skills-library/database-solutions/content-publishing-states.md +631 -0
- package/skills-library/database-solutions/database-schema-designer.md +522 -0
- package/skills-library/database-solutions/er-diagram-components.md +569 -0
- package/skills-library/database-solutions/er-to-ddl-mapping.md +1405 -0
- package/skills-library/database-solutions/erd-creator-textbook-research.md +433 -0
- package/skills-library/database-solutions/erd-react-flow-architecture.md +1965 -0
- package/skills-library/database-solutions/mariadb-aggregate-function-replacement.md +145 -0
- package/skills-library/database-solutions/normalization-validator.md +778 -0
- package/skills-library/database-solutions/postgres-full-text-search-content.md +494 -0
- package/skills-library/database-solutions/postgresql-to-mysql-runtime-translation.md +286 -0
- package/skills-library/database-solutions/regex-alternation-ordering-sql-types.md +92 -0
- package/skills-library/database-solutions/reserved-word-context-aware-quoting.md +142 -0
- package/skills-library/database-solutions/sql-ddl-generator.md +756 -0
- package/skills-library/database-solutions/supabase-connection-pooler-fix.md +102 -0
- package/skills-library/deployment-security/CPANEL_NODE_DEPLOYMENT.md +166 -0
- package/skills-library/deployment-security/DEPLOYMENT.md +275 -0
- package/skills-library/deployment-security/DEPLOYMENT_CHECKLIST.md +363 -0
- package/skills-library/deployment-security/DEPLOYMENT_PLAN.md +669 -0
- package/skills-library/deployment-security/KNEX_DATABASE_ABSTRACTION.md +444 -0
- package/skills-library/deployment-security/LICENSE_KEY_SYSTEM.md +206 -0
- package/skills-library/deployment-security/NODE18_DEPENDENCY_COMPATIBILITY.md +284 -0
- package/skills-library/deployment-security/PHP_INSTALLER_WIZARD_GUIDE.md +315 -0
- package/skills-library/deployment-security/PM2_ENVIRONMENT_VARIABLE_CACHING.md +256 -0
- package/skills-library/deployment-security/PM2_MEMORY_EXHAUSTION_FIX.md +370 -0
- package/skills-library/deployment-security/PRODUCTION_DEPLOYMENT_GUIDE.md +592 -0
- package/skills-library/deployment-security/PRODUCTION_HARDENING_DOCUMENTATION.md +307 -0
- package/skills-library/deployment-security/PRODUCTION_RECOVERY_CHERRY_PICK_PATTERN.md +202 -0
- package/skills-library/deployment-security/PYINSTALLER_CUDA_WHISPER_BUNDLING.md +236 -0
- package/skills-library/deployment-security/SECURITY.md +41 -0
- package/skills-library/deployment-security/SMTP_SSL_HOSTNAME_MISMATCH_SHARED_HOSTING.md +220 -0
- package/skills-library/deployment-security/SPA_SEO_OPTIMIZATION_CPANEL.md +200 -0
- package/skills-library/deployment-security/SUPABASE_EDGE_FUNCTIONS.md +338 -0
- package/skills-library/deployment-security/VERCEL_GITHUB_DEPLOYMENT_GUIDE.md +858 -0
- package/skills-library/deployment-security/VPS_DEPLOYMENT_READINESS.md +356 -0
- package/skills-library/deployment-security/deployment-changes-not-applying.md +241 -0
- package/skills-library/deployment-security/env-file-management-production-local.md +203 -0
- package/skills-library/deployment-security/express-secure-file-downloads.md +413 -0
- package/skills-library/deployment-security/react-production-deployment-desktop-guide.md +2011 -0
- package/skills-library/deployment-security/self-hosted-supabase-coolify-guide.md +1684 -0
- package/skills-library/deployment-security/unique-features-ai-strategy-plaid-security.md +1613 -0
- package/skills-library/deployment-security/vps-deployment.md +135 -0
- package/skills-library/document-processing/WORD_EXPORT_MARKDOWN_FORMATTING.md +482 -0
- package/skills-library/document-processing/document-ai-landingai-integration.md +677 -0
- package/skills-library/document-processing/express-secure-file-downloads-mern.md +413 -0
- package/skills-library/document-processing/express-secure-file-downloads.md +413 -0
- package/skills-library/document-processing/md-to-word-converter.md +318 -0
- package/skills-library/document-processing/pdf-forms-integration/README.md +101 -0
- package/skills-library/document-processing/pdf-forms-integration/SKILL.md +662 -0
- package/skills-library/ecommerce/ADMIN_PRODUCTS_GUIDE.md +428 -0
- package/skills-library/ecommerce/ECOMMERCE_API_REFERENCE.md +776 -0
- package/skills-library/ecommerce/ECOMMERCE_COMPLETION_SUMMARY.md +673 -0
- package/skills-library/ecommerce/ECOMMERCE_IMPLEMENTATION_GUIDE.md +729 -0
- package/skills-library/ecommerce/ECOMMERCE_QUICK_REFERENCE.md +521 -0
- package/skills-library/ecommerce/ECOMMERCE_TESTING_CHECKLIST.md +565 -0
- package/skills-library/ecommerce/ECOMMERCE_WORKFLOW_GUIDE.md +1059 -0
- package/skills-library/ecommerce/PRODUCT_CREATION_EXPANDED.md +522 -0
- package/skills-library/ecommerce/agentic-commerce-protocol.md +203 -0
- package/skills-library/ecommerce/cart-abandonment-recovery.md +236 -0
- package/skills-library/ecommerce/cart-architecture-patterns.md +300 -0
- package/skills-library/ecommerce/cart-item-count-indicator.md +264 -0
- package/skills-library/ecommerce/checkout-ux-conversion.md +227 -0
- package/skills-library/ecommerce/composable-commerce-selection.md +166 -0
- package/skills-library/ecommerce/ecommerce-analytics-patterns.md +167 -0
- package/skills-library/ecommerce/fraud-detection-patterns.md +179 -0
- package/skills-library/ecommerce/inventory-stock-management.md +270 -0
- package/skills-library/ecommerce/order-saga-state-machine.md +336 -0
- package/skills-library/ecommerce/payment-provider-abstraction.md +245 -0
- package/skills-library/ecommerce/pci-compliance-checklist.md +192 -0
- package/skills-library/ecommerce/refund-chargeback-handling.md +177 -0
- package/skills-library/ecommerce/shipping-carrier-integration.md +218 -0
- package/skills-library/ecommerce/webhook-idempotency-patterns.md +253 -0
- package/skills-library/excalidraw-diagrams/.github/workflows/ci.yml +558 -0
- package/skills-library/excalidraw-diagrams/.github/workflows/prompt-gallery.yml +448 -0
- package/skills-library/excalidraw-diagrams/.github/workflows/release.yml +42 -0
- package/skills-library/excalidraw-diagrams/.github/workflows/test-reusable-ci.yml +25 -0
- package/skills-library/excalidraw-diagrams/CLAUDE.md +57 -0
- package/skills-library/excalidraw-diagrams/LICENSE +21 -0
- package/skills-library/excalidraw-diagrams/README.md +178 -0
- package/skills-library/excalidraw-diagrams/SKILL.md +715 -0
- package/skills-library/form-solutions/BUTTON_TYPE_FORM_SUBMISSION.md +336 -0
- package/skills-library/form-solutions/FILLABLE_PDF_IMPLEMENTATION.md +226 -0
- package/skills-library/form-solutions/SURVEYJS_QUESTIONNAIRE_SYSTEM.md +367 -0
- package/skills-library/form-solutions/tiptap-minimal-setup.md +690 -0
- package/skills-library/frontend/scholarly-classification-bubble-map.md +149 -0
- package/skills-library/infrastructure/ci-cd-pipeline-builder.md +517 -0
- package/skills-library/infrastructure/observability-designer.md +264 -0
- package/skills-library/infrastructure/performance-profiler.md +621 -0
- package/skills-library/installer-wizard-patterns.md +249 -0
- package/skills-library/integrations/CLAUDE_CODE_TOKEN_ANALYTICS.md +160 -0
- package/skills-library/integrations/CONFIGURABLE_AI_PROVIDER_SELECTION.md +728 -0
- package/skills-library/integrations/SOCKET_IO_BROADCAST_ALL_VS_ROOM.md +141 -0
- package/skills-library/integrations/VIRTUAL_MEETINGS_IMPLEMENTATION.md +374 -0
- package/skills-library/integrations/WORDPRESS_LEARNDASH_DATA_RECOVERY.md +53 -0
- package/skills-library/integrations/YOUTUBE_API_SETUP.md +141 -0
- package/skills-library/integrations/YOUTUBE_BOOKMARKING_EXPLANATION.md +252 -0
- package/skills-library/integrations/YOUTUBE_BOOKMARKING_SOLUTION.md +268 -0
- package/skills-library/integrations/YOUTUBE_OAUTH_SETUP_GUIDE.md +200 -0
- package/skills-library/integrations/YOUTUBE_VIDEO_FIX_COMPLETE.md +192 -0
- package/skills-library/integrations/ai-ml/GEMINI_AI_RAG_PIPELINE_COMPLETE_GUIDE.md +195 -0
- package/skills-library/integrations/ai-ml/GEMINI_IMAGE_GENERATION_SETUP.md +64 -0
- package/skills-library/integrations/cloudflare/cloudflare-turnstile-debugging.md +202 -0
- package/skills-library/integrations/cloudflare/cloudflare-turnstile-implementation.md +476 -0
- package/skills-library/integrations/cloudflare-turnstile-debugging.md +202 -0
- package/skills-library/integrations/cloudflare-turnstile-implementation.md +476 -0
- package/skills-library/integrations/ghost-creator-monetization-pattern.md +454 -0
- package/skills-library/integrations/headless-cms-architecture.md +484 -0
- package/skills-library/integrations/headless-cms-stack-selection.md +183 -0
- package/skills-library/integrations/payload-cms-patterns.md +674 -0
- package/skills-library/integrations/realtimestt-openwakeword-cuda-windows.md +229 -0
- package/skills-library/integrations/rss-podcast-integration.md +300 -0
- package/skills-library/integrations/wordpress/WORDPRESS_LEARNDASH_DATA_RECOVERY.md +53 -0
- package/skills-library/integrations/youtube/YOUTUBE_API_SETUP.md +141 -0
- package/skills-library/integrations/youtube/YOUTUBE_BOOKMARKING_EXPLANATION.md +252 -0
- package/skills-library/integrations/youtube/YOUTUBE_BOOKMARKING_SOLUTION.md +268 -0
- package/skills-library/integrations/youtube/YOUTUBE_OAUTH_SETUP_GUIDE.md +200 -0
- package/skills-library/integrations/youtube/YOUTUBE_VIDEO_FIX_COMPLETE.md +192 -0
- package/skills-library/marketing/campaign-analytics.md +97 -0
- package/skills-library/marketing/content-creator.md +105 -0
- package/skills-library/marketing/marketing-strategy-pmm.md +94 -0
- package/skills-library/marketing/social-media-analyzer.md +81 -0
- package/skills-library/methodology/ADVANCED_ORCHESTRATION_PATTERNS.md +401 -0
- package/skills-library/methodology/AGENT_SELF_IMPROVEMENT_LOOP.md +179 -0
- package/skills-library/methodology/BREATH_BASED_PARALLEL_EXECUTION.md +1 -1
- package/skills-library/methodology/CLEANSING_CYCLE.md +358 -0
- package/skills-library/methodology/CONFIDENCE_ANNOTATION_PATTERN.md +143 -0
- package/skills-library/methodology/CRITICAL_PATTERNS_DOCUMENTATION_COMPLETE.md +204 -0
- package/skills-library/methodology/DELIVERABLES_SUMMARY.md +341 -0
- package/skills-library/methodology/DIFFICULTY_AWARE_AGENT_ROUTING.md +252 -0
- package/skills-library/methodology/EVOLUTIONARY_SKILL_SYNTHESIS.md +219 -0
- package/skills-library/methodology/GLOMERULUS_DECISION_GATE.md +223 -0
- package/skills-library/methodology/HIBERNATION_SYSTEM.md +231 -0
- package/skills-library/methodology/INSTRUMENTATION_OVER_RESTRICTION.md +192 -0
- package/skills-library/methodology/MASTER_COMPLETION_SUMMARY.md +444 -0
- package/skills-library/methodology/MASTER_SESSION_COMPLETION.md +743 -0
- package/skills-library/methodology/MERN_QUICK_REFERENCE.md +358 -0
- package/skills-library/methodology/ORGAN_AGENT_MAPPING.md +177 -0
- package/skills-library/methodology/PARALLEL_WAVE_BASED_REFACTORING.md +440 -0
- package/skills-library/methodology/QUICK_REFERENCE.md +358 -0
- package/skills-library/methodology/SDFT_ONPOLICY_SELF_DISTILLATION.md +186 -0
- package/skills-library/methodology/SELF_QUESTIONING_TASK_GENERATION.md +270 -0
- package/skills-library/methodology/SESSION_COMPLETION_SUMMARY.md +304 -0
- package/skills-library/methodology/SESSION_SUMMARY.md +432 -0
- package/skills-library/methodology/WARRIOR_WORKFLOW_DEBUGGING_PROTOCOL.md +252 -0
- package/skills-library/methodology/tech-debt-tracker.md +570 -0
- package/skills-library/parallel-debug/SKILL.md +60 -0
- package/skills-library/patterns-standards/API_PATTERN_FIX_SUMMARY.md +236 -0
- package/skills-library/patterns-standards/BATCH_OPERATIONS_WITH_PROGRESS_MODAL.md +362 -0
- package/skills-library/patterns-standards/CRITICAL_CODING_PATTERNS.md +639 -0
- package/skills-library/patterns-standards/DARK_MODE_MODAL_VISIBILITY.md +258 -0
- package/skills-library/patterns-standards/ERROR_RESILIENCE_IMPLEMENTATION.md +375 -0
- package/skills-library/patterns-standards/ES_MODULE_IMPORT_HOISTING_DOTENV.md +298 -0
- package/skills-library/patterns-standards/NESTED_BACKDROP_FILTER_CSS_ARTIFACT_FIX.md +76 -0
- package/skills-library/patterns-standards/ORDERED_DETECTOR_PIPELINE_GRACEFUL_FALLBACK.md +333 -0
- package/skills-library/patterns-standards/PHASE_IMPORT_ERROR_DEBUGGING.md +271 -0
- package/skills-library/patterns-standards/PYNPUT_GLOBAL_HOTKEY_VK_MATCHING.md +252 -0
- package/skills-library/patterns-standards/REACT_USEEFFECT_CASCADE_RESET_FIX.md +132 -0
- package/skills-library/patterns-standards/SUBMENU_HOVER_DROPDOWN_PATTERN.md +225 -0
- package/skills-library/patterns-standards/TAILWIND_TEXT_VISIBILITY_OVERRIDE.md +322 -0
- package/skills-library/patterns-standards/THEME_AWARE_CSS_VARIABLES_PATTERN.md +209 -0
- package/skills-library/patterns-standards/THEME_USER_OBJECT_PROPERTY_NAMING.md +194 -0
- package/skills-library/patterns-standards/TOOLTIP_BLOCKING_CLICKS_FIX.md +267 -0
- package/skills-library/patterns-standards/claude-code-plugin-structure.md +235 -0
- package/skills-library/patterns-standards/react-i18next-setup.md +429 -0
- package/skills-library/patterns-standards/thesys-c1-generative-ui-integration.md +967 -0
- package/skills-library/plugin-development/CLAUDE_CODE_COMMAND_REGISTRATION_SILENT_FAILURE.md +315 -0
- package/skills-library/plugin-development/plugin-command-namespace-vs-global.md +390 -0
- package/skills-library/plugin-development/plugin-doc-auto-generation.md +172 -0
- package/skills-library/security/GITHUB_REPO_SECURITY_AUDIT.md +115 -0
- package/skills-library/security/admin-deletion-safety.md +396 -0
- package/skills-library/security/application-vuln-patterns.md +477 -0
- package/skills-library/security/env-secrets-manager.md +686 -0
- package/skills-library/security/secure-ai-application-templates.md +347 -0
- package/skills-library/security/sql-injection-prevention-postgresjs.md +151 -0
- package/skills-library/supabase-connection-pooler-fix.md +102 -0
- package/skills-library/system-context/POWERSHELL_BASH_INTEROP.md +82 -0
- package/skills-library/system-context/SERVICE_LIFECYCLE_MANAGEMENT.md +119 -0
- package/skills-library/system-context/SKILL.md +40 -0
- package/skills-library/system-context/WINDOWS_DEV_ENVIRONMENT.md +73 -0
- package/skills-library/testing/E2E_PLAYWRIGHT_PATTERNS.md +99 -0
- package/skills-library/testing/INTEGRATION_TEST_STRATEGY.md +82 -0
- package/skills-library/testing/RED_GREEN_BUGFIX_GATE.md +203 -0
- package/skills-library/testing/TEST_DATA_MANAGEMENT.md +69 -0
- package/skills-library/testing/VITEST_UNIT_TEST_PATTERNS.md +75 -0
- package/skills-library/testing/playwright-api-security-tests.md +202 -0
- package/skills-library/toolbox/SKILL.md +84 -0
- package/skills-library/toolbox/code-graph-and-web-scraping-mcps.md +237 -0
- package/skills-library/ui-ux-pro-max/ACCESSIBILITY_ESSENTIALS.md +115 -0
- package/skills-library/ui-ux-pro-max/DESIGN_SYSTEM_SCAFFOLDING.md +133 -0
- package/skills-library/ui-ux-pro-max/RESPONSIVE_LAYOUT_PATTERNS.md +119 -0
- package/skills-library/ui-ux-pro-max/SKILL.md +386 -0
- package/skills-library/ui-ux-pro-max/data/charts.csv +26 -0
- package/skills-library/ui-ux-pro-max/data/colors.csv +97 -0
- package/skills-library/ui-ux-pro-max/data/icons.csv +101 -0
- package/skills-library/ui-ux-pro-max/data/landing.csv +31 -0
- package/skills-library/ui-ux-pro-max/data/products.csv +97 -0
- package/skills-library/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/skills-library/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/skills-library/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/skills-library/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/skills-library/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/skills-library/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/skills-library/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/skills-library/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/skills-library/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/skills-library/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/skills-library/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/skills-library/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/skills-library/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/skills-library/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/skills-library/ui-ux-pro-max/data/styles.csv +68 -0
- package/skills-library/ui-ux-pro-max/data/typography.csv +58 -0
- package/skills-library/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/skills-library/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/skills-library/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/skills-library/wordpress-style-theme-components.md +1526 -0
- package/templates/ASSUMPTIONS.md +1 -1
- package/templates/DECISION_LOG.md +0 -1
- package/templates/phase-prompt.md +1 -1
- package/templates/phoenix-comparison.md +6 -6
- package/templates/skill-api-integration.md +106 -0
- package/templates/skill-architecture-pattern.md +92 -0
- package/templates/skill-debug-pattern.md +98 -0
- package/templates/skill-devops-recipe.md +107 -0
- package/templates/skill-general.md +65 -0
- package/templates/skill-ui-component.md +113 -0
- package/version.json +7 -3
- package/workflows/handoff-session.md +2 -2
- package/workflows/new-project.md +2 -2
- package/workflows/plan-phase.md +1 -1
- package/.claude-plugin/plugin.json +0 -64
- package/skills-library/_general/methodology/LIVE_BREADCRUMB_PROTOCOL.md +0 -242
- package/skills-library/_general/methodology/llm-judge-memory-crud.md +0 -241
- package/skills-library/methodology/REFLEXION_MEMORY_PATTERN.md +0 -183
- package/skills-library/methodology/RESEARCH_BACKED_WORKFLOW_UPGRADE.md +0 -263
- package/skills-library/methodology/SABBATH_REST_PATTERN.md +0 -267
- package/skills-library/methodology/STONE_AND_SCAFFOLD.md +0 -220
- package/skills-library/specialists/api-architecture/api-designer.md +0 -49
- package/skills-library/specialists/api-architecture/graphql-architect.md +0 -49
- package/skills-library/specialists/api-architecture/mcp-developer.md +0 -51
- package/skills-library/specialists/api-architecture/microservices-architect.md +0 -50
- package/skills-library/specialists/api-architecture/websocket-engineer.md +0 -48
- package/skills-library/specialists/backend/django-expert.md +0 -52
- package/skills-library/specialists/backend/fastapi-expert.md +0 -52
- package/skills-library/specialists/backend/laravel-specialist.md +0 -52
- package/skills-library/specialists/backend/nestjs-expert.md +0 -51
- package/skills-library/specialists/backend/rails-expert.md +0 -53
- package/skills-library/specialists/backend/spring-boot-engineer.md +0 -56
- package/skills-library/specialists/data-ml/fine-tuning-expert.md +0 -48
- package/skills-library/specialists/data-ml/ml-pipeline.md +0 -47
- package/skills-library/specialists/data-ml/pandas-pro.md +0 -47
- package/skills-library/specialists/data-ml/rag-architect.md +0 -51
- package/skills-library/specialists/data-ml/spark-engineer.md +0 -47
- package/skills-library/specialists/frontend/angular-architect.md +0 -52
- package/skills-library/specialists/frontend/flutter-expert.md +0 -51
- package/skills-library/specialists/frontend/nextjs-developer.md +0 -54
- package/skills-library/specialists/frontend/react-native-expert.md +0 -50
- package/skills-library/specialists/frontend/vue-expert.md +0 -51
- package/skills-library/specialists/infrastructure/chaos-engineer.md +0 -74
- package/skills-library/specialists/infrastructure/cloud-architect.md +0 -70
- package/skills-library/specialists/infrastructure/database-optimizer.md +0 -64
- package/skills-library/specialists/infrastructure/devops-engineer.md +0 -70
- package/skills-library/specialists/infrastructure/kubernetes-specialist.md +0 -52
- package/skills-library/specialists/infrastructure/monitoring-expert.md +0 -70
- package/skills-library/specialists/infrastructure/sre-engineer.md +0 -70
- package/skills-library/specialists/infrastructure/terraform-engineer.md +0 -51
- package/skills-library/specialists/languages/cpp-pro.md +0 -74
- package/skills-library/specialists/languages/csharp-developer.md +0 -69
- package/skills-library/specialists/languages/dotnet-core-expert.md +0 -54
- package/skills-library/specialists/languages/golang-pro.md +0 -51
- package/skills-library/specialists/languages/java-architect.md +0 -49
- package/skills-library/specialists/languages/javascript-pro.md +0 -68
- package/skills-library/specialists/languages/kotlin-specialist.md +0 -68
- package/skills-library/specialists/languages/php-pro.md +0 -49
- package/skills-library/specialists/languages/python-pro.md +0 -52
- package/skills-library/specialists/languages/react-expert.md +0 -51
- package/skills-library/specialists/languages/rust-engineer.md +0 -50
- package/skills-library/specialists/languages/sql-pro.md +0 -56
- package/skills-library/specialists/languages/swift-expert.md +0 -69
- package/skills-library/specialists/languages/typescript-pro.md +0 -51
- package/skills-library/specialists/platform/atlassian-mcp.md +0 -52
- package/skills-library/specialists/platform/embedded-systems.md +0 -53
- package/skills-library/specialists/platform/game-developer.md +0 -53
- package/skills-library/specialists/platform/salesforce-developer.md +0 -53
- package/skills-library/specialists/platform/shopify-expert.md +0 -49
- package/skills-library/specialists/platform/wordpress-pro.md +0 -49
- package/skills-library/specialists/quality/browser-use-expert.md +0 -210
- package/skills-library/specialists/quality/code-documenter.md +0 -51
- package/skills-library/specialists/quality/code-reviewer.md +0 -67
- package/skills-library/specialists/quality/debugging-wizard.md +0 -51
- package/skills-library/specialists/quality/fullstack-guardian.md +0 -51
- package/skills-library/specialists/quality/legacy-modernizer.md +0 -50
- package/skills-library/specialists/quality/playwright-expert.md +0 -65
- package/skills-library/specialists/quality/spec-miner.md +0 -56
- package/skills-library/specialists/quality/test-master.md +0 -65
- package/skills-library/specialists/security/secure-code-guardian.md +0 -55
- package/skills-library/specialists/security/security-reviewer.md +0 -53
- package/skills-library/specialists/workflow/architecture-designer.md +0 -53
- package/skills-library/specialists/workflow/cli-developer.md +0 -70
- package/skills-library/specialists/workflow/feature-forge.md +0 -65
- package/skills-library/specialists/workflow/prompt-engineer.md +0 -54
- package/skills-library/specialists/workflow/the-fool.md +0 -62
- /package/skills-library/{performance → _general/performance}/cache-augmented-generation.md +0 -0
- /package/skills-library/{debugging → parallel-debug}/FAILURE_TAXONOMY_CLASSIFICATION.md +0 -0
- /package/skills-library/{debugging → parallel-debug}/THREE_AGENT_HYPOTHESIS_DEBUGGING.md +0 -0
|
@@ -0,0 +1,1213 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: ai-erd-generator
|
|
3
|
+
category: database-solutions
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
contributed: 2026-03-09
|
|
6
|
+
contributor: fire-research
|
|
7
|
+
last_updated: 2026-03-09
|
|
8
|
+
tags: [ai, erd, llm, natural-language, schema-generation, multi-agent, text2schema]
|
|
9
|
+
difficulty: hard
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# AI-Powered ERD Generator
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Problem
|
|
16
|
+
|
|
17
|
+
Generating database ER diagrams from natural language descriptions requires decomposing ambiguous human requirements into precise entities, relationships, and constraints. Traditional approaches demand a database architect to manually interpret requirements, identify entities, define relationships, assign cardinalities, and produce normalized schemas. This is slow, error-prone, and inaccessible to non-experts.
|
|
18
|
+
|
|
19
|
+
LLMs can now automate this pipeline, but single-prompt approaches fail because:
|
|
20
|
+
- **Entity extraction** and **relationship classification** are fundamentally different reasoning tasks
|
|
21
|
+
- LLMs hallucinate cardinalities (the #1 failure mode per Cogent Education 2025)
|
|
22
|
+
- Single-pass generation misses implicit constraints and cross-entity dependencies
|
|
23
|
+
- No self-verification means errors compound silently
|
|
24
|
+
|
|
25
|
+
The solution: a **multi-agent pipeline** where specialized agents handle decomposed sub-tasks, with explicit verification gates between stages.
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Multi-Agent Pipeline Architecture
|
|
30
|
+
|
|
31
|
+
Inspired by NOMAD (arXiv 2511.22409) and Text2Schema (arXiv 2503.23886). Five agents with clear I/O contracts, each invocable independently or as a chain.
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
NL Requirements
|
|
35
|
+
|
|
|
36
|
+
v
|
|
37
|
+
+---------------------+
|
|
38
|
+
| Agent 1: Entity | NL -> Entity List + Attributes
|
|
39
|
+
| Extractor |
|
|
40
|
+
+---------------------+
|
|
41
|
+
|
|
|
42
|
+
v
|
|
43
|
+
+---------------------+
|
|
44
|
+
| Agent 2: Relationship| Entities + NL -> Relationships + Cardinality
|
|
45
|
+
| Classifier |
|
|
46
|
+
+---------------------+
|
|
47
|
+
|
|
|
48
|
+
v
|
|
49
|
+
+---------------------+
|
|
50
|
+
| Agent 3: Constraint | Entities + Relationships -> PKs, FKs, Constraints
|
|
51
|
+
| Integrator |
|
|
52
|
+
+---------------------+
|
|
53
|
+
|
|
|
54
|
+
v
|
|
55
|
+
+---------------------+
|
|
56
|
+
| Agent 4: Schema | Full Model -> SQL DDL / JSON Schema / Mermaid
|
|
57
|
+
| Articulator |
|
|
58
|
+
+---------------------+
|
|
59
|
+
|
|
|
60
|
+
v
|
|
61
|
+
+---------------------+
|
|
62
|
+
| Agent 5: Verifier | DDL + Original NL -> Validation Report
|
|
63
|
+
| |
|
|
64
|
+
+---------------------+
|
|
65
|
+
|
|
|
66
|
+
v
|
|
67
|
+
Verified ERD + DDL
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## Agent 1: Entity Extractor
|
|
73
|
+
|
|
74
|
+
**Role:** Extract entities and their attributes from natural language requirements.
|
|
75
|
+
|
|
76
|
+
**Input:** Raw natural language description of the system.
|
|
77
|
+
**Output:** Structured JSON of entities with typed attributes.
|
|
78
|
+
|
|
79
|
+
### Prompt Template
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
SYSTEM:
|
|
83
|
+
You are a database entity extraction agent. Your ONLY job is to identify
|
|
84
|
+
entities (nouns that represent storable objects) and their attributes from
|
|
85
|
+
natural language requirements. You do NOT define relationships — another
|
|
86
|
+
agent handles that.
|
|
87
|
+
|
|
88
|
+
Rules:
|
|
89
|
+
1. Each entity must have a clear identity (something that makes instances unique)
|
|
90
|
+
2. Mark the likely primary key attribute with [PK]
|
|
91
|
+
3. Classify each attribute: simple, composite, multivalued, or derived
|
|
92
|
+
4. Flag weak entities that cannot exist without a parent (mark [WEAK])
|
|
93
|
+
5. Include data type suggestions (string, integer, decimal, date, boolean, text, enum)
|
|
94
|
+
6. If an attribute could be an entity itself (has its own attributes), extract it as a separate entity
|
|
95
|
+
7. Do NOT invent attributes not implied by the requirements
|
|
96
|
+
8. DO mark attributes as [REQUIRED] or [OPTIONAL] based on context
|
|
97
|
+
|
|
98
|
+
OUTPUT FORMAT (strict JSON):
|
|
99
|
+
{
|
|
100
|
+
"entities": [
|
|
101
|
+
{
|
|
102
|
+
"name": "EntityName",
|
|
103
|
+
"type": "strong" | "weak",
|
|
104
|
+
"description": "One-line purpose",
|
|
105
|
+
"owner_entity": null | "ParentEntityName",
|
|
106
|
+
"attributes": [
|
|
107
|
+
{
|
|
108
|
+
"name": "attribute_name",
|
|
109
|
+
"data_type": "string|integer|decimal|date|boolean|text|enum|uuid",
|
|
110
|
+
"attribute_type": "simple|composite|multivalued|derived",
|
|
111
|
+
"constraints": ["PK", "REQUIRED", "OPTIONAL", "UNIQUE"],
|
|
112
|
+
"enum_values": ["val1", "val2"],
|
|
113
|
+
"sub_attributes": ["child1", "child2"],
|
|
114
|
+
"derived_from": "source_description",
|
|
115
|
+
"description": "What this attribute represents"
|
|
116
|
+
}
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
"ambiguities": [
|
|
121
|
+
"List anything unclear in the requirements that could affect entity design"
|
|
122
|
+
]
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
USER:
|
|
126
|
+
Extract all database entities and their attributes from the following requirements:
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
{REQUIREMENTS_TEXT}
|
|
130
|
+
---
|
|
131
|
+
|
|
132
|
+
Think step-by-step:
|
|
133
|
+
1. Identify all nouns that represent storable business objects
|
|
134
|
+
2. For each, list its descriptive properties
|
|
135
|
+
3. Determine which attributes are keys, required, or optional
|
|
136
|
+
4. Flag any weak entities
|
|
137
|
+
5. Note ambiguities for human review
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Example Input/Output
|
|
141
|
+
|
|
142
|
+
**Input:**
|
|
143
|
+
> "We need a system for a university. Students enroll in courses. Each course is taught by a professor. Professors belong to departments. Students have names, emails, and phone numbers (they can have multiple). Each course has a code, title, and credit hours. Departments have a name and building location."
|
|
144
|
+
|
|
145
|
+
**Output:**
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"entities": [
|
|
149
|
+
{
|
|
150
|
+
"name": "Student",
|
|
151
|
+
"type": "strong",
|
|
152
|
+
"description": "A person enrolled in the university",
|
|
153
|
+
"owner_entity": null,
|
|
154
|
+
"attributes": [
|
|
155
|
+
{"name": "student_id", "data_type": "uuid", "attribute_type": "simple", "constraints": ["PK"], "description": "Unique student identifier"},
|
|
156
|
+
{"name": "name", "data_type": "string", "attribute_type": "composite", "constraints": ["REQUIRED"], "sub_attributes": ["first_name", "last_name"], "description": "Student full name"},
|
|
157
|
+
{"name": "email", "data_type": "string", "attribute_type": "simple", "constraints": ["REQUIRED", "UNIQUE"], "description": "Student email address"},
|
|
158
|
+
{"name": "phone_numbers", "data_type": "string", "attribute_type": "multivalued", "constraints": ["OPTIONAL"], "description": "Student phone numbers (multiple allowed)"}
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
"name": "Course",
|
|
163
|
+
"type": "strong",
|
|
164
|
+
"description": "An academic course offered by the university",
|
|
165
|
+
"owner_entity": null,
|
|
166
|
+
"attributes": [
|
|
167
|
+
{"name": "course_code", "data_type": "string", "attribute_type": "simple", "constraints": ["PK", "UNIQUE"], "description": "Unique course code (e.g., CS101)"},
|
|
168
|
+
{"name": "title", "data_type": "string", "attribute_type": "simple", "constraints": ["REQUIRED"], "description": "Course title"},
|
|
169
|
+
{"name": "credit_hours", "data_type": "integer", "attribute_type": "simple", "constraints": ["REQUIRED"], "description": "Number of credit hours"}
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"name": "Professor",
|
|
174
|
+
"type": "strong",
|
|
175
|
+
"description": "A faculty member who teaches courses",
|
|
176
|
+
"owner_entity": null,
|
|
177
|
+
"attributes": [
|
|
178
|
+
{"name": "professor_id", "data_type": "uuid", "attribute_type": "simple", "constraints": ["PK"], "description": "Unique professor identifier"},
|
|
179
|
+
{"name": "name", "data_type": "string", "attribute_type": "simple", "constraints": ["REQUIRED"], "description": "Professor name"},
|
|
180
|
+
{"name": "email", "data_type": "string", "attribute_type": "simple", "constraints": ["REQUIRED", "UNIQUE"], "description": "Professor email"}
|
|
181
|
+
]
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"name": "Department",
|
|
185
|
+
"type": "strong",
|
|
186
|
+
"description": "An academic department within the university",
|
|
187
|
+
"owner_entity": null,
|
|
188
|
+
"attributes": [
|
|
189
|
+
{"name": "department_id", "data_type": "uuid", "attribute_type": "simple", "constraints": ["PK"], "description": "Unique department identifier"},
|
|
190
|
+
{"name": "name", "data_type": "string", "attribute_type": "simple", "constraints": ["REQUIRED", "UNIQUE"], "description": "Department name"},
|
|
191
|
+
{"name": "building", "data_type": "string", "attribute_type": "simple", "constraints": ["OPTIONAL"], "description": "Building location"}
|
|
192
|
+
]
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
"ambiguities": [
|
|
196
|
+
"Should professors have a department_id FK or can they belong to multiple departments?",
|
|
197
|
+
"Is enrollment a simple relationship or does it carry attributes (grade, semester, enrollment_date)?",
|
|
198
|
+
"Can a course be taught by multiple professors (team-teaching)?"
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
---
|
|
204
|
+
|
|
205
|
+
## Agent 2: Relationship Classifier
|
|
206
|
+
|
|
207
|
+
**Role:** Identify all relationships between entities, classify cardinality and participation.
|
|
208
|
+
|
|
209
|
+
**Input:** Entity list (from Agent 1) + original NL requirements.
|
|
210
|
+
**Output:** Structured JSON of relationships with cardinality and participation.
|
|
211
|
+
|
|
212
|
+
### Prompt Template
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
SYSTEM:
|
|
216
|
+
You are a database relationship classification agent. Given a list of entities
|
|
217
|
+
and the original requirements, identify ALL relationships between entities.
|
|
218
|
+
|
|
219
|
+
Rules:
|
|
220
|
+
1. Classify each relationship: 1:1, 1:N, or M:N
|
|
221
|
+
2. Determine participation: total (mandatory) or partial (optional) for EACH side
|
|
222
|
+
3. Identify relationship attributes (properties of the relationship itself, not the entities)
|
|
223
|
+
4. Flag recursive/unary relationships (entity relates to itself)
|
|
224
|
+
5. For M:N relationships, note that a junction table will be needed
|
|
225
|
+
6. CRITICAL: Cardinalities are the #1 error source in LLM-generated ERDs.
|
|
226
|
+
For each cardinality, provide your reasoning. Ask: "Can ONE instance of A
|
|
227
|
+
be associated with MANY instances of B? Can ONE instance of B be associated
|
|
228
|
+
with MANY instances of A?"
|
|
229
|
+
7. When uncertain about cardinality, default to the MORE FLEXIBLE option (M:N)
|
|
230
|
+
and flag for human review — it is easier to tighten than to loosen later
|
|
231
|
+
|
|
232
|
+
OUTPUT FORMAT (strict JSON):
|
|
233
|
+
{
|
|
234
|
+
"relationships": [
|
|
235
|
+
{
|
|
236
|
+
"name": "descriptive_verb_phrase",
|
|
237
|
+
"entity_a": "EntityName",
|
|
238
|
+
"entity_b": "EntityName",
|
|
239
|
+
"cardinality": "1:1" | "1:N" | "M:N",
|
|
240
|
+
"participation_a": "total" | "partial",
|
|
241
|
+
"participation_b": "total" | "partial",
|
|
242
|
+
"cardinality_reasoning": "Explain WHY this cardinality was chosen",
|
|
243
|
+
"relationship_attributes": [
|
|
244
|
+
{"name": "attr", "data_type": "type", "description": "purpose"}
|
|
245
|
+
],
|
|
246
|
+
"is_identifying": false,
|
|
247
|
+
"notes": "Any special considerations"
|
|
248
|
+
}
|
|
249
|
+
],
|
|
250
|
+
"cardinality_warnings": [
|
|
251
|
+
"List relationships where cardinality is ambiguous and needs human confirmation"
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
USER:
|
|
256
|
+
Given these entities:
|
|
257
|
+
```json
|
|
258
|
+
{ENTITIES_JSON}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
And the original requirements:
|
|
262
|
+
---
|
|
263
|
+
{REQUIREMENTS_TEXT}
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
Identify all relationships. For each, explain your cardinality reasoning step-by-step.
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Cardinality Reasoning Template (from Cogent Education 2025)
|
|
270
|
+
|
|
271
|
+
For every relationship, the agent must answer these four questions:
|
|
272
|
+
|
|
273
|
+
1. **Can one A have many B?** (yes/no + why)
|
|
274
|
+
2. **Can one B have many A?** (yes/no + why)
|
|
275
|
+
3. **Must every A have at least one B?** (total/partial participation)
|
|
276
|
+
4. **Must every B have at least one A?** (total/partial participation)
|
|
277
|
+
|
|
278
|
+
If both Q1 and Q2 are "yes" => M:N. If only Q1 => 1:N. If neither => 1:1.
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Agent 3: Constraint Integrator
|
|
283
|
+
|
|
284
|
+
**Role:** Synthesize entities and relationships into a complete logical model with all constraints.
|
|
285
|
+
|
|
286
|
+
**Input:** Entities (Agent 1) + Relationships (Agent 2).
|
|
287
|
+
**Output:** Complete logical schema with PKs, FKs, constraints, and junction tables.
|
|
288
|
+
|
|
289
|
+
### Prompt Template
|
|
290
|
+
|
|
291
|
+
```
|
|
292
|
+
SYSTEM:
|
|
293
|
+
You are a database constraint integration agent. Given entities and relationships,
|
|
294
|
+
produce a complete logical data model with all constraints properly assigned.
|
|
295
|
+
|
|
296
|
+
Rules:
|
|
297
|
+
1. Apply ER-to-schema mapping rules:
|
|
298
|
+
- Strong entity -> table with PK
|
|
299
|
+
- Weak entity -> table with composite PK (partial key + owner PK)
|
|
300
|
+
- 1:1 -> FK on the total-participation side
|
|
301
|
+
- 1:N -> FK on the "many" side
|
|
302
|
+
- M:N -> junction table with composite PK
|
|
303
|
+
- Multivalued attribute -> separate table with FK back to entity
|
|
304
|
+
2. Flatten composite attributes to leaf-level columns
|
|
305
|
+
3. Assign ON DELETE actions:
|
|
306
|
+
- CASCADE for weak entities and junction tables
|
|
307
|
+
- SET NULL for optional relationships
|
|
308
|
+
- RESTRICT for critical parent references
|
|
309
|
+
4. Add standard columns: created_at, updated_at (all tables)
|
|
310
|
+
5. Suggest indexes for all FK columns and common query patterns
|
|
311
|
+
6. Flag any normalization concerns (1NF/2NF/3NF violations)
|
|
312
|
+
|
|
313
|
+
OUTPUT FORMAT (strict JSON):
|
|
314
|
+
{
|
|
315
|
+
"tables": [
|
|
316
|
+
{
|
|
317
|
+
"name": "table_name",
|
|
318
|
+
"source": "entity" | "junction" | "multivalued",
|
|
319
|
+
"columns": [
|
|
320
|
+
{
|
|
321
|
+
"name": "column_name",
|
|
322
|
+
"data_type": "VARCHAR(100)|INTEGER|UUID|TIMESTAMPTZ|...",
|
|
323
|
+
"constraints": ["PRIMARY KEY", "NOT NULL", "UNIQUE", "DEFAULT NOW()"],
|
|
324
|
+
"foreign_key": {
|
|
325
|
+
"references_table": "other_table",
|
|
326
|
+
"references_column": "id",
|
|
327
|
+
"on_delete": "CASCADE|SET NULL|RESTRICT",
|
|
328
|
+
"on_update": "CASCADE"
|
|
329
|
+
} | null
|
|
330
|
+
}
|
|
331
|
+
],
|
|
332
|
+
"indexes": [
|
|
333
|
+
{"columns": ["col1", "col2"], "unique": false, "partial": null}
|
|
334
|
+
],
|
|
335
|
+
"notes": "Design rationale"
|
|
336
|
+
}
|
|
337
|
+
],
|
|
338
|
+
"normalization_warnings": ["Any 1NF/2NF/3NF concerns"],
|
|
339
|
+
"design_decisions": ["Explain non-obvious choices"]
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
USER:
|
|
343
|
+
Integrate these entities and relationships into a complete logical schema:
|
|
344
|
+
|
|
345
|
+
Entities:
|
|
346
|
+
```json
|
|
347
|
+
{ENTITIES_JSON}
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
Relationships:
|
|
351
|
+
```json
|
|
352
|
+
{RELATIONSHIPS_JSON}
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
Apply all ER-to-schema mapping rules and produce the complete table definitions.
|
|
356
|
+
```
|
|
357
|
+
|
|
358
|
+
---
|
|
359
|
+
|
|
360
|
+
## Agent 4: Schema Articulator
|
|
361
|
+
|
|
362
|
+
**Role:** Transform the logical model into deployable artifacts (SQL DDL, Mermaid ERD, JSON Schema).
|
|
363
|
+
|
|
364
|
+
**Input:** Complete logical model (from Agent 3).
|
|
365
|
+
**Output:** SQL DDL, Mermaid diagram, and optionally JSON Schema or ORM definitions.
|
|
366
|
+
|
|
367
|
+
### Prompt Template
|
|
368
|
+
|
|
369
|
+
```
|
|
370
|
+
SYSTEM:
|
|
371
|
+
You are a schema articulation agent. Given a complete logical data model,
|
|
372
|
+
generate deployment-ready artifacts in the requested formats.
|
|
373
|
+
|
|
374
|
+
Supported output formats:
|
|
375
|
+
- SQL DDL (PostgreSQL, MySQL, or SQLite — specify target)
|
|
376
|
+
- Mermaid ERD diagram
|
|
377
|
+
- JSON Schema (for API validation)
|
|
378
|
+
- Prisma schema
|
|
379
|
+
- Drizzle schema (TypeScript)
|
|
380
|
+
|
|
381
|
+
Rules:
|
|
382
|
+
1. Use the target database's native syntax and types
|
|
383
|
+
2. Include all constraints (PK, FK, UNIQUE, CHECK, NOT NULL, DEFAULT)
|
|
384
|
+
3. Name constraints explicitly: pk_tablename, fk_table_column, uq_table_column
|
|
385
|
+
4. Add CREATE INDEX statements for all FKs and suggested indexes
|
|
386
|
+
5. Order CREATE TABLE statements respecting FK dependencies (parents before children)
|
|
387
|
+
6. Include comments explaining non-obvious design decisions
|
|
388
|
+
7. For Mermaid: use Crow's Foot notation with PK/FK markers
|
|
389
|
+
|
|
390
|
+
OUTPUT FORMAT:
|
|
391
|
+
Return each artifact in a clearly labeled code block.
|
|
392
|
+
|
|
393
|
+
USER:
|
|
394
|
+
Generate the following artifacts from this logical schema:
|
|
395
|
+
|
|
396
|
+
Target database: {TARGET_DB}
|
|
397
|
+
Requested formats: {FORMATS_LIST}
|
|
398
|
+
|
|
399
|
+
Schema:
|
|
400
|
+
```json
|
|
401
|
+
{LOGICAL_SCHEMA_JSON}
|
|
402
|
+
```
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### Mermaid Output Template
|
|
406
|
+
|
|
407
|
+
```mermaid
|
|
408
|
+
erDiagram
|
|
409
|
+
%% Generated by AI ERD Pipeline
|
|
410
|
+
%% Source: [original requirements summary]
|
|
411
|
+
|
|
412
|
+
Student ||--o{ Enrollment : "enrolls in"
|
|
413
|
+
Course ||--o{ Enrollment : "has"
|
|
414
|
+
Professor ||--o{ Course : "teaches"
|
|
415
|
+
Department ||--o{ Professor : "employs"
|
|
416
|
+
|
|
417
|
+
Student {
|
|
418
|
+
uuid student_id PK
|
|
419
|
+
varchar first_name
|
|
420
|
+
varchar last_name
|
|
421
|
+
varchar email UK
|
|
422
|
+
timestamptz created_at
|
|
423
|
+
timestamptz updated_at
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
Course {
|
|
427
|
+
varchar course_code PK
|
|
428
|
+
varchar title
|
|
429
|
+
integer credit_hours
|
|
430
|
+
uuid professor_id FK
|
|
431
|
+
timestamptz created_at
|
|
432
|
+
timestamptz updated_at
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
Enrollment {
|
|
436
|
+
uuid student_id PK,FK
|
|
437
|
+
varchar course_code PK,FK
|
|
438
|
+
date enrollment_date
|
|
439
|
+
varchar grade
|
|
440
|
+
}
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## Agent 5: Verifier
|
|
446
|
+
|
|
447
|
+
**Role:** Validate the generated schema against the original requirements. Catch hallucinations, missing entities, wrong cardinalities.
|
|
448
|
+
|
|
449
|
+
**Input:** Generated DDL/schema (Agent 4) + original NL requirements.
|
|
450
|
+
**Output:** Validation report with pass/fail/warning for each check.
|
|
451
|
+
|
|
452
|
+
### Prompt Template
|
|
453
|
+
|
|
454
|
+
```
|
|
455
|
+
SYSTEM:
|
|
456
|
+
You are a database schema verification agent. Given a generated schema and the
|
|
457
|
+
original requirements, validate completeness and correctness.
|
|
458
|
+
|
|
459
|
+
Perform these checks:
|
|
460
|
+
|
|
461
|
+
STRUCTURAL CHECKS:
|
|
462
|
+
1. Every entity in requirements has a corresponding table
|
|
463
|
+
2. Every relationship in requirements is represented (FK or junction table)
|
|
464
|
+
3. No orphan tables (tables with no relationships)
|
|
465
|
+
4. All PKs are defined
|
|
466
|
+
5. All FK references point to existing tables and columns
|
|
467
|
+
6. Junction tables exist for all M:N relationships
|
|
468
|
+
|
|
469
|
+
SEMANTIC CHECKS:
|
|
470
|
+
7. Cardinality matches requirements (the #1 failure mode)
|
|
471
|
+
8. Participation constraints match (total vs partial)
|
|
472
|
+
9. No attributes are missing from the requirements
|
|
473
|
+
10. No hallucinated attributes (invented by the AI, not in requirements)
|
|
474
|
+
11. Naming is consistent (snake_case, singular table names or plural — pick one)
|
|
475
|
+
|
|
476
|
+
NORMALIZATION CHECKS:
|
|
477
|
+
12. No 1NF violations (no arrays or comma-separated values in columns)
|
|
478
|
+
13. No 2NF violations (partial dependencies in composite PKs)
|
|
479
|
+
14. No 3NF violations (transitive dependencies)
|
|
480
|
+
|
|
481
|
+
COMPLETENESS CHECKS:
|
|
482
|
+
15. Standard columns present (created_at, updated_at)
|
|
483
|
+
16. Indexes on all FK columns
|
|
484
|
+
17. ON DELETE actions specified for all FKs
|
|
485
|
+
18. UNIQUE constraints where implied by requirements
|
|
486
|
+
|
|
487
|
+
OUTPUT FORMAT (strict JSON):
|
|
488
|
+
{
|
|
489
|
+
"overall_status": "PASS" | "FAIL" | "PASS_WITH_WARNINGS",
|
|
490
|
+
"checks": [
|
|
491
|
+
{
|
|
492
|
+
"id": 1,
|
|
493
|
+
"category": "structural|semantic|normalization|completeness",
|
|
494
|
+
"description": "What was checked",
|
|
495
|
+
"status": "PASS" | "FAIL" | "WARNING",
|
|
496
|
+
"details": "Explanation of finding",
|
|
497
|
+
"fix_suggestion": "How to fix (if FAIL or WARNING)"
|
|
498
|
+
}
|
|
499
|
+
],
|
|
500
|
+
"missing_from_requirements": ["Things in requirements not in schema"],
|
|
501
|
+
"hallucinated_additions": ["Things in schema not in requirements"],
|
|
502
|
+
"cardinality_review": [
|
|
503
|
+
{
|
|
504
|
+
"relationship": "A -> B",
|
|
505
|
+
"generated": "1:N",
|
|
506
|
+
"assessment": "CORRECT" | "SUSPECT" | "WRONG",
|
|
507
|
+
"reasoning": "Why"
|
|
508
|
+
}
|
|
509
|
+
],
|
|
510
|
+
"summary": "One-paragraph assessment"
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
USER:
|
|
514
|
+
Verify this generated schema against the original requirements.
|
|
515
|
+
|
|
516
|
+
Original requirements:
|
|
517
|
+
---
|
|
518
|
+
{REQUIREMENTS_TEXT}
|
|
519
|
+
---
|
|
520
|
+
|
|
521
|
+
Generated DDL:
|
|
522
|
+
```sql
|
|
523
|
+
{GENERATED_DDL}
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
Generated entity/relationship model:
|
|
527
|
+
```json
|
|
528
|
+
{LOGICAL_SCHEMA_JSON}
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
Check every requirement is satisfied. Flag anything suspicious.
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
### Error Taxonomy (from NOMAD)
|
|
535
|
+
|
|
536
|
+
The verifier classifies errors into three categories:
|
|
537
|
+
|
|
538
|
+
| Category | Examples | Severity |
|
|
539
|
+
|----------|----------|----------|
|
|
540
|
+
| **Structural** | Missing table, missing column, wrong PK, orphan table | HIGH |
|
|
541
|
+
| **Relationship** | Wrong cardinality, missing FK, missing junction table, wrong ON DELETE | HIGH |
|
|
542
|
+
| **Semantic/Logical** | Hallucinated attribute, wrong data type, naming inconsistency, missing constraint | MEDIUM |
|
|
543
|
+
|
|
544
|
+
---
|
|
545
|
+
|
|
546
|
+
## Known LLM Weaknesses & Mitigations
|
|
547
|
+
|
|
548
|
+
Based on Cogent Education 2025, DiagramEval (EMNLP 2025), and Springer ER 2025:
|
|
549
|
+
|
|
550
|
+
### Weakness 1: Cardinality Hallucination (CRITICAL)
|
|
551
|
+
|
|
552
|
+
**Problem:** LLMs default to 1:N when the actual relationship is M:N, or vice versa. This is the single most common error in LLM-generated ERDs.
|
|
553
|
+
|
|
554
|
+
**Evidence:** Cogent Education 2025 found that Chain-of-Thought prompting improves Chen notation cardinality accuracy but produces *mixed results* for Crow's Foot notation.
|
|
555
|
+
|
|
556
|
+
**Mitigation:**
|
|
557
|
+
- Force explicit cardinality reasoning (Agent 2 requires step-by-step justification)
|
|
558
|
+
- Always flag cardinalities for human confirmation in the verification step
|
|
559
|
+
- Default to M:N when ambiguous (easier to tighten than loosen)
|
|
560
|
+
- Use the four-question framework: "Can one A have many B? Can one B have many A? Must A have B? Must B have A?"
|
|
561
|
+
|
|
562
|
+
### Weakness 2: Domain Alignment Drift
|
|
563
|
+
|
|
564
|
+
**Problem:** LLMs inject generic patterns (user/role/permission tables) even when the domain does not call for them.
|
|
565
|
+
|
|
566
|
+
**Evidence:** Springer ER 2025 identifies "domain alignment" as one of three core LLM weaknesses for data modeling.
|
|
567
|
+
|
|
568
|
+
**Mitigation:**
|
|
569
|
+
- Agent 5 (Verifier) explicitly checks for hallucinated additions not in requirements
|
|
570
|
+
- Entity Extractor rule: "Do NOT invent attributes not implied by the requirements"
|
|
571
|
+
- Include domain context in the system prompt when available
|
|
572
|
+
|
|
573
|
+
### Weakness 3: Formalism Generation Errors
|
|
574
|
+
|
|
575
|
+
**Problem:** LLMs produce syntactically invalid DDL, especially for constraints, CHECK clauses, and database-specific syntax.
|
|
576
|
+
|
|
577
|
+
**Evidence:** Springer ER 2025 identifies "formalism generation" as a core weakness.
|
|
578
|
+
|
|
579
|
+
**Mitigation:**
|
|
580
|
+
- Agent 4 uses explicit DDL templates with named constraints
|
|
581
|
+
- Validate generated DDL by attempting to parse/execute it (dry run)
|
|
582
|
+
- Target one database dialect at a time (do not mix PG and MySQL syntax)
|
|
583
|
+
|
|
584
|
+
### Weakness 4: Implicit Requirements
|
|
585
|
+
|
|
586
|
+
**Problem:** Requirements often imply entities and constraints that are not explicitly stated. "Users can place orders" implies an Order table, order items, timestamps, and status tracking.
|
|
587
|
+
|
|
588
|
+
**Mitigation:**
|
|
589
|
+
- Agent 1 includes an "ambiguities" field to surface what is implied but not stated
|
|
590
|
+
- Prompt includes: "If an attribute could be an entity itself, extract it as a separate entity"
|
|
591
|
+
- Verifier checks for common implied patterns (audit fields, status enums, soft deletes)
|
|
592
|
+
|
|
593
|
+
---
|
|
594
|
+
|
|
595
|
+
## Quality Evaluation (DiagramEval Metrics)
|
|
596
|
+
|
|
597
|
+
From DiagramEval (EMNLP 2025) — the first benchmark for evaluating LLM-generated diagrams.
|
|
598
|
+
|
|
599
|
+
### Node Alignment Score
|
|
600
|
+
|
|
601
|
+
Measures whether generated entities match expected entities.
|
|
602
|
+
|
|
603
|
+
```
|
|
604
|
+
Node Alignment = |correct_entities intersection generated_entities|
|
|
605
|
+
/ max(|correct_entities|, |generated_entities|)
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
- **1.0** = perfect entity extraction
|
|
609
|
+
- **< 0.8** = missing or hallucinated entities, needs review
|
|
610
|
+
|
|
611
|
+
### Path Alignment Score
|
|
612
|
+
|
|
613
|
+
Measures whether relationships (paths between entities) are correct.
|
|
614
|
+
|
|
615
|
+
```
|
|
616
|
+
Path Alignment = |correct_paths intersection generated_paths|
|
|
617
|
+
/ max(|correct_paths|, |generated_paths|)
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
- Limitation: path metrics miss cardinality and participation details
|
|
621
|
+
- Supplement with explicit cardinality review (Agent 5)
|
|
622
|
+
|
|
623
|
+
### Practical Scoring
|
|
624
|
+
|
|
625
|
+
When evaluating a generated ERD:
|
|
626
|
+
|
|
627
|
+
1. Count entities: generated vs expected. Missing = structural error. Extra = hallucination.
|
|
628
|
+
2. Count relationships: generated vs expected. Missing = structural error. Extra = hallucination.
|
|
629
|
+
3. For each relationship: is cardinality correct? (the most important check)
|
|
630
|
+
4. For each entity: are all required attributes present?
|
|
631
|
+
5. Overall score = weighted average: entities (30%) + relationships (30%) + cardinalities (25%) + attributes (15%)
|
|
632
|
+
|
|
633
|
+
### Benchmark Results (DiagramEval)
|
|
634
|
+
|
|
635
|
+
| Model | Node Alignment | Path Alignment | Best For |
|
|
636
|
+
|-------|---------------|----------------|----------|
|
|
637
|
+
| Claude 3.7 Sonnet | Best on 4/6 metrics | Strong | Overall generation |
|
|
638
|
+
| Gemini 2.0 Flash | Competitive | Good | Speed/cost tradeoff |
|
|
639
|
+
| GPT-4o | Good | Mixed | Fallback option |
|
|
640
|
+
|
|
641
|
+
---
|
|
642
|
+
|
|
643
|
+
## MCP Integration Pattern (ERFlow-Inspired)
|
|
644
|
+
|
|
645
|
+
Expose ERD operations as MCP tools for CLI/IDE access. Based on ERFlow MCP Server (25+ tools for NL schema edits).
|
|
646
|
+
|
|
647
|
+
### Tool Definitions
|
|
648
|
+
|
|
649
|
+
```typescript
|
|
650
|
+
// MCP tool registration for ERD operations
|
|
651
|
+
const erdTools = [
|
|
652
|
+
{
|
|
653
|
+
name: "erd_generate",
|
|
654
|
+
description: "Generate ERD from natural language requirements",
|
|
655
|
+
inputSchema: {
|
|
656
|
+
type: "object",
|
|
657
|
+
properties: {
|
|
658
|
+
requirements: { type: "string", description: "Natural language system description" },
|
|
659
|
+
target_db: { type: "string", enum: ["postgresql", "mysql", "sqlite"], default: "postgresql" },
|
|
660
|
+
output_formats: {
|
|
661
|
+
type: "array",
|
|
662
|
+
items: { type: "string", enum: ["ddl", "mermaid", "json_schema", "prisma", "drizzle"] },
|
|
663
|
+
default: ["ddl", "mermaid"]
|
|
664
|
+
}
|
|
665
|
+
},
|
|
666
|
+
required: ["requirements"]
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
{
|
|
670
|
+
name: "erd_modify",
|
|
671
|
+
description: "Modify existing ERD with natural language instruction",
|
|
672
|
+
inputSchema: {
|
|
673
|
+
type: "object",
|
|
674
|
+
properties: {
|
|
675
|
+
current_schema: { type: "string", description: "Current DDL or JSON schema" },
|
|
676
|
+
modification: { type: "string", description: "NL description of change" }
|
|
677
|
+
},
|
|
678
|
+
required: ["current_schema", "modification"]
|
|
679
|
+
}
|
|
680
|
+
},
|
|
681
|
+
{
|
|
682
|
+
name: "erd_validate",
|
|
683
|
+
description: "Validate ERD against requirements",
|
|
684
|
+
inputSchema: {
|
|
685
|
+
type: "object",
|
|
686
|
+
properties: {
|
|
687
|
+
schema: { type: "string", description: "DDL or JSON schema to validate" },
|
|
688
|
+
requirements: { type: "string", description: "Original requirements to check against" }
|
|
689
|
+
},
|
|
690
|
+
required: ["schema", "requirements"]
|
|
691
|
+
}
|
|
692
|
+
},
|
|
693
|
+
{
|
|
694
|
+
name: "erd_reverse_engineer",
|
|
695
|
+
description: "Generate ERD from existing DDL or data samples",
|
|
696
|
+
inputSchema: {
|
|
697
|
+
type: "object",
|
|
698
|
+
properties: {
|
|
699
|
+
source: { type: "string", description: "SQL DDL, CSV headers, or JSON data sample" },
|
|
700
|
+
source_type: { type: "string", enum: ["ddl", "csv", "json", "prisma"] }
|
|
701
|
+
},
|
|
702
|
+
required: ["source", "source_type"]
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
];
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
### Integration with Claude Code
|
|
709
|
+
|
|
710
|
+
```bash
|
|
711
|
+
# Add ERD MCP server to Claude Code config
|
|
712
|
+
claude mcp add erd-generator -- node /path/to/erd-mcp-server.js
|
|
713
|
+
|
|
714
|
+
# Then use from CLI:
|
|
715
|
+
# "Generate an ERD for an e-commerce system with products, orders, and users"
|
|
716
|
+
# "Add a reviews table to this schema"
|
|
717
|
+
# "Validate this DDL against the original requirements"
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
---
|
|
721
|
+
|
|
722
|
+
## Implementation Modes
|
|
723
|
+
|
|
724
|
+
### Mode 1: Full Generation (NL -> Complete ERD)
|
|
725
|
+
|
|
726
|
+
The primary use case. Run all 5 agents in sequence.
|
|
727
|
+
|
|
728
|
+
```
|
|
729
|
+
Input: "I need a database for a blog platform. Users write posts.
|
|
730
|
+
Posts have categories and tags. Users can comment on posts.
|
|
731
|
+
Comments can be nested (replies to comments)."
|
|
732
|
+
|
|
733
|
+
Pipeline: Agent 1 -> Agent 2 -> Agent 3 -> Agent 4 -> Agent 5
|
|
734
|
+
Output: SQL DDL + Mermaid ERD + Validation Report
|
|
735
|
+
```
|
|
736
|
+
|
|
737
|
+
### Mode 2: Iterative Refinement (NL Edits to Existing ERD)
|
|
738
|
+
|
|
739
|
+
Modify an existing schema with natural language instructions. Only runs Agents 3-5.
|
|
740
|
+
|
|
741
|
+
```
|
|
742
|
+
Input: Current DDL + "Add a bookmarks feature where users can save posts"
|
|
743
|
+
Pipeline: Agent 3 (integrate new entity) -> Agent 4 (regenerate DDL) -> Agent 5 (verify)
|
|
744
|
+
Output: Updated DDL + diff showing changes
|
|
745
|
+
```
|
|
746
|
+
|
|
747
|
+
### Mode 3: Reverse Engineering (Data/DDL -> ERD)
|
|
748
|
+
|
|
749
|
+
Start from existing artifacts and produce a visual ERD + documentation.
|
|
750
|
+
|
|
751
|
+
```
|
|
752
|
+
Input: Existing SQL DDL dump or Prisma schema
|
|
753
|
+
Pipeline: Parse DDL -> Agent 4 (generate Mermaid) -> Agent 5 (identify issues)
|
|
754
|
+
Output: Mermaid ERD + normalization warnings + improvement suggestions
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
### Mode 4: Requirements Upload (PDF/Doc -> ERD)
|
|
758
|
+
|
|
759
|
+
Extract requirements from documents, then run full pipeline.
|
|
760
|
+
|
|
761
|
+
```
|
|
762
|
+
Input: PDF or text document with business requirements
|
|
763
|
+
Pipeline: Extract text -> Agent 1 -> Agent 2 -> Agent 3 -> Agent 4 -> Agent 5
|
|
764
|
+
Output: Full ERD + traceability matrix (which requirement -> which table)
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
---
|
|
768
|
+
|
|
769
|
+
## Code Example: Multi-Agent Pipeline Orchestrator
|
|
770
|
+
|
|
771
|
+
A complete TypeScript implementation that orchestrates all 5 agents. Uses Claude or Gemini API (never OpenAI).
|
|
772
|
+
|
|
773
|
+
```typescript
|
|
774
|
+
// erd-pipeline.ts — Multi-agent ERD generation pipeline
|
|
775
|
+
// Works with Anthropic Claude or Google Gemini APIs
|
|
776
|
+
|
|
777
|
+
import Anthropic from "@anthropic-ai/sdk";
|
|
778
|
+
|
|
779
|
+
// ── Types ────────────────────────────────────────────────────────────────────
|
|
780
|
+
|
|
781
|
+
interface Entity {
|
|
782
|
+
name: string;
|
|
783
|
+
type: "strong" | "weak";
|
|
784
|
+
description: string;
|
|
785
|
+
owner_entity: string | null;
|
|
786
|
+
attributes: Attribute[];
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
interface Attribute {
|
|
790
|
+
name: string;
|
|
791
|
+
data_type: string;
|
|
792
|
+
attribute_type: "simple" | "composite" | "multivalued" | "derived";
|
|
793
|
+
constraints: string[];
|
|
794
|
+
enum_values?: string[];
|
|
795
|
+
sub_attributes?: string[];
|
|
796
|
+
derived_from?: string;
|
|
797
|
+
description: string;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
interface Relationship {
|
|
801
|
+
name: string;
|
|
802
|
+
entity_a: string;
|
|
803
|
+
entity_b: string;
|
|
804
|
+
cardinality: "1:1" | "1:N" | "M:N";
|
|
805
|
+
participation_a: "total" | "partial";
|
|
806
|
+
participation_b: "total" | "partial";
|
|
807
|
+
cardinality_reasoning: string;
|
|
808
|
+
relationship_attributes: { name: string; data_type: string; description: string }[];
|
|
809
|
+
is_identifying: boolean;
|
|
810
|
+
notes: string;
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
interface TableColumn {
|
|
814
|
+
name: string;
|
|
815
|
+
data_type: string;
|
|
816
|
+
constraints: string[];
|
|
817
|
+
foreign_key: {
|
|
818
|
+
references_table: string;
|
|
819
|
+
references_column: string;
|
|
820
|
+
on_delete: string;
|
|
821
|
+
on_update: string;
|
|
822
|
+
} | null;
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
interface Table {
|
|
826
|
+
name: string;
|
|
827
|
+
source: "entity" | "junction" | "multivalued";
|
|
828
|
+
columns: TableColumn[];
|
|
829
|
+
indexes: { columns: string[]; unique: boolean; partial: string | null }[];
|
|
830
|
+
notes: string;
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
interface VerificationResult {
|
|
834
|
+
overall_status: "PASS" | "FAIL" | "PASS_WITH_WARNINGS";
|
|
835
|
+
checks: {
|
|
836
|
+
id: number;
|
|
837
|
+
category: string;
|
|
838
|
+
description: string;
|
|
839
|
+
status: "PASS" | "FAIL" | "WARNING";
|
|
840
|
+
details: string;
|
|
841
|
+
fix_suggestion: string;
|
|
842
|
+
}[];
|
|
843
|
+
summary: string;
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
interface PipelineResult {
|
|
847
|
+
entities: Entity[];
|
|
848
|
+
relationships: Relationship[];
|
|
849
|
+
tables: Table[];
|
|
850
|
+
ddl: string;
|
|
851
|
+
mermaid: string;
|
|
852
|
+
verification: VerificationResult;
|
|
853
|
+
ambiguities: string[];
|
|
854
|
+
cardinality_warnings: string[];
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
// ── Agent Prompts ────────────────────────────────────────────────────────────
|
|
858
|
+
|
|
859
|
+
const ENTITY_EXTRACTOR_SYSTEM = `You are a database entity extraction agent. Your ONLY job is to identify entities (nouns that represent storable objects) and their attributes from natural language requirements. You do NOT define relationships — another agent handles that.
|
|
860
|
+
|
|
861
|
+
Rules:
|
|
862
|
+
1. Each entity must have a clear identity (something that makes instances unique)
|
|
863
|
+
2. Mark the likely primary key attribute with "PK" in constraints
|
|
864
|
+
3. Classify each attribute: simple, composite, multivalued, or derived
|
|
865
|
+
4. Flag weak entities that cannot exist without a parent
|
|
866
|
+
5. Include data type suggestions
|
|
867
|
+
6. If an attribute could be an entity itself, extract it as a separate entity
|
|
868
|
+
7. Do NOT invent attributes not implied by the requirements
|
|
869
|
+
8. Mark attributes as REQUIRED or OPTIONAL based on context
|
|
870
|
+
|
|
871
|
+
Return valid JSON matching the EntityExtraction schema.`;
|
|
872
|
+
|
|
873
|
+
const RELATIONSHIP_CLASSIFIER_SYSTEM = `You are a database relationship classification agent. Given entities and requirements, identify ALL relationships.
|
|
874
|
+
|
|
875
|
+
Rules:
|
|
876
|
+
1. Classify each: 1:1, 1:N, or M:N
|
|
877
|
+
2. Determine participation: total or partial for EACH side
|
|
878
|
+
3. Identify relationship attributes
|
|
879
|
+
4. Flag recursive relationships
|
|
880
|
+
5. CRITICAL: For each cardinality, answer: "Can ONE A have MANY B? Can ONE B have MANY A?"
|
|
881
|
+
6. When uncertain, default to M:N and flag for human review
|
|
882
|
+
|
|
883
|
+
Return valid JSON matching the RelationshipClassification schema.`;
|
|
884
|
+
|
|
885
|
+
const CONSTRAINT_INTEGRATOR_SYSTEM = `You are a database constraint integration agent. Apply ER-to-schema mapping rules:
|
|
886
|
+
- Strong entity -> table with PK
|
|
887
|
+
- Weak entity -> composite PK (partial key + owner PK)
|
|
888
|
+
- 1:1 -> FK on total-participation side
|
|
889
|
+
- 1:N -> FK on "many" side
|
|
890
|
+
- M:N -> junction table
|
|
891
|
+
- Multivalued attribute -> separate table
|
|
892
|
+
Add created_at/updated_at to all tables. Suggest indexes for all FKs.
|
|
893
|
+
|
|
894
|
+
Return valid JSON matching the LogicalSchema schema.`;
|
|
895
|
+
|
|
896
|
+
const SCHEMA_ARTICULATOR_SYSTEM = `You are a schema articulation agent. Generate deployment-ready SQL DDL and Mermaid ERD from a logical schema. Use explicit constraint names (pk_, fk_, uq_ prefixes). Order CREATE TABLE respecting FK dependencies. Include CREATE INDEX statements.`;
|
|
897
|
+
|
|
898
|
+
const VERIFIER_SYSTEM = `You are a database schema verification agent. Validate completeness and correctness against original requirements.
|
|
899
|
+
|
|
900
|
+
Check: structural (tables exist, FKs valid), semantic (cardinalities correct, no hallucinations), normalization (1NF/2NF/3NF), completeness (timestamps, indexes, ON DELETE actions).
|
|
901
|
+
|
|
902
|
+
Return valid JSON matching the VerificationResult schema.`;
|
|
903
|
+
|
|
904
|
+
// ── Pipeline Orchestrator ────────────────────────────────────────────────────
|
|
905
|
+
|
|
906
|
+
class ERDPipeline {
|
|
907
|
+
private client: Anthropic;
|
|
908
|
+
private model: string;
|
|
909
|
+
|
|
910
|
+
constructor(apiKey: string, model = "claude-sonnet-4-20250514") {
|
|
911
|
+
this.client = new Anthropic({ apiKey });
|
|
912
|
+
this.model = model;
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
private async callAgent(systemPrompt: string, userPrompt: string): Promise<string> {
|
|
916
|
+
const response = await this.client.messages.create({
|
|
917
|
+
model: this.model,
|
|
918
|
+
max_tokens: 8192,
|
|
919
|
+
system: systemPrompt,
|
|
920
|
+
messages: [{ role: "user", content: userPrompt }],
|
|
921
|
+
});
|
|
922
|
+
|
|
923
|
+
const textBlock = response.content.find((b) => b.type === "text");
|
|
924
|
+
if (!textBlock || textBlock.type !== "text") throw new Error("No text response from agent");
|
|
925
|
+
return textBlock.text;
|
|
926
|
+
}
|
|
927
|
+
|
|
928
|
+
private extractJSON(text: string): string {
|
|
929
|
+
// Extract JSON from markdown code blocks or raw text
|
|
930
|
+
const jsonMatch = text.match(/```(?:json)?\s*\n?([\s\S]*?)\n?```/);
|
|
931
|
+
if (jsonMatch) return jsonMatch[1].trim();
|
|
932
|
+
// Try parsing the whole text as JSON
|
|
933
|
+
const firstBrace = text.indexOf("{");
|
|
934
|
+
const lastBrace = text.lastIndexOf("}");
|
|
935
|
+
if (firstBrace !== -1 && lastBrace !== -1) {
|
|
936
|
+
return text.slice(firstBrace, lastBrace + 1);
|
|
937
|
+
}
|
|
938
|
+
return text;
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
async generate(
|
|
942
|
+
requirements: string,
|
|
943
|
+
targetDb: "postgresql" | "mysql" | "sqlite" = "postgresql"
|
|
944
|
+
): Promise<PipelineResult> {
|
|
945
|
+
console.log("[ERD Pipeline] Stage 1/5: Entity Extraction...");
|
|
946
|
+
|
|
947
|
+
// ── Agent 1: Entity Extraction ──
|
|
948
|
+
const entitiesRaw = await this.callAgent(
|
|
949
|
+
ENTITY_EXTRACTOR_SYSTEM,
|
|
950
|
+
`Extract all database entities from:\n---\n${requirements}\n---\n\nReturn JSON with "entities" and "ambiguities" arrays.`
|
|
951
|
+
);
|
|
952
|
+
const entitiesResult = JSON.parse(this.extractJSON(entitiesRaw));
|
|
953
|
+
const entities: Entity[] = entitiesResult.entities;
|
|
954
|
+
const ambiguities: string[] = entitiesResult.ambiguities || [];
|
|
955
|
+
|
|
956
|
+
console.log(`[ERD Pipeline] Found ${entities.length} entities, ${ambiguities.length} ambiguities`);
|
|
957
|
+
console.log("[ERD Pipeline] Stage 2/5: Relationship Classification...");
|
|
958
|
+
|
|
959
|
+
// ── Agent 2: Relationship Classification ──
|
|
960
|
+
const relationshipsRaw = await this.callAgent(
|
|
961
|
+
RELATIONSHIP_CLASSIFIER_SYSTEM,
|
|
962
|
+
`Given these entities:\n\`\`\`json\n${JSON.stringify(entities, null, 2)}\n\`\`\`\n\nAnd requirements:\n---\n${requirements}\n---\n\nIdentify all relationships. Return JSON with "relationships" and "cardinality_warnings" arrays.`
|
|
963
|
+
);
|
|
964
|
+
const relResult = JSON.parse(this.extractJSON(relationshipsRaw));
|
|
965
|
+
const relationships: Relationship[] = relResult.relationships;
|
|
966
|
+
const cardinalityWarnings: string[] = relResult.cardinality_warnings || [];
|
|
967
|
+
|
|
968
|
+
console.log(`[ERD Pipeline] Found ${relationships.length} relationships, ${cardinalityWarnings.length} warnings`);
|
|
969
|
+
console.log("[ERD Pipeline] Stage 3/5: Constraint Integration...");
|
|
970
|
+
|
|
971
|
+
// ── Agent 3: Constraint Integration ──
|
|
972
|
+
const schemaRaw = await this.callAgent(
|
|
973
|
+
CONSTRAINT_INTEGRATOR_SYSTEM,
|
|
974
|
+
`Integrate into logical schema:\n\nEntities:\n\`\`\`json\n${JSON.stringify(entities, null, 2)}\n\`\`\`\n\nRelationships:\n\`\`\`json\n${JSON.stringify(relationships, null, 2)}\n\`\`\`\n\nTarget: ${targetDb}. Return JSON with "tables", "normalization_warnings", and "design_decisions" arrays.`
|
|
975
|
+
);
|
|
976
|
+
const schemaResult = JSON.parse(this.extractJSON(schemaRaw));
|
|
977
|
+
const tables: Table[] = schemaResult.tables;
|
|
978
|
+
|
|
979
|
+
console.log(`[ERD Pipeline] Generated ${tables.length} tables`);
|
|
980
|
+
console.log("[ERD Pipeline] Stage 4/5: Schema Articulation...");
|
|
981
|
+
|
|
982
|
+
// ── Agent 4: Schema Articulation ──
|
|
983
|
+
const artifactsRaw = await this.callAgent(
|
|
984
|
+
SCHEMA_ARTICULATOR_SYSTEM,
|
|
985
|
+
`Generate SQL DDL (${targetDb}) and Mermaid ERD from:\n\`\`\`json\n${JSON.stringify(schemaResult, null, 2)}\n\`\`\`\n\nReturn the DDL in a \`\`\`sql block and the Mermaid in a \`\`\`mermaid block.`
|
|
986
|
+
);
|
|
987
|
+
|
|
988
|
+
// Extract DDL and Mermaid from response
|
|
989
|
+
const ddlMatch = artifactsRaw.match(/```sql\s*\n([\s\S]*?)\n```/);
|
|
990
|
+
const mermaidMatch = artifactsRaw.match(/```mermaid\s*\n([\s\S]*?)\n```/);
|
|
991
|
+
const ddl = ddlMatch ? ddlMatch[1].trim() : "-- DDL extraction failed";
|
|
992
|
+
const mermaid = mermaidMatch ? mermaidMatch[1].trim() : "erDiagram\n %% Mermaid extraction failed";
|
|
993
|
+
|
|
994
|
+
console.log("[ERD Pipeline] Stage 5/5: Verification...");
|
|
995
|
+
|
|
996
|
+
// ── Agent 5: Verification ──
|
|
997
|
+
const verificationRaw = await this.callAgent(
|
|
998
|
+
VERIFIER_SYSTEM,
|
|
999
|
+
`Verify this schema against requirements.\n\nRequirements:\n---\n${requirements}\n---\n\nDDL:\n\`\`\`sql\n${ddl}\n\`\`\`\n\nLogical model:\n\`\`\`json\n${JSON.stringify({ entities, relationships, tables }, null, 2)}\n\`\`\`\n\nReturn JSON with "overall_status", "checks", and "summary".`
|
|
1000
|
+
);
|
|
1001
|
+
const verification: VerificationResult = JSON.parse(this.extractJSON(verificationRaw));
|
|
1002
|
+
|
|
1003
|
+
console.log(`[ERD Pipeline] Verification: ${verification.overall_status}`);
|
|
1004
|
+
|
|
1005
|
+
return {
|
|
1006
|
+
entities,
|
|
1007
|
+
relationships,
|
|
1008
|
+
tables,
|
|
1009
|
+
ddl,
|
|
1010
|
+
mermaid,
|
|
1011
|
+
verification,
|
|
1012
|
+
ambiguities,
|
|
1013
|
+
cardinality_warnings: cardinalityWarnings,
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
// ── Usage Example ────────────────────────────────────────────────────────────
|
|
1019
|
+
|
|
1020
|
+
async function main() {
|
|
1021
|
+
const pipeline = new ERDPipeline(process.env.ANTHROPIC_API_KEY!);
|
|
1022
|
+
|
|
1023
|
+
const result = await pipeline.generate(`
|
|
1024
|
+
We need a database for an online learning platform.
|
|
1025
|
+
Teachers create courses with multiple modules. Each module has lessons.
|
|
1026
|
+
Students enroll in courses and track their progress per lesson.
|
|
1027
|
+
Students can rate and review courses (one review per student per course).
|
|
1028
|
+
Teachers can create quizzes for each module with multiple-choice questions.
|
|
1029
|
+
Students submit quiz attempts with their answers and receive scores.
|
|
1030
|
+
There should be a discussion forum per course where students and teachers
|
|
1031
|
+
can post messages and reply to each other.
|
|
1032
|
+
`);
|
|
1033
|
+
|
|
1034
|
+
console.log("\n=== ENTITIES ===");
|
|
1035
|
+
result.entities.forEach((e) => console.log(` ${e.name} (${e.type}): ${e.attributes.length} attrs`));
|
|
1036
|
+
|
|
1037
|
+
console.log("\n=== RELATIONSHIPS ===");
|
|
1038
|
+
result.relationships.forEach((r) =>
|
|
1039
|
+
console.log(` ${r.entity_a} --[${r.cardinality}]--> ${r.entity_b}: ${r.name}`)
|
|
1040
|
+
);
|
|
1041
|
+
|
|
1042
|
+
console.log("\n=== DDL ===");
|
|
1043
|
+
console.log(result.ddl);
|
|
1044
|
+
|
|
1045
|
+
console.log("\n=== MERMAID ===");
|
|
1046
|
+
console.log(result.mermaid);
|
|
1047
|
+
|
|
1048
|
+
console.log("\n=== VERIFICATION ===");
|
|
1049
|
+
console.log(`Status: ${result.verification.overall_status}`);
|
|
1050
|
+
console.log(result.verification.summary);
|
|
1051
|
+
|
|
1052
|
+
if (result.ambiguities.length > 0) {
|
|
1053
|
+
console.log("\n=== AMBIGUITIES (need human input) ===");
|
|
1054
|
+
result.ambiguities.forEach((a) => console.log(` - ${a}`));
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
if (result.cardinality_warnings.length > 0) {
|
|
1058
|
+
console.log("\n=== CARDINALITY WARNINGS (review these) ===");
|
|
1059
|
+
result.cardinality_warnings.forEach((w) => console.log(` - ${w}`));
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
main().catch(console.error);
|
|
1064
|
+
```
|
|
1065
|
+
|
|
1066
|
+
---
|
|
1067
|
+
|
|
1068
|
+
## BYO API Key Pattern
|
|
1069
|
+
|
|
1070
|
+
Inspired by ChartDB's model: the application does not store or proxy API keys. Users bring their own.
|
|
1071
|
+
|
|
1072
|
+
```typescript
|
|
1073
|
+
// api-key-config.ts — Multi-provider API key management
|
|
1074
|
+
|
|
1075
|
+
type Provider = "anthropic" | "google" | "ollama";
|
|
1076
|
+
|
|
1077
|
+
interface ProviderConfig {
|
|
1078
|
+
provider: Provider;
|
|
1079
|
+
apiKey?: string; // Not needed for Ollama
|
|
1080
|
+
model: string;
|
|
1081
|
+
baseUrl?: string; // Custom endpoint (Ollama, proxy)
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
const PROVIDER_DEFAULTS: Record<Provider, { model: string; baseUrl?: string }> = {
|
|
1085
|
+
anthropic: { model: "claude-sonnet-4-20250514" },
|
|
1086
|
+
google: { model: "gemini-2.5-pro" },
|
|
1087
|
+
ollama: { model: "llama3.3:70b", baseUrl: "http://localhost:11434" },
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
function createClient(config: ProviderConfig) {
|
|
1091
|
+
switch (config.provider) {
|
|
1092
|
+
case "anthropic":
|
|
1093
|
+
// Uses @anthropic-ai/sdk
|
|
1094
|
+
return {
|
|
1095
|
+
call: async (system: string, user: string) => {
|
|
1096
|
+
const Anthropic = (await import("@anthropic-ai/sdk")).default;
|
|
1097
|
+
const client = new Anthropic({ apiKey: config.apiKey });
|
|
1098
|
+
const res = await client.messages.create({
|
|
1099
|
+
model: config.model,
|
|
1100
|
+
max_tokens: 8192,
|
|
1101
|
+
system,
|
|
1102
|
+
messages: [{ role: "user", content: user }],
|
|
1103
|
+
});
|
|
1104
|
+
const block = res.content.find((b) => b.type === "text");
|
|
1105
|
+
return block && block.type === "text" ? block.text : "";
|
|
1106
|
+
},
|
|
1107
|
+
};
|
|
1108
|
+
|
|
1109
|
+
case "google":
|
|
1110
|
+
// Uses @google/generative-ai
|
|
1111
|
+
return {
|
|
1112
|
+
call: async (system: string, user: string) => {
|
|
1113
|
+
const { GoogleGenerativeAI } = await import("@google/generative-ai");
|
|
1114
|
+
const genAI = new GoogleGenerativeAI(config.apiKey!);
|
|
1115
|
+
const model = genAI.getGenerativeModel({
|
|
1116
|
+
model: config.model,
|
|
1117
|
+
systemInstruction: system,
|
|
1118
|
+
});
|
|
1119
|
+
const result = await model.generateContent(user);
|
|
1120
|
+
return result.response.text();
|
|
1121
|
+
},
|
|
1122
|
+
};
|
|
1123
|
+
|
|
1124
|
+
case "ollama":
|
|
1125
|
+
// Uses fetch against Ollama REST API — fully offline
|
|
1126
|
+
return {
|
|
1127
|
+
call: async (system: string, user: string) => {
|
|
1128
|
+
const res = await fetch(`${config.baseUrl}/api/chat`, {
|
|
1129
|
+
method: "POST",
|
|
1130
|
+
headers: { "Content-Type": "application/json" },
|
|
1131
|
+
body: JSON.stringify({
|
|
1132
|
+
model: config.model,
|
|
1133
|
+
messages: [
|
|
1134
|
+
{ role: "system", content: system },
|
|
1135
|
+
{ role: "user", content: user },
|
|
1136
|
+
],
|
|
1137
|
+
stream: false,
|
|
1138
|
+
}),
|
|
1139
|
+
});
|
|
1140
|
+
const data = await res.json();
|
|
1141
|
+
return data.message?.content ?? "";
|
|
1142
|
+
},
|
|
1143
|
+
};
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
// Usage: user picks their provider, stores key locally (never sent to our servers)
|
|
1148
|
+
// const client = createClient({ provider: "anthropic", apiKey: "sk-ant-...", model: "claude-sonnet-4-20250514" });
|
|
1149
|
+
// const client = createClient({ provider: "ollama", model: "llama3.3:70b" }); // fully offline
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
### Desktop + Offline Gap (Market Opportunity)
|
|
1153
|
+
|
|
1154
|
+
Every existing tool (Eraser DiagramGPT, ChartDB, dbdiagram.io) is **web-only**. A desktop application built with **Tauri** (Rust backend, web frontend) that runs the pipeline against a local Ollama instance would be:
|
|
1155
|
+
|
|
1156
|
+
- Fully offline-capable (sensitive schemas never leave the machine)
|
|
1157
|
+
- Zero ongoing cost after setup (no API fees with local models)
|
|
1158
|
+
- Installable via `.msi` / `.dmg` / `.AppImage`
|
|
1159
|
+
- Differentiated from every competitor in the space
|
|
1160
|
+
|
|
1161
|
+
Stack: Tauri + React + Ollama + this pipeline. The prompt templates work with any model that outputs JSON.
|
|
1162
|
+
|
|
1163
|
+
---
|
|
1164
|
+
|
|
1165
|
+
## When to Use
|
|
1166
|
+
|
|
1167
|
+
- **Rapid prototyping:** "I need a database for an e-commerce store" -> complete schema in 60 seconds
|
|
1168
|
+
- **Requirements analysis:** Converting business documents to technical schemas with traceability
|
|
1169
|
+
- **Schema iteration:** "Add user authentication to this schema" -> updated DDL + diff
|
|
1170
|
+
- **Teaching:** Students describe a domain, AI generates a starter ERD for discussion
|
|
1171
|
+
- **Code review:** Reverse-engineer existing DDL into visual ERD for review
|
|
1172
|
+
- **Documentation:** Generate Mermaid ERDs from existing schemas for README files
|
|
1173
|
+
|
|
1174
|
+
## When NOT to Use
|
|
1175
|
+
|
|
1176
|
+
- **Production schema changes** — always human-review AI output before deploying
|
|
1177
|
+
- **Complex domain modeling** — AI misses domain-specific constraints, business rules, and edge cases
|
|
1178
|
+
- **Performance-sensitive schemas** — AI does not optimize for query patterns, read/write ratios, or data volume
|
|
1179
|
+
- **Regulatory compliance** — HIPAA, SOX, PCI schemas need domain expert review, not AI generation
|
|
1180
|
+
- **Migration planning** — AI generates target state but does not handle data migration strategy
|
|
1181
|
+
|
|
1182
|
+
---
|
|
1183
|
+
|
|
1184
|
+
## Related Skills
|
|
1185
|
+
|
|
1186
|
+
- **erd-creator-textbook-research** — Source research for this skill (textbook analysis, scored findings)
|
|
1187
|
+
- **er-diagram-components** — Visual component knowledge for rendering (Chen + Crow's Foot notation)
|
|
1188
|
+
- **er-to-ddl-mapping** — Manual ER-to-schema mapping rules (deterministic fallback when AI fails)
|
|
1189
|
+
- **normalization-validator** — Validate AI-generated schemas for 1NF/2NF/3NF violations
|
|
1190
|
+
- **database-schema-designer** — Broader schema design skill (RLS, seeds, migrations, types)
|
|
1191
|
+
- **pg-to-mysql-schema-migration-methodology** — Cross-database migration patterns
|
|
1192
|
+
|
|
1193
|
+
---
|
|
1194
|
+
|
|
1195
|
+
## References
|
|
1196
|
+
|
|
1197
|
+
1. **Text2Schema** — "From Natural Language to Database Table Structures: Text2Schema." arXiv:2503.23886, March 2025. Multi-agent LLM framework for NL-to-schema generation.
|
|
1198
|
+
|
|
1199
|
+
2. **NOMAD** — "NOMAD: Multi-Agent Framework for UML Diagram Generation from Natural Language." arXiv:2511.22409, November 2025. Five-agent pipeline with error taxonomy.
|
|
1200
|
+
|
|
1201
|
+
3. **Towards Diagram-Based Data Model Generation** — ER 2025 Conference (Springer). Agentic approach with Prompt Interpreter and tooling agents. Identifies three LLM weaknesses: domain alignment, semantic validation, formalism generation.
|
|
1202
|
+
|
|
1203
|
+
4. **DiagramEval** — "DiagramEval: Evaluating LLM-Generated Diagrams." EMNLP 2025. First benchmark with Node Alignment and Path Alignment metrics. Claude 3.7 Sonnet best on 4/6 metrics.
|
|
1204
|
+
|
|
1205
|
+
5. **Cogent Education 2025** — "LLMs and ER Diagrams: Cardinality Challenges." LLMs struggle most with cardinalities. CoT prompting improves Chen notation but mixed results for Crow's Foot.
|
|
1206
|
+
|
|
1207
|
+
6. **ERFlow MCP Server** — 25+ MCP tools for natural language schema edits from IDE. Open source.
|
|
1208
|
+
|
|
1209
|
+
7. **Eraser DiagramGPT** — Paste code/text, generates ERDs. Diagram-as-code editing model.
|
|
1210
|
+
|
|
1211
|
+
8. **ChartDB** — Open-source database visualization with BYO API key pattern. No vendor lock-in.
|
|
1212
|
+
|
|
1213
|
+
9. **ResearchGate 2024** — "Generating Database Schema from Requirements Using NLP and LLMs." Pipeline: requirements docs -> entities/relationships -> schema.
|