Claude Skills
CollectionsCompareWorkflowsNominate
Sign inSign up
© 2026 Curated Agent Skills·Learn more about Agent Skills
Back to repository

sqlx-patterns

verified

SQL and Dataform SQLX coding conventions, patterns, and best practices. Covers SQLX configuration, SQL patterns, incremental tables, layer architecture, CTEs, window functions, and naming conventions for Expanly scoring models.

View on GitHub

Marketplace

expanly-claude-code-agents

Expanly/expanly-claude-code-agents

Plugin

expanly-scoring-model

data

Repository

Expanly/expanly-claude-code-agents

plugins/expanly-scoring-model/skills/sqlx-patterns/SKILL.md

Last Verified

February 1, 2026

Install Skill

Select agents to install to:

Scope:
npx add-skill https://github.com/Expanly/expanly-claude-code-agents/blob/main/plugins/expanly-scoring-model/skills/sqlx-patterns/SKILL.md -a claude-code --skill sqlx-patterns

Installation paths:

Claude
.claude/skills/sqlx-patterns/
Powered by add-skill CLI

Instructions

# SQL/SQLX Patterns Reference

This skill provides coding conventions and patterns for BigQuery SQL and Dataform SQLX development. Reference these patterns when writing data transformations.

---

## SQLX File Structure

### View Configuration

```sql
config {
  type: "view",
  schema: "expanly_query_builder_data",
  tags: ["client_name", "layer2", "scoring"]
}
```

### Incremental Table Configuration

```sql
config {
  type: "incremental",
  schema: "expanly_query_builder_data_snapshots",
  uniqueKey: ["snapshot_date", "join_id"],
  protected: true,
  bigquery: {
    partitionBy: "snapshot_date",
    clusterBy: ["item_group_id"]
  },
  tags: ["snapshot", "scoring"]
}
```

### Table Configuration

```sql
config {
  type: "table",
  schema: "expanly_query_builder_data",
  tags: ["client_name"]
}
```

---

## Dependency Patterns

### Internal References

```sql
FROM ${ref("table_name")}

FROM ${ref("schema_name", "table_name")}
```

### Variable References

```sql
FROM ${ref(dataform.projectConfig.vars.raw__feed)}
```

### External References (No Tracking)

```sql
FROM `project.dataset.table`
```

### Fully Qualified Reference

```sql
FROM ${ref({database: "project-id", schema: "dataset", name: "table"})}
```

---

## SQL Patterns

### Safe Operations (MANDATORY)

```sql
SAFE_DIVIDE(revenue, cost) AS roas

COALESCE(field, 0) AS field_with_default

SAFE_CAST(string_field AS FLOAT64) AS numeric_field

GREATEST(0, LEAST(100, calculated_value)) AS capped_value
```

### ID Normalization (MANDATORY)

```sql
UPPER(TRIM(id_column)) AS join_id
```

**Critical**: GA4 uses mixed case, Google Ads uses lowercase. Always normalize.

### Deduplication

```sql
SELECT * EXCEPT(row_num)
FROM (
  SELECT *,
    ROW_NUMBER() OVER (
      PARTITION BY id
      ORDER BY priority_field DESC
    ) AS row_num
  FROM source_table
)
WHERE row_num = 1
```

### Conditional Ranking

Rank only items with data, avoid ranking nulls:

```sql
CASE
  WHEN gads_cost_short > 0
    THEN PERCENT_RANK() OVER 

Validation Details

Front Matter
Required Fields
Valid Name Format
Valid Description
Has Sections
Allowed Tools
Instruction Length:
8530 chars