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.

Microsoft SQL Server

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.

ColdFusion / Lucee SQL Server / MySQL / PostgreSQL INFORMATION_SCHEMA Zero Dependencies

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.

SQL Server
INFORMATION_SCHEMA

index.cfm
Queries + Renders

_datastructure.md
Auto-Generated

Claude / AI
Reads Markdown

Correct Code
Right Columns + JOINs
Key insight: The markdown file lives in your project directory. When Claude Code reads your project files, it can find the _datastructure.md file and learn your entire database schema automatically — every table, column, data type, and foreign key relationship.
sql_docs/
   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.

 
index.cfm — lines 16-20
dsnList = []> arrayAppend(dsnList, {name: "Your_DSN_Name", label: "My Database"})> arrayAppend(dsnList, {name: "Second_DSN", label: "Other DB"})> arrayAppend(dsnList, {name: "", label: ""})> arrayAppend(dsnList, {name: "", label: ""})>

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
That's it. The markdown files are now in your project directory. Claude Code will discover them when it reads your project files, and every AI conversation about your database will have full schema context.

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

Build me a single-file ColdFusion page (index.cfm) that serves as a self-contained database schema documentation tool. Drop it into any CF app and it should work with just a datasource name change. REQUIREMENTS: 1. CONFIGURATION - Support up to 4 datasource names defined at the top of the file - Each DSN has a "name" (the actual CF datasource) and a "label" (display name) - Allow switching between DSNs via a URL parameter - Leave slots blank to disable them 2. DATABASE QUERIES (use INFORMATION_SCHEMA for portability) - Query all user tables and views from INFORMATION_SCHEMA.TABLES - Query all columns with ordinal position, data type, length/precision, nullable flag, column default, and whether it's a primary key - Query all foreign key relationships (which column references which table) - Query reverse relationships (which tables reference the current table) 3. INTERACTIVE HTML UI - Header showing DSN name, table count, view count, column count, FK count - Search bar that filters tables by name OR column name - Filter buttons: All / Tables Only / Views Only - Expand All / Collapse All buttons - Sticky sidebar with a table-of-contents listing all tables/views - Each table rendered as a collapsible card showing: * Column number, name, data type (with length), nullable, default value * Primary key badge (PK) on key columns * Foreign key badge (FK) with a clickable link to the referenced table * "Referenced by" section showing which other tables point to this table - A "Copy" button on each table card that copies the column list to clipboard - Clean, modern CSS (no external dependencies) with responsive design - Print-friendly styles 4. AUTO-GENERATE MARKDOWN FILES - On every page load, write a {DSN_Name}_datastructure.md file for each active datasource to the same directory as index.cfm - The markdown file should contain: * A summary (table count, column count, FK count) * Every table with a markdown table of columns (name, type, nullable, default, key info including PK and FK references) * Every view with its columns * A foreign key relationship summary table * A "Quick Reference" section listing just table names and their columns - This file is the key deliverable: it gives AI coding tools (Claude Code, Cursor, Copilot, etc.) full database context without needing DB access 5. COMPATIBILITY - Works on SQL Server, MySQL, and PostgreSQL (anything with INFORMATION_SCHEMA) - Works on Adobe ColdFusion and Lucee - All CSS and JS inline (zero external dependencies) - Gracefully handles empty DSN slots and query errors The purpose of the markdown file generation is critical: when this file lives in the project directory, AI coding assistants can read it and understand the entire database schema. This means they can write correct SQL queries, use the right column names, understand table relationships, and build proper JOINs -- all without ever connecting to the database directly. My datasources are: [YOUR_DSN_1], [YOUR_DSN_2] My database engine is: [SQL Server / MySQL / PostgreSQL]

Customize the bracketed values. Replace [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:

 
Example prompt
Read sql_docs/Royale_Club_datastructure.md for the database schema, then write a query that returns all rally attendees with their contact info and coach details for Rally ID 42.

3 CLAUDE.md Integration

Add a line to your project's CLAUDE.md file so Claude always knows where to find the schema:

 
CLAUDE.md
## Database Reference Database schemas are documented in the sql_docs/ directory: - sql_docs/Royale_Club_datastructure.md — Main application database (75 tables) - sql_docs/SMS_Messages_datastructure.md — SMS/Twilio messaging database (9 tables) Always read the relevant datastructure file before writing SQL queries or modifying database-related code.

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

Does this expose my database to the internet? ?
No. The page runs server-side on your ColdFusion application server. It only queries 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.
Will this work with my database engine? ?
It works with any database that supports INFORMATION_SCHEMA views, which includes SQL Server, MySQL, MariaDB, and PostgreSQL. Oracle and SQLite do not support INFORMATION_SCHEMA and would need modified queries.
What if I don't use ColdFusion?
The concept works with any server-side language. Use the AI prompt above as a starting point and ask Claude to generate a PHP, Python, Node.js, or C# version. The INFORMATION_SCHEMA queries are standard SQL and will transfer directly. The key idea is the same: query the schema, generate a markdown file, keep it in your project.
How large can the markdown file get? ?
The Royale_Club database with 75 tables and 979 columns produces a markdown file of about 1,400 lines. Claude Code handles this easily — it's well within the context window. Even databases with hundreds of tables will produce manageable files since the format is compact (one row per column in a markdown table).
Can I use this with Cursor, Copilot, or other AI tools? ?
Yes. Any AI coding tool that reads project files will benefit from having the _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.
Should I commit the markdown files to version control? ?
Yes, committing them is recommended. This way, every developer (and every AI tool) on the team has immediate access to the current schema without needing to run the ColdFusion page themselves. The files are regenerated on each page load, so they'll be updated whenever someone views the documentation page.