chore: drizzle-engineering skill source + pre-hook - #51
Conversation
🤖 CodeAnt AI — Review Status
|
✅ Deploy Preview for moderaty ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
Warning Review limit reached
Next review available in: 21 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds a Drizzle ORM engineering skill with schema, query, validation, migration, transaction, driver, and troubleshooting guidance. Adds a prompt hook that detects Drizzle-related requests and injects the full skill or a directive. ChangesDrizzle engineering guidance
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant PromptHarness
participant skill_prehook.py
participant SKILL.md
PromptHarness->>skill_prehook.py: Submit JSON or raw prompt
skill_prehook.py->>skill_prehook.py: Parse prompt and match Drizzle keywords
skill_prehook.py->>SKILL.md: Load full skill when enabled
SKILL.md-->>skill_prehook.py: Return skill content
skill_prehook.py-->>PromptHarness: Emit skill content or directive
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Sequence DiagramThis PR adds a prompt prehook that detects Drizzle-related work, loads the engineering skill, and injects its guidance into the agent context before processing continues. sequenceDiagram
participant UserPrompt
participant Prehook
participant SkillFile
participant AgentHarness
UserPrompt->>Prehook: Submit prompt
Prehook->>Prehook: Detect Drizzle keywords
Prehook->>SkillFile: Read engineering skill
SkillFile-->>Prehook: Return skill guidance
Prehook-->>AgentHarness: Inject guidance into context
Generated by CodeAnt AI |
🏁 CodeAnt Quality Gate ResultsCommit: ✅ Overall Status: PASSEDQuality Gate Details
|
There was a problem hiding this comment.
Review complete. The code changes add comprehensive Drizzle ORM engineering documentation and tooling that are well-structured with no blocking defects identified. All Python code includes proper error handling, and documentation examples are syntactically correct.
You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.
Not up to standards ⛔🟢 Issues
|
| Category | Results |
|---|---|
| Documentation | 1 minor |
🔴 Metrics 12 complexity · 4 duplication
Metric Results Complexity ✅ 12 (≤ 100 complexity) Duplication ⚠️ 4 (≤ 1 duplication)
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
PR Summary by QodoAdd drizzle-engineering agent skill docs and Drizzle keyword prehook
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
There was a problem hiding this comment.
Pull Request Overview
The pull request is currently not up to standards according to Codacy, primarily due to issues within the pre-hook implementation and documentation accuracy. The most significant concern is the overly broad trigger list in the Python pre-hook, which will cause the Drizzle engineering skill to be injected into almost any database-related task, regardless of whether Drizzle is actually used. This will lead to context window pollution and potentially conflicting instructions.
Additionally, the documentation contains outdated information regarding drizzle-kit's ability to detect renames and recommends unsafe patterns using sql.raw. The pre-hook script itself is complex and lacks automated tests, posing a maintenance risk.
About this PR
- Generic triggers such as 'orm' and 'migration' are highly likely to cause false positives, injecting Drizzle-specific guidelines into tasks that use other ORMs (e.g., Prisma, SQLAlchemy) or generic migration tools.
- The pre-hook script is complex and lacks automated unit tests. Relying on manual verification for a component that modifies the agent's context is risky; consider adding unit tests to verify trigger logic and prompt parsing.
Test suggestions
- Detection of Drizzle-specific keywords (e.g., 'drizzle-orm', 'sqliteTable')
- Parsing of JSON input from standard agent harnesses like Claude Code
- Switching between full skill inlining and directive mode via DRIZZLE_ENGINEERING_HOOK_FULL
- Handling of file access errors when reading SKILL.md to ensure the hook remains silent rather than failing
- Verification that broad keywords like 'orm' or 'migration' do not trigger excessive false positives for non-Drizzle tasks
- Unit tests for skill_prehook.py to address high complexity and lack of coverage
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Detection of Drizzle-specific keywords (e.g., 'drizzle-orm', 'sqliteTable')
2. Parsing of JSON input from standard agent harnesses like Claude Code
3. Switching between full skill inlining and directive mode via DRIZZLE_ENGINEERING_HOOK_FULL
4. Handling of file access errors when reading SKILL.md to ensure the hook remains silent rather than failing
5. Verification that broad keywords like 'orm' or 'migration' do not trigger excessive false positives for non-Drizzle tasks
6. Unit tests for skill_prehook.py to address high complexity and lack of coverage
TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback
| TRIGGERS = [ | ||
| r"\bdrizzle\b", r"\bdrizzle-orm\b", r"\bdrizzle-kit\b", r"\bdrizzle-zod\b", | ||
| r"\bdrizzle\.config\b", | ||
| r"\bsqliteTable\b", r"\bpgTable\b", r"\bmysqlTable\b", | ||
| r"\bonConflictDo(Update|Nothing)\b", r"\bupsert(s|ing)?\b", | ||
| r"\bdb\.transaction\b", r"\bdb\.query\b", r"\bprepared\s+statement(s)?\b", | ||
| r"\bsql\.placeholder\b", r"\bsql\.raw\b", | ||
| r"\borm\b", | ||
| r"\bselect\s+.+\s+from\b", r"\bjoin(s|ing)?\b", r"\bleftJoin\b", r"\binnerJoin\b", | ||
| r"\bn\+1\b", r"\brelations\b", | ||
| r"\bmigration(s)?\b", r"\bbackfill(s|ing)?\b", | ||
| r"\bexpand[-\s]and[-\s]contract\b", r"\bschema\s+(drift|declaration|design)\b", | ||
| r"\bcolumn\s+already\s+exists\b", | ||
| ] |
There was a problem hiding this comment.
🔴 HIGH RISK
The trigger list includes extremely broad terms like 'orm', 'migration', 'select', 'join', and 'upsert'. These will cause the Drizzle engineering skill to be injected into the context for nearly any database-related task, polluting the context window. Narrow these to Drizzle-specific terms such as package names ('drizzle-orm'), specific table builders ('pgTable', 'sqliteTable'), or unique API methods.
| if __name__ == "__main__": | ||
| try: | ||
| main() | ||
| except Exception: |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Avoid silently ignoring all exceptions. Even if the hook must not block the prompt flow, logging the error to sys.stderr ensures visibility for troubleshooting when the skill fails to load. Update the exception handling in the __main__ block to log any caught Exception to sys.stderr before exiting with code 0.
| Rules: | ||
|
|
||
| 1. `sql.raw()` accepts only string literals you wrote. If any part came from a request, config, or | ||
| another system, it does not go through `sql.raw`. (Its one legitimate use: referencing the |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Suggestion: Using sql.raw is discouraged even for internal identifiers. Use the sql template literal with the column object instead to ensure proper escaping.
| }); | ||
|
|
||
| // referencing the proposed row (Postgres "excluded"): | ||
| set: { name: sql.raw(`excluded.${users.name.name}`) } |
There was a problem hiding this comment.
🟡 MEDIUM RISK
Suggestion: Referencing the excluded table using sql.raw is unnecessary and bypasses safety mechanisms. Drizzle can safely interpolate column identifiers within the sql template tag (e.g., sqlexcluded.${users.name}`).
| drizzle-kit diffs snapshots, not intent. Before committing, read the SQL and check: | ||
|
|
||
| 1. **Drops** — every `DROP TABLE`/`DROP COLUMN` is a data-loss decision. Is it intended? If it | ||
| appeared because you renamed something, it's wrong: kit can't see renames. |
There was a problem hiding this comment.
⚪ LOW RISK
The claim that drizzle-kit cannot see renames is outdated. The CLI provides interactive prompts to detect renames during the generate command, which results in correct rename statements in the migration file.
| def read_prompt() -> str: | ||
| raw = sys.stdin.read() | ||
| if not raw.strip(): | ||
| return "" | ||
| try: | ||
| data = json.loads(raw) | ||
| except json.JSONDecodeError: | ||
| return raw | ||
| if isinstance(data, dict): | ||
| for key in ("prompt", "user_prompt", "message", "text"): | ||
| val = data.get(key) | ||
| if isinstance(val, str) and val.strip(): | ||
| return val | ||
| return "" |
There was a problem hiding this comment.
⚪ LOW RISK
Suggestion: This file duplicates the read_prompt logic from sqlite-engineering. Consider abstracting this into a shared utility or using a template to avoid manually syncing boilerplate across every new engineering skill.
Code Review by Qodo
Context used✅ Compliance rules (platform):
74 rules 1.
|
There was a problem hiding this comment.
Warning
CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.
Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.
Actionable comments posted: 11
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.agents/skills-src/drizzle-engineering/assets/hooks/skill_prehook.py:
- Around line 103-108: Update the __main__ exception handling so hook failures
are no longer silently discarded: catch expected decoding and I/O failures at
their sources, and if the final catch-all remains necessary to preserve exit
code 0, write only the exception type to stderr without including prompt or
skill contents.
- Around line 2-4: Update the module docstring at the top of skill_prehook.py so
the opening line is followed by a blank line, the summary appears on the next
paragraph’s first line, and that summary ends with a period, preserving the
existing description.
- Around line 35-40: In the trigger patterns used by the prehook, narrow generic
matches such as join, relations, and migrations so unrelated prompts do not
enable full SKILL.md injection. Require a Drizzle-specific term or database
context for these generic terms, while preserving detection of valid Drizzle
prompts. Add regression coverage for unrelated prompts and valid Drizzle prompts
through the existing hook test symbols.
In @.agents/skills-src/drizzle-engineering/references/queries-performance.md:
- Around line 84-91: Update the onConflictDoUpdate example to remove the
undefined excludedName reference in set; replace it with a complete valid
SQL/value expression consistent with the insert example, or omit the example if
no valid expression is intended.
- Around line 55-60: In the N+1 query example, update the result binding in the
`posts` query from `posts` to `postRows` so it does not shadow the table
reference before initialization. Preserve the loop and author assignment logic,
updating any references to the fetched result as needed.
- Around line 96-102: Replace the blanket buildConflictUpdateColumns example
with a valid Drizzle pattern: define a local helper or explicit set map that
includes only mutable user column keys, excluding immutable/defaulted fields
such as id and createdAt, and remove the invalid buildConflictUpdateColumns
import and usage.
In @.agents/skills-src/drizzle-engineering/references/schema-declaration.md:
- Around line 24-30: Update the defineConfig example to clearly label it as
SQLite-only, or align it with the repository’s Turso setup by using dialect
'turso' and the corresponding `@libsql/client` credentials including the auth
token. Ensure the schema, output, and strict/verbose settings remain unchanged.
- Around line 124-135: Update the self-reference guidance in the schema
declaration documentation to reflect that drizzle-orm@0.45.2 supports the inline
references form when the callback explicitly returns AnySQLiteColumn. Retain or
additionally show the standalone foreignKey alternative, and ensure the example
and surrounding explanation no longer claim inline self-references are
unsupported.
In @.agents/skills-src/drizzle-engineering/SKILL.md:
- Around line 33-34: Revise the source-of-truth guidance in the TypeScript
schema section to apply only to normal schema changes, allowing manual database
reconciliation when recovering from a partial migration. Reference the
documented recovery procedure in migrations-workflow.md, while preserving the
warning against routine out-of-band edits.
- Around line 58-61: Add shell language identifiers to the command fences at
.agents/skills-src/drizzle-engineering/SKILL.md lines 58-61 and
.agents/skills-src/drizzle-engineering/references/migrations-workflow.md lines
62-64, 95-97, and 119-123; no other content changes are needed.
- Around line 46-47: Update the multi-row mutation rule in the Drizzle
engineering guidance to require db.transaction when the driver supports it,
while allowing an equivalent atomic SQL statement or driver-supported batch API
such as db.batch when transactions are unavailable. Preserve the requirement
that the entire mutation remains atomic and cannot leave a partial write.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: bfe8d7e3-1229-47ff-bb34-5ea23120fb94
📒 Files selected for processing (7)
.agents/skills-src/drizzle-engineering/SKILL.md.agents/skills-src/drizzle-engineering/assets/hooks/skill_prehook.py.agents/skills-src/drizzle-engineering/references/migrations-workflow.md.agents/skills-src/drizzle-engineering/references/queries-performance.md.agents/skills-src/drizzle-engineering/references/schema-declaration.md.agents/skills-src/drizzle-engineering/references/transactions-drivers.md.agents/skills-src/drizzle-engineering/references/validation-zod.md
| export default defineConfig({ | ||
| dialect: 'sqlite', // 'postgresql' | 'mysql' | 'sqlite' | 'turso' | ... | ||
| schema: './src/lib/server/db/schema', // file OR folder — folder = all files merged | ||
| out: './drizzle', // migrations + snapshots + journal live here, COMMITTED | ||
| dbCredentials: { url: process.env.DATABASE_URL! }, | ||
| strict: true, // interactive confirmations on ambiguous diffs | ||
| verbose: true, // print generated statements |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Align or label the database configuration example.
The repository configuration in drizzle.config.ts, Lines 31-41, uses dialect: 'turso', @libsql/client, and an auth token. This example sets dialect: 'sqlite' and provides only a URL. If contributors copy it into this repository, Drizzle Kit can use the wrong dialect and driver configuration. Mark this as a SQLite-only example or show the repository's Turso configuration.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.agents/skills-src/drizzle-engineering/references/schema-declaration.md
around lines 24 - 30, Update the defineConfig example to clearly label it as
SQLite-only, or align it with the repository’s Turso setup by using dialect
'turso' and the corresponding `@libsql/client` credentials including the auth
token. Ensure the schema, output, and strict/verbose settings remain unchanged.
…ect doc examples
|
Review dispositions at 926697e — all findings verified against the code first. Fixed (valid):
Skipped (invalid or moot):
Hook re-verified after changes: compiles, injects on Drizzle prompts, silent no-op (exit 0) on generic database and unrelated prompts. Installed copy at |
PR Code Suggestions ✨Latest suggestions up to commit
|
| Category | Suggestion | Severity | Generated at (UTC) |
| Performance |
Overlapping Drizzle triggers cause duplicate full skill injection when both hooks are enabledWhen both the documented sqlite and Drizzle hooks are installed, this .agents/skills-src/drizzle-engineering/assets/hooks/skill_prehook.py [35-36] Why it matters? 🤔
(Use Cmd/Ctrl + Click for best experience) Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** .agents/skills-src/drizzle-engineering/assets/hooks/skill_prehook.py
**Line:** 35:36
**Comment:**
*Performance: When both the documented sqlite and Drizzle hooks are installed, this `drizzle` trigger overlaps with the sqlite hook's own `drizzle` trigger. In the default full mode, every Drizzle prompt causes both complete skill documents and directives to be appended, unnecessarily consuming context and potentially crowding out the user request. Avoid overlapping triggers or coordinate the hooks so only one full payload is emitted.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix | Major | 2026-08-03 12:33
|
| Api mismatch |
Unqualified transaction guidance can generate unsupported code for D1 driversThis directive unconditionally instructs the agent to put multi-row mutations inside .agents/skills-src/drizzle-engineering/assets/hooks/skill_prehook.py [53-54] Why it matters? 🤔
(Use Cmd/Ctrl + Click for best experience) Prompt for AI Agent 🤖This is a comment left during a code review.
**Path:** .agents/skills-src/drizzle-engineering/assets/hooks/skill_prehook.py
**Line:** 53:54
**Comment:**
*Api Mismatch: This directive unconditionally instructs the agent to put multi-row mutations inside `db.transaction`, but the loaded skill explicitly says D1 rejects SQL transactions and requires a single atomic statement or `db.batch` instead. For D1/Turso work, the injected directive can cause unsupported transaction code. Qualify this instruction by driver.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix | Major | 2026-08-03 12:33
|
|
Round-2 dispositions at fa7fcf8 (CodeAnt suggestions on 926697e) — both verified and fixed:
Codacy's remaining "1 minor (Documentation)" is the previously-dispositioned Both installed hooks at |
|
There was a problem hiding this comment.
Warning
CodeRabbit couldn't request changes on this pull request because it doesn't have sufficient GitHub permissions.
Please grant CodeRabbit Pull requests: Read and write permission and re-run the review.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.agents/skills-src/drizzle-engineering/references/migrations-workflow.md:
- Around line 120-123: Update the migration workflow around the drizzle-kit
generate and wrangler d1 migrations apply commands so both tools use the same
migrations directory. Configure Wrangler’s migrations_dir to drizzle, configure
Drizzle to emit to Wrangler’s configured directory, or add a documented copy
step before applying migrations; ensure the documented commands operate on the
generated files.
In @.agents/skills-src/drizzle-engineering/references/queries-performance.md:
- Around line 94-113: Update the upsert example around
buildConflictUpdateColumns so the set property is passed inside an
onConflictDoUpdate({ ... }) options object, keeping the helper as the value for
the set field and removing the standalone set expression.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 2047b1ca-5cfa-472e-998c-57c56def4fc6
📒 Files selected for processing (5)
.agents/skills-src/drizzle-engineering/SKILL.md.agents/skills-src/drizzle-engineering/assets/hooks/skill_prehook.py.agents/skills-src/drizzle-engineering/references/migrations-workflow.md.agents/skills-src/drizzle-engineering/references/queries-performance.md.agents/skills-src/drizzle-engineering/references/schema-declaration.md
| ```sh | ||
| npx drizzle-kit generate | ||
| npx wrangler d1 migrations apply <db-name> --local | ||
| npx wrangler d1 migrations apply <db-name> --remote |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- target file ---'
sed -n '1,180p' .agents/skills-src/drizzle-engineering/references/migrations-workflow.md
printf '%s\n' '--- Drizzle and Wrangler configuration references ---'
rg -n --hidden -S \
'migrations_dir|migrationsDir|out:|drizzle-kit|drizzle\.config|wrangler\.toml|wrangler\.json|d1 migrations apply|drizzle' \
. \
-g '!node_modules' -g '!dist' -g '!build' \
| head -300
printf '%s\n' '--- relevant tracked files ---'
git ls-files | rg '(^|/)(drizzle|wrangler|package\.json|.*migration.*|.*config.*)' | head -200Repository: Bonobo791/Moderaty
Length of output: 41179
🏁 Script executed:
#!/bin/bash
set -eu
printf '%s\n' '--- drizzle.config.ts ---'
cat -n drizzle.config.ts
printf '%s\n' '--- package.json ---'
cat -n package.json
printf '%s\n' '--- Wrangler configuration files ---'
git ls-files | rg '(^|/)(wrangler\.toml|wrangler\.json|wrangler\.jsonc)$' || true
printf '%s\n' '--- migration directories ---'
find . -maxdepth 2 -type d \( -name drizzle -o -name migrations \) -print | sort
printf '%s\n' '--- read-only path consistency check ---'
python3 - <<'PY'
from pathlib import Path
import re
drizzle = Path("drizzle.config.ts").read_text()
out = re.search(r"\bout\s*:\s*['\"]([^'\"]+)['\"]", drizzle)
print("drizzle.config.ts out:", out.group(1) if out else "<not found>")
print("Drizzle output directory exists:", Path(out.group(1)).is_dir() if out else False)
print("Default Wrangler D1 directory exists:", Path("migrations").is_dir())
print("Wrangler config tracked:", any(
p.name in {"wrangler.toml", "wrangler.json", "wrangler.jsonc"}
for p in map(Path, __import__("subprocess").check_output(
["git", "ls-files"], text=True
).splitlines())
))
PYRepository: Bonobo791/Moderaty
Length of output: 3671
🌐 Web query:
Cloudflare Wrangler D1 migrations apply migrations_dir default official documentation
💡 Result:
In Cloudflare Wrangler, the default directory for D1 migrations is./migrations [1][2]. When you run wrangler d1 migrations create, Wrangler automatically creates this migrations folder in your project directory if it does not already exist [3][4]. You can customize this location in your wrangler.jsonc or wrangler.toml configuration file by specifying the migrations_dir field within your D1 database binding configuration [3][5][6]. Example configuration for a custom directory: { "d1_databases": [ { "binding": "DB", "database_name": "my-database", "database_id": "", "migrations_dir": "my-custom-migrations-folder" } ] } If you are using an ORM that requires a nested directory structure (such as Drizzle), you must set both migrations_dir and migrations_pattern to correctly locate and apply your migration files [3][5][7]. The migrations_pattern defaults to <migrations_dir>/*.sql if not otherwise specified [5][6][7].
Citations:
- 1: https://github.com/cloudflare/workers-sdk/blob/e643b19d/packages/wrangler/src/d1/constants.ts
- 2: https://github.com/cloudflare/cloudflare-docs/blob/production/src/content/docs/d1/reference/migrations.mdx
- 3: https://developers.cloudflare.com/d1/reference/migrations/
- 4: https://www.thisdot.co/blog/d1-sqlite-schema-migrations-and-seeds
- 5: https://developers.cloudflare.com/workers/wrangler/configuration/
- 6: https://developers.cloudflare.com/workers/wrangler/configuration/index.md
- 7: https://developers.cloudflare.com/changelog/post/2026-06-04-migrations-pattern/
Configure Wrangler to read Drizzle's output directory.
drizzle-kit generate writes to ./drizzle, while Wrangler defaults to ./migrations when migrations_dir is unset. Set Wrangler's migrations_dir to drizzle, configure Drizzle to use Wrangler's directory, or document a copy step.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.agents/skills-src/drizzle-engineering/references/migrations-workflow.md
around lines 120 - 123, Update the migration workflow around the drizzle-kit
generate and wrangler d1 migrations apply commands so both tools use the same
migrations directory. Configure Wrangler’s migrations_dir to drizzle, configure
Drizzle to emit to Wrangler’s configured directory, or add a documented copy
step before applying migrations; ensure the documented commands operate on the
generated files.
| // helper for "update every inserted column" — NOT a drizzle-orm export; it is | ||
| // the user-defined helper from the Drizzle upsert guide. Define it locally: | ||
| import { getTableColumns, sql, type SQL } from 'drizzle-orm'; | ||
| import type { SQLiteTable } from 'drizzle-orm/sqlite-core'; | ||
|
|
||
| const buildConflictUpdateColumns = <T extends SQLiteTable, Q extends keyof T['_']['columns']>( | ||
| table: T, | ||
| columns: Q[], | ||
| ) => { | ||
| const cls = getTableColumns(table); | ||
| return columns.reduce( | ||
| (acc, column) => { | ||
| acc[column] = sql.raw(`excluded."${cls[column].name}"`); | ||
| return acc; | ||
| }, | ||
| {} as Record<Q, SQL>, | ||
| ); | ||
| }; | ||
|
|
||
| set: buildConflictUpdateColumns(users, ['name', 'email']), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -e
file=".agents/skills-src/drizzle-engineering/references/queries-performance.md"
sed -n '70,125p' "$file"
printf '\n--- nearby onConflictDoUpdate occurrences ---\n'
rg -n -C 4 'onConflictDoUpdate|buildConflictUpdateColumns|^set:' "$file"
printf '\n--- repository references to the helper ---\n'
rg -n -C 3 'buildConflictUpdateColumns' .Repository: Bonobo791/Moderaty
Length of output: 3373
Wrap the helper call in onConflictDoUpdate({ ... }). The standalone set: at Line 113 is invalid TypeScript after the preceding call closes.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.agents/skills-src/drizzle-engineering/references/queries-performance.md
around lines 94 - 113, Update the upsert example around
buildConflictUpdateColumns so the set property is passed inside an
onConflictDoUpdate({ ... }) options object, keeping the helper as the value for
the set field and removing the standalone set expression.




User description
Adds the drizzle-engineering skill source under
.agents/skills-src/drizzle-engineering/(flattened to match the sqlite-engineering layout) plus a UserPromptSubmit pre-hook atassets/hooks/skill_prehook.py, adapted from the sqlite pre-hook with Drizzle/Turso/ORM triggers.The installed copy lives at
~/.agents/skills/drizzle-engineering/and the hook is wired in~/.kimi-code/config.tomlalongside the sqlite hook (both user-scope, not in this repo).Verified: hook compiles, injects the skill on a drizzle-flavored prompt, no-ops silently on an unrelated prompt, and config.toml parses with both hook entries.
CodeAnt-AI Description
Add Drizzle ORM guidance and automatic skill loading for database work
What Changed
Impact
✅ Consistent Drizzle guidance for ORM tasks✅ Fewer unsafe production migrations✅ Fewer accidental SQL injection and partial-write risks💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.