<p>Then you do it again five minutes later.</p><p><code>@elyracode/db-tools</code> skips the context switch. The agent queries your database directly, understands the schema, and uses the results to inform what it builds. You stay in one place.</p><h2>Install</h2><pre><code>elyra install npm:@elyracode/db-tools
</code></pre><h2>Zero configuration for Laravel projects</h2><p>If your project has a <code>.env</code> file with <code>DB_HOST</code>, <code>DB_DATABASE</code>, <code>DB_USERNAME</code>, and <code>DB_PASSWORD</code> — the standard Laravel variables — db-tools reads them automatically. No separate configuration.</p><pre><code class="language-env">DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=myapp
DB_USERNAME=root
DB_PASSWORD=secret
</code></pre><p>That's enough. The agent can now query your database.</p><p>SQLite is even simpler. If your <code>.env</code> has <code>DB_CONNECTION=sqlite</code>, db-tools finds the database file automatically — either from <code>DB_DATABASE</code> or the Laravel default at <code>database/database.sqlite</code>.</p><h2>Just ask about your data</h2><p>You don't need to write SQL. Just describe what you want to know:</p><pre><code>How many users registered this week?
</code></pre><p>The agent calls <code>get_database_schema</code> to discover your tables and columns, writes the SQL, executes it via <code>query_mysql</code>, and gives you the answer. If the schema has a <code>users</code> table with a <code>created_at</code> column, it knows what to do.</p><pre><code>Show me the top 10 products by revenue this month
</code></pre><p>The agent joins the relevant tables, handles the date filtering, aggregates the revenue, and returns the results as formatted JSON.</p><pre><code>What's the schema of the orders table?
</code></pre><p>Returns columns, types, nullable flags, defaults, and indexes. Useful when you're about to build something that touches that table and want the agent to know the structure.</p><h2>Where it gets interesting</h2><p>The database tools aren't just for answering questions. They change how the agent writes code.</p><p><strong>Building migrations.</strong> When you ask the agent to add a feature that needs new database tables, it can check the existing schema first. It knows what tables exist, what columns they have, what foreign keys are in place. The migration it writes fits the existing structure instead of guessing.</p><pre><code>Add a notifications system. Check the existing schema first.
</code></pre><p>The agent reads the schema, sees your <code>users</code> table structure, and creates a migration with the right foreign key references and column types.</p><p><strong>Debugging data issues.</strong> When something isn't working and the bug might be in the data, you can ask the agent to check:</p><pre><code>The order total on order #4521 looks wrong. Check the line items and calculate what it should be.
</code></pre><p>The agent queries the order, queries the line items, does the math, and tells you whether the total matches. If it doesn't, it can trace the code path that calculates totals and find where the bug is.</p><p><strong>Seeding and testing.</strong> Before writing tests, the agent can check what data patterns exist:</p><pre><code>Show me a few example rows from the payments table so I understand the data format
</code></pre><p>Then it writes factory definitions and test assertions that match your actual data patterns, not generic placeholders.</p><h2>Three database engines</h2><p><strong>MySQL</strong> is the primary target. Connection details come from your <code>.env</code> or from <code>ELYRA_MYSQL_*</code> environment variables. Supports all standard SELECT queries, joins, aggregations, subqueries.</p><p><strong>ClickHouse</strong> for analytical workloads. If you have a ClickHouse instance for logs, analytics, or time-series data, the agent can query it with the same natural language interface. Configure with <code>ELYRA_CLICKHOUSE_*</code> variables or the standard ClickHouse <code>.env</code> keys.</p><pre><code>What's the 95th percentile response time for the /api/checkout endpoint this week?
</code></pre><p>If that data lives in ClickHouse, the agent writes the appropriate ClickHouse SQL (which has different syntax for percentiles and time functions) and returns the result.</p><p><strong>SQLite</strong> for local development and testing. Auto-detected from your Laravel project. No configuration. Useful for checking state during development without spinning up a full database server.</p><h2>Safety</h2><p>By default, db-tools only allows read operations. SELECT, SHOW, DESCRIBE, and EXPLAIN. The agent cannot INSERT, UPDATE, or DELETE through the database tools unless you explicitly enable it:</p><pre><code class="language-bash">export ELYRA_DB_ALLOW_WRITES=true
</code></pre><p>Even with writes disabled, the agent can still create migration files that modify the schema — it just can't execute them against your database directly. This is the right default for most workflows: the agent reads data to inform its work, but structural changes go through your normal migration pipeline.</p><p>The recommendation is to use a database user with SELECT-only privileges. Even if someone enables <code>ELYRA_DB_ALLOW_WRITES</code>, the database itself enforces the boundary.</p><h2>Practical patterns</h2><p><strong>Start of session: ground the agent in reality.</strong> Pin your schema or ask the agent to read it at the beginning of a session. This gives it accurate knowledge of your data model for everything that follows.</p><pre><code>/pin database/schema.sql
</code></pre><p>Or:</p><pre><code>Read the database schema and keep it in mind for this session.
</code></pre><p><strong>Before building features: check the data.</strong> Instead of describing your data model in words, let the agent see it. "Add a reporting dashboard" works better when the agent has queried the actual tables and knows what metrics are available.</p><p><strong>After deploying: verify the data.</strong> Run a quick check after a migration or data import:</p><pre><code>Check if all users have a valid team_id after the migration
</code></pre><p>The agent writes a query that finds orphaned records, null foreign keys, or data inconsistencies.</p><h2>When not to use it</h2><p>Don't point it at production databases with sensitive data. The query results flow through the LLM provider. Use a development or staging database, or a read replica with anonymized data.</p><p>Don't use it for bulk data operations. It's designed for exploratory queries and schema discovery, not for importing 10,000 rows or running data migrations. Use your normal database tools for that.</p><p>Don't enable writes unless you have a specific reason and a separate database user with limited permissions. The default read-only mode exists for a reason.</p>