SQL Reflect for Openclaw

A powerful reverse-engineering skill to map database queries back to their origin in PHP and Laravel codebases.

willing-lin
v1.0.0
Mar 30, 2026
0
751
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install sql-reflect

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install sql-reflect using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is SQL Reflect?

SQL Reflect is an essential diagnostic tool for Openclaw Skills users who need to bridge the gap between database performance logs and source code. It automates the tedious process of finding where a specific SQL query was generated within a PHP or Laravel application. By analyzing query components like table names, JOIN structures, and WHERE clauses, it performs a reverse-lookup to identify the exact Eloquent model, service method, or controller responsible for the database hit.

This skill is particularly valuable for developers maintaining legacy codebases or large-scale Laravel projects where database interactions are abstracted through multiple layers. By integrating this into Openclaw Skills, teams can drastically reduce the time spent on manual grep searches and debugging sessions.

SQL Reflect Use Cases

  • Identifying the source of slow queries identified in database slow logs.
  • Debugging complex Eloquent relationships and whereHas constraints that generate unexpected SQL.
  • Mapping raw database interactions back to specific Controller methods or Service classes.
  • Visualizing the call chain that leads from a web request to a specific database table interaction.

How SQL Reflect Works

  1. Extract metadata from the raw SQL query, including primary table names, JOIN clauses, and specific WHERE conditions.
  2. Execute high-speed searches across the project directory for table strings and converted PascalCase Model names.
  3. Analyze code structure to match SQL keywords to Laravel-specific syntax, such as mapping EXISTS to whereHas() or BETWEEN to whereBetween().
  4. Verify the structural integrity by identifying Model associations like belongsTo or hasMany in the source code.
  5. Trace the execution path from the Model layer up through the application to define the complete call stack.

SQL Reflect Setup

To get started with SQL Reflect within the Openclaw Skills ecosystem, ensure your agent has read access to your PHP project root:

# Navigate to your Laravel project root
cd /path/to/your/laravel-app

# Ensure grep or ripgrep is installed on your system
# SQL Reflect will automatically utilize these tools to scan your app/ directory

SQL Reflect Data Schema & Taxonomy

The skill organizes its analysis based on the following taxonomy:

Data Component Description
Table Mapping A dictionary that maps database table names (e.g., pk_customer) to Laravel Models (e.g., Customers).
Syntax Bridge A logic layer mapping SQL structures like INNER JOIN to Eloquent methods like join().
Field Signatures Logical combinations of database columns used to identify specific business modules.
Call Path A sequential trace from the Controller through the Service layer to the final query execution.

SQL Reflect Advanced Features

  • Automatic conversion of table prefixes and snake_case tables to PascalCase Eloquent Models.
  • Deep tracing of nested EXISTS and NOT EXISTS subqueries to Laravel whereHas and whereDoesntHave logic.
  • Call chain visualization showing the exact line numbers from Controller to Model.
  • Support for identifying business logic modules via unique field combinations in WHERE clauses.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*