$npx -y skills add langchain-ai/deepagents --skill schema-explorationschema-exploration is an agent skill published from langchain-ai/deepagents, installable through the skills CLI.
| 1 | # Schema Exploration Skill |
| 2 | |
| 3 | ## Workflow |
| 4 | |
| 5 | ### 1. List All Tables |
| 6 | Use `sql_db_list_tables` tool to see all available tables in the database. |
| 7 | |
| 8 | This returns the complete list of tables you can query. |
| 9 | |
| 10 | ### 2. Get Schema for Specific Tables |
| 11 | Use `sql_db_schema` tool with table names to examine: |
| 12 | - **Column names** - What fields are available |
| 13 | - **Data types** - INTEGER, TEXT, DATETIME, etc. |
| 14 | - **Sample data** - 3 example rows to understand content |
| 15 | - **Primary keys** - Unique identifiers for rows |
| 16 | - **Foreign keys** - Relationships to other tables |
| 17 | |
| 18 | ### 3. Map Relationships |
| 19 | Identify how tables connect: |
| 20 | - Look for columns ending in "Id" (e.g., CustomerId, ArtistId) |
| 21 | - Foreign keys link to primary keys in other tables |
| 22 | - Document parent-child relationships |
| 23 | |
| 24 | ### 4. Answer the Question |
| 25 | Provide clear information about: |
| 26 | - Available tables and their purpose |
| 27 | - Column names and what they contain |
| 28 | - How tables relate to each other |
| 29 | - Sample data to illustrate content |
| 30 | |
| 31 | ## Example: "What tables are available?" |
| 32 | |
| 33 | **Step 1:** Use `sql_db_list_tables` |
| 34 | |
| 35 | **Response:** |
| 36 | ``` |
| 37 | The Chinook database has 11 tables: |
| 38 | 1. Artist - Music artists |
| 39 | 2. Album - Music albums |
| 40 | 3. Track - Individual songs |
| 41 | 4. Genre - Music genres |
| 42 | 5. MediaType - File formats (MP3, AAC, etc.) |
| 43 | 6. Playlist - User-created playlists |
| 44 | 7. PlaylistTrack - Tracks in playlists |
| 45 | 8. Customer - Store customers |
| 46 | 9. Employee - Store employees |
| 47 | 10. Invoice - Customer purchases |
| 48 | 11. InvoiceLine - Individual items in invoices |
| 49 | ``` |
| 50 | |
| 51 | ## Example: "What columns does the Customer table have?" |
| 52 | |
| 53 | **Step 1:** Use `sql_db_schema` with table name "Customer" |
| 54 | |
| 55 | **Response:** |
| 56 | ``` |
| 57 | The Customer table has these columns: |
| 58 | |
| 59 | - CustomerId (INTEGER) - Primary key, unique customer ID |
| 60 | - FirstName (NVARCHAR) - Customer's first name |
| 61 | - LastName (NVARCHAR) - Customer's last name |
| 62 | - Company (NVARCHAR) - Company name (optional) |
| 63 | - Address, City, State, Country, PostalCode - Location fields |
| 64 | - Phone (NVARCHAR) - Phone number |
| 65 | - Fax (NVARCHAR) - Fax number |
| 66 | - Email (NVARCHAR) - Email address |
| 67 | - SupportRepId (INTEGER) - Foreign key to Employee table |
| 68 | |
| 69 | Sample data shows customers like: |
| 70 | - Luís Gonçalves from Brazil |
| 71 | - Leonie Köhler from Germany |
| 72 | - François Tremblay from Canada |
| 73 | ``` |
| 74 | |
| 75 | ## Example: "How do I find revenue by artist?" |
| 76 | |
| 77 | **Step 1:** Identify tables needed |
| 78 | - Artist (has artist names) |
| 79 | - Album (links artists to tracks) |
| 80 | - Track (links albums to sales) |
| 81 | - InvoiceLine (has sales data) |
| 82 | - Invoice (has revenue totals) |
| 83 | |
| 84 | **Step 2:** Map relationships |
| 85 | ``` |
| 86 | Artist (ArtistId) |
| 87 | ↓ 1:many |
| 88 | Album (ArtistId, AlbumId) |
| 89 | ↓ 1:many |
| 90 | Track (AlbumId, TrackId) |
| 91 | ↓ 1:many |
| 92 | InvoiceLine (TrackId, UnitPrice, Quantity) |
| 93 | ``` |
| 94 | |
| 95 | **Response:** |
| 96 | ``` |
| 97 | To find revenue by artist, you'll need to: |
| 98 | 1. Start with the Artist table |
| 99 | 2. JOIN to Album on ArtistId |
| 100 | 3. JOIN to Track on AlbumId |
| 101 | 4. JOIN to InvoiceLine on TrackId |
| 102 | 5. SUM the revenue (UnitPrice * Quantity) |
| 103 | 6. GROUP BY artist name |
| 104 | |
| 105 | This requires the query-writing skill to execute. |
| 106 | ``` |
| 107 | |
| 108 | ## Quality Guidelines |
| 109 | |
| 110 | **For "list tables" questions:** |
| 111 | - Show all table names |
| 112 | - Add brief descriptions of what each contains |
| 113 | - Group related tables (e.g., music catalog, transactions, people) |
| 114 | |
| 115 | **For "describe table" questions:** |
| 116 | - List all columns with data types |
| 117 | - Explain what each column contains |
| 118 | - Show sample data for context |
| 119 | - Note primary and foreign keys |
| 120 | - Explain relationships to other tables |
| 121 | |
| 122 | **For "how do I query X" questions:** |
| 123 | - Identify required tables |
| 124 | - Map the JOIN path |
| 125 | - Explain the relationship chain |
| 126 | - Suggest next steps (use query-writing skill) |