Teach Claude about your data structures for a project
This post talks about how you can easily provide Claude with all your data structures in a secure and easy manner. I keep a link to this page in my project admin section so I can refresh it after making changes in the SQL structure. All my projects use Microsoft SQL server. This is a fact that Claude has stored in my profile. You can store all your programming preferences in your Claude profile.
![]()
SQL Docs for Calude AI
A drop-in ColdFusion page that documents your database schema and generates machine-readable markdown files — so Claude (and other AI tools) can write correct queries on the first try.
Why Database Documentation Matters for AI Coding
When you ask Claude to write a SQL query or build a feature that touches your database, it has no idea what tables or columns exist. Without that context, AI is guessing — and guessing means wrong column names, missed relationships, and wasted time.
AI Can't See Your Database
Claude doesn't have access to your SQL Server. It can't run SELECT * FROM INFORMATION_SCHEMA.TABLES to discover what exists. You have to tell it.
Schema Is the Source of Truth
Column names, data types, nullable flags, and foreign keys define what's possible. When AI has this information, it writes correct queries instead of plausible-looking wrong ones.
First-Try Accuracy
Instead of a back-and-forth cycle of "that column doesn't exist" / "try this instead," Claude gets it right the first time. Faster features, fewer bugs.
Relationships Matter
Foreign keys tell AI how tables connect. Without them, it won't know that Rally_ID in Expenses maps to ProtGroup.ID, and it will write broken JOINs.
Scales with Complexity
A small database might be easy to describe by hand. But when you have 75+ tables and 900+ columns, automated documentation is the only practical approach.
Always Up to Date
The page re-queries on every load. Add a column, refresh the page, and the markdown is already regenerated. No manual maintenance.
How It Works
A single ColdFusion page sits inside your project. When loaded, it queries INFORMATION_SCHEMA, renders an interactive browser UI, and writes a markdown file for each datasource.
INFORMATION_SCHEMA
Queries + Renders
Auto-Generated
Reads Markdown
Right Columns + JOINs
_datastructure.md file and learn your entire database schema automatically — every table, column, data type, and foreign key relationship.index.cfm ← The documentation page (runs on your CF server)
Royale_Club_datastructure.md ← Auto-generated: 75 tables, 979 columns, 19 FKs
SMS_Messages_datastructure.md ← Auto-generated: 9 tables, 67 columns, 4 FKs
guide.html ← This documentation page
Setup — 3 Steps
No packages to install. No build step. Just configure your datasource names and load the page.
1 Drop the folder into your project
Copy the sql_docs folder anywhere inside a ColdFusion application. It has no dependencies on the rest of your app — it's fully self-contained.
2 Set your datasource names
Open index.cfm and edit lines 17–20. Set the name to your ColdFusion DSN and label to a display name. Leave slots blank to disable them.
3 Load the page in your browser
Navigate to https://yoursite.com/sql_docs/index.cfm in any browser. The page will query your database, display the interactive schema browser, and automatically write {DSN}_datastructure.md files to the same directory.
- Switch between datasources with the dropdown (if you configured more than one)
- Search tables and columns with the search bar
- Filter by Tables or Views
- Click foreign key links to navigate between related tables
- Click Copy on any table card to copy its column list
The AI Prompt to Build This for Your Environment
Use the following prompt with Claude Code (or any AI coding assistant) to generate a customized version of this tool for your own project. Modify the details in brackets to match your setup.
Copy this prompt into Claude Code
[YOUR_DSN_1], [YOUR_DSN_2], and the database engine with your actual values. You can remove the second DSN line or add more as needed.What the Markdown File Contains
Each _datastructure.md file is structured so AI tools can quickly parse and understand your schema. Here's the anatomy of a generated file:
1 Summary Block
Table count, total columns, and foreign key count at a glance.
2 Table Definitions
Each table gets a markdown table showing every column with its data type (including length like nvarchar(150)), nullable flag, default value, and key information (PK, FK with target table.column).
3 View Definitions
Views are listed separately with their column names, types, and nullability.
4 Foreign Key Summary
A single table mapping every FK relationship: from-table, from-column, to-table, to-column. This is how AI learns which JOINs are valid.
5 Quick Reference
Compact one-liner per table listing just the column names. Useful for AI to quickly scan for a specific column without parsing the full table definitions.
Using the Markdown with Claude Code
Once the _datastructure.md files exist in your project, here's how to leverage them.
1 Automatic Discovery
When you ask Claude Code to work on a feature that involves the database, it will search your project files for context. If the markdown files are in your project tree, Claude will find and read them automatically. No special instructions needed.
2 Explicit Reference
For best results, you can point Claude directly to the file:
3 CLAUDE.md Integration
Add a line to your project's CLAUDE.md file so Claude always knows where to find the schema:
4 Keep It Fresh
Whenever you modify the database (add tables, columns, or relationships), just reload index.cfm in your browser. The markdown files are rewritten on every page load. No scripts to run, no CLI commands, no build step.
FAQ
INFORMATION_SCHEMA (schema metadata, not your actual data). The generated markdown files contain table/column definitions only — never any row data. You should still protect the page with authentication or IP restrictions in production.INFORMATION_SCHEMA views, which includes SQL Server, MySQL, MariaDB, and PostgreSQL. Oracle and SQLite do not support INFORMATION_SCHEMA and would need modified queries._datastructure.md files in your project. Cursor, GitHub Copilot, Codeium, and others all use project context to improve suggestions. The markdown format is universally readable.
Comments (0)
No comments yet. Be the first to share your thoughts!
You must be logged in with a verified email to post comments.
Log In Register