@ranimontagna/agent-toolkit 0.1.7 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +83 -14
- package/dist/src/args.js +10 -0
- package/dist/src/args.js.map +1 -1
- package/dist/src/menu.js +43 -2
- package/dist/src/menu.js.map +1 -1
- package/dist/src/skills.js +9 -2
- package/dist/src/skills.js.map +1 -1
- package/dist/src/state.d.ts +2 -0
- package/dist/src/state.js +7 -0
- package/dist/src/state.js.map +1 -1
- package/dist/src/status.js +3 -1
- package/dist/src/status.js.map +1 -1
- package/dist/src/ui.js +4 -1
- package/dist/src/ui.js.map +1 -1
- package/dist/src/usage.js +2 -0
- package/dist/src/usage.js.map +1 -1
- package/docs/assets/install-plan.svg +2 -2
- package/docs/assets/install-skill-packages.svg +14 -14
- package/package.json +1 -1
- package/skills/backend/database/postgres-patterns/LICENSE.ANTIGRAVITY +21 -0
- package/skills/backend/database/postgres-patterns/LICENSE.ECC +21 -0
- package/skills/backend/database/postgres-patterns/NOTICE.md +11 -0
- package/skills/backend/database/postgres-patterns/SKILL.md +180 -0
- package/skills/backend/kotlin/kotlin-patterns/LICENSE +21 -0
- package/skills/backend/kotlin/kotlin-patterns/NOTICE.md +7 -0
- package/skills/backend/kotlin/kotlin-patterns/SKILL.md +711 -0
- package/skills/backend/kotlin/kotlin-testing/LICENSE +21 -0
- package/skills/backend/kotlin/kotlin-testing/NOTICE.md +7 -0
- package/skills/backend/kotlin/kotlin-testing/SKILL.md +824 -0
- package/skills/backend/python/python-patterns/LICENSE +21 -0
- package/skills/backend/python/python-patterns/NOTICE.md +7 -0
- package/skills/backend/python/python-patterns/SKILL.md +424 -0
- package/skills/backend/python/python-testing/LICENSE +21 -0
- package/skills/backend/python/python-testing/NOTICE.md +7 -0
- package/skills/backend/python/python-testing/SKILL.md +494 -0
- package/skills/devops/docker-patterns/LICENSE.ANTIGRAVITY +21 -0
- package/skills/devops/docker-patterns/LICENSE.ECC +21 -0
- package/skills/devops/docker-patterns/NOTICE.md +11 -0
- package/skills/devops/docker-patterns/SKILL.md +397 -0
- package/skills/frontend/accessibility/LICENSE +21 -0
- package/skills/frontend/accessibility/NOTICE.md +10 -0
- package/skills/frontend/accessibility/SKILL.md +145 -0
- package/skills/frontend/design/ui-ux-pro-max/LICENSE +21 -0
- package/skills/frontend/design/ui-ux-pro-max/NOTICE.md +12 -0
- package/skills/frontend/design/ui-ux-pro-max/SKILL.md +672 -0
- package/skills/frontend/design/ui-ux-pro-max/data/_sync_all.py +414 -0
- package/skills/frontend/design/ui-ux-pro-max/data/app-interface.csv +31 -0
- package/skills/frontend/design/ui-ux-pro-max/data/charts.csv +26 -0
- package/skills/frontend/design/ui-ux-pro-max/data/colors.csv +162 -0
- package/skills/frontend/design/ui-ux-pro-max/data/design.csv +1776 -0
- package/skills/frontend/design/ui-ux-pro-max/data/draft.csv +1779 -0
- package/skills/frontend/design/ui-ux-pro-max/data/google-fonts.csv +1924 -0
- package/skills/frontend/design/ui-ux-pro-max/data/icons.csv +106 -0
- package/skills/frontend/design/ui-ux-pro-max/data/landing.csv +35 -0
- package/skills/frontend/design/ui-ux-pro-max/data/products.csv +162 -0
- package/skills/frontend/design/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/angular.csv +51 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/laravel.csv +51 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/threejs.csv +54 -0
- package/skills/frontend/design/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/skills/frontend/design/ui-ux-pro-max/data/styles.csv +85 -0
- package/skills/frontend/design/ui-ux-pro-max/data/typography.csv +74 -0
- package/skills/frontend/design/ui-ux-pro-max/data/ui-reasoning.csv +162 -0
- package/skills/frontend/design/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/skills/frontend/design/ui-ux-pro-max/scripts/core.py +262 -0
- package/skills/frontend/design/ui-ux-pro-max/scripts/design_system.py +1148 -0
- package/skills/frontend/design/ui-ux-pro-max/scripts/search.py +114 -0
- package/skills/general/code-reviewer/AGENTS.md +292 -0
- package/skills/general/code-reviewer/LICENSE +201 -0
- package/skills/general/code-reviewer/NOTICE.md +10 -0
- package/skills/general/code-reviewer/SKILL.md +132 -0
- package/skills/general/code-reviewer/rules/correctness-error-handling.md +279 -0
- package/skills/general/code-reviewer/rules/maintainability-naming.md +149 -0
- package/skills/general/code-reviewer/rules/maintainability-type-hints.md +93 -0
- package/skills/general/code-reviewer/rules/performance-n-plus-one.md +250 -0
- package/skills/general/code-reviewer/rules/security-sql-injection.md +142 -0
- package/skills/general/code-reviewer/rules/security-xss-prevention.md +225 -0
package/dist/src/usage.js
CHANGED
|
@@ -39,6 +39,7 @@ Install scope:
|
|
|
39
39
|
--skills-dir DIR Use another source directory for Custom Skills
|
|
40
40
|
--skills-package NAME Install Custom Skills from a first-level package, repeatable
|
|
41
41
|
--skills-scope SCOPE Install skills under a relative scope path, repeatable
|
|
42
|
+
--skills-path PATH Install exact Custom Skill path, repeatable
|
|
42
43
|
--skills-list List discovered Custom Skills and exit
|
|
43
44
|
|
|
44
45
|
Other:
|
|
@@ -61,6 +62,7 @@ Environment:
|
|
|
61
62
|
CUSTOM_SKILLS_DIR Source directory for custom skills
|
|
62
63
|
SKILLS_PACKAGE Comma-separated first-level skill package filters
|
|
63
64
|
SKILLS_SCOPE Comma-separated skill scope filters
|
|
65
|
+
SKILLS_PATH Comma-separated exact skill path filters
|
|
64
66
|
CLAUDE_CLI_PACKAGE npm package used to install Claude Code CLI
|
|
65
67
|
CODEX_CLI_PACKAGE npm package used to install Codex CLI
|
|
66
68
|
OPENCODE_CLI_PACKAGE npm package used to install OpenCode CLI
|
package/dist/src/usage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/usage.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK;IACnB,OAAO
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../../src/usage.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,KAAK;IACnB,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAmEsD,CAAC;AAChE,CAAC"}
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
<text x="74" y="392" fill="#cbd5e1" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">Custom Skills:</text>
|
|
23
23
|
<text x="96" y="422" fill="#e5e7eb" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">- Selected packages: core</text>
|
|
24
|
-
<text x="96" y="450" fill="#e5e7eb" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">- Selected
|
|
25
|
-
<text x="96" y="478" fill="#e5e7eb" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">-
|
|
24
|
+
<text x="96" y="450" fill="#e5e7eb" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">- Selected individual skills: core/agent-toolkit-maintainer</text>
|
|
25
|
+
<text x="96" y="478" fill="#e5e7eb" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">- Selected source skills: core/agent-toolkit-maintainer</text>
|
|
26
26
|
|
|
27
27
|
<rect x="52" y="506" width="876" height="36" rx="8" fill="#111827" stroke="#334155"/>
|
|
28
28
|
<text x="70" y="530" fill="#86efac" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">Continue with installation? Yes</text>
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
<svg xmlns="http://www.w3.org/2000/svg" width="980" height="520" viewBox="0 0 980 520" role="img" aria-labelledby="title desc">
|
|
2
|
-
<title id="title">Agent Toolkit Custom Skill
|
|
3
|
-
<desc id="desc">Terminal screenshot showing selectable Custom
|
|
2
|
+
<title id="title">Agent Toolkit Custom Skill selection screen</title>
|
|
3
|
+
<desc id="desc">Terminal screenshot showing selectable individual Custom Skills in the Clack installer.</desc>
|
|
4
4
|
<rect width="980" height="520" rx="18" fill="#111827"/>
|
|
5
5
|
<rect x="24" y="24" width="932" height="472" rx="14" fill="#0b1020" stroke="#263247"/>
|
|
6
6
|
<circle cx="52" cy="52" r="7" fill="#ff5f57"/>
|
|
7
7
|
<circle cx="76" cy="52" r="7" fill="#ffbd2e"/>
|
|
8
8
|
<circle cx="100" cy="52" r="7" fill="#28c840"/>
|
|
9
|
-
<text x="126" y="57" fill="#9ca3af" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="14">Custom Skills
|
|
9
|
+
<text x="126" y="57" fill="#9ca3af" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="14">Custom Skills granular selection</text>
|
|
10
10
|
|
|
11
|
-
<text x="52" y="104" fill="#93c5fd" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="19" font-weight="700">Select Custom
|
|
12
|
-
<text x="52" y="138" fill="#cbd5e1" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">
|
|
11
|
+
<text x="52" y="104" fill="#93c5fd" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="19" font-weight="700">Select individual Custom Skills</text>
|
|
12
|
+
<text x="52" y="138" fill="#cbd5e1" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">After package and scope filters, choose exact skills or keep all selected.</text>
|
|
13
13
|
|
|
14
14
|
<rect x="72" y="172" width="836" height="56" rx="10" fill="#172033" stroke="#3b82f6"/>
|
|
15
|
-
<text x="96" y="207" fill="#bfdbfe" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="16">(*) All
|
|
16
|
-
<text x="388" y="207" fill="#94a3b8" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">
|
|
15
|
+
<text x="96" y="207" fill="#bfdbfe" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="16">(*) All selected skills</text>
|
|
16
|
+
<text x="388" y="207" fill="#94a3b8" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">keep the current package/scope result</text>
|
|
17
17
|
|
|
18
18
|
<rect x="72" y="244" width="836" height="56" rx="10" fill="#111827" stroke="#334155"/>
|
|
19
|
-
<text x="96" y="279" fill="#e5e7eb" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="16">( )
|
|
20
|
-
<text x="
|
|
19
|
+
<text x="96" y="279" fill="#e5e7eb" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="16">( ) backend/python/python-patterns</text>
|
|
20
|
+
<text x="458" y="279" fill="#94a3b8" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">Pythonic design patterns</text>
|
|
21
21
|
|
|
22
22
|
<rect x="72" y="316" width="836" height="56" rx="10" fill="#111827" stroke="#334155" opacity="0.72"/>
|
|
23
|
-
<text x="96" y="351" fill="#94a3b8" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="16">(
|
|
24
|
-
<text x="
|
|
23
|
+
<text x="96" y="351" fill="#94a3b8" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="16">(*) backend/python/python-testing</text>
|
|
24
|
+
<text x="458" y="351" fill="#64748b" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">pytest fixtures, mocking and coverage</text>
|
|
25
25
|
|
|
26
26
|
<rect x="72" y="388" width="836" height="56" rx="10" fill="#111827" stroke="#334155" opacity="0.72"/>
|
|
27
|
-
<text x="96" y="423" fill="#94a3b8" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="16">( )
|
|
28
|
-
<text x="
|
|
27
|
+
<text x="96" y="423" fill="#94a3b8" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="16">( ) backend/kotlin/kotlin-testing</text>
|
|
28
|
+
<text x="466" y="423" fill="#64748b" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">Kotest, MockK and coroutine testing</text>
|
|
29
29
|
|
|
30
|
-
<text x="52" y="474" fill="#c4b5fd" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">CLI equivalent: --skills-
|
|
30
|
+
<text x="52" y="474" fill="#c4b5fd" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" font-size="15">CLI equivalent: --skills-path backend/python/python-testing</text>
|
|
31
31
|
</svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ranimontagna/agent-toolkit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "Personal AI agent toolkit installer for Claude Code, Codex CLI, OpenCode, Gemini CLI and graph-aware workflows.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@11.0.6",
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Antigravity User
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Affaan Mustafa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Third-party notice
|
|
2
|
+
|
|
3
|
+
This skill is adapted from two MIT-licensed community skills:
|
|
4
|
+
|
|
5
|
+
- ECC postgres-patterns: https://github.com/affaan-m/ECC/tree/main/.kiro/skills/postgres-patterns
|
|
6
|
+
- ECC source commit: 0f84c0e2796703fbda87d577b2636351418c7442
|
|
7
|
+
- Antigravity postgresql: https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/postgresql
|
|
8
|
+
- Antigravity source commit: b806b97a9a48063f7bdbee5611caf40edd17e305
|
|
9
|
+
|
|
10
|
+
The upstream MIT license texts are included in `LICENSE.ECC` and
|
|
11
|
+
`LICENSE.ANTIGRAVITY`.
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: postgres-patterns
|
|
3
|
+
description: Use when writing PostgreSQL queries or migrations, designing schemas, choosing data types, adding indexes, implementing RLS, tuning slow queries, reviewing DDL safety, or configuring production database behavior.
|
|
4
|
+
metadata:
|
|
5
|
+
origin: ECC and antigravity-awesome-skills
|
|
6
|
+
credit: Supabase team, Affaan Mustafa, and Antigravity User
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# PostgreSQL Patterns
|
|
10
|
+
|
|
11
|
+
Quick reference for PostgreSQL best practices. For detailed guidance, use the `database-reviewer` agent.
|
|
12
|
+
|
|
13
|
+
## When to Activate
|
|
14
|
+
|
|
15
|
+
- Writing SQL queries or migrations
|
|
16
|
+
- Designing database schemas
|
|
17
|
+
- Troubleshooting slow queries
|
|
18
|
+
- Implementing Row Level Security
|
|
19
|
+
- Setting up connection pooling
|
|
20
|
+
|
|
21
|
+
## Schema Review Guardrails
|
|
22
|
+
|
|
23
|
+
Before changing DDL, capture entities, access patterns, expected row counts,
|
|
24
|
+
QPS, retention, and migration constraints. Optimize for correctness first,
|
|
25
|
+
then tune for measured hot paths.
|
|
26
|
+
|
|
27
|
+
- Prefer `snake_case` unquoted identifiers.
|
|
28
|
+
- Define primary keys where rows are referenced by other tables.
|
|
29
|
+
- Prefer `bigint generated always as identity` for local IDs; use UUID only
|
|
30
|
+
when global uniqueness, opacity, or distributed creation is required.
|
|
31
|
+
- Normalize first; denormalize only after measuring read bottlenecks.
|
|
32
|
+
- Add `not null`, `check`, `unique`, and foreign key constraints to enforce
|
|
33
|
+
invariants in the database.
|
|
34
|
+
- Index foreign keys manually. PostgreSQL does not auto-index FK columns.
|
|
35
|
+
- Prefer `timestamptz` for event time and `numeric(p,s)` for money.
|
|
36
|
+
- Prefer `text` plus optional `check (length(col) <= n)` over arbitrary
|
|
37
|
+
`varchar(n)`.
|
|
38
|
+
- Use `jsonb` for optional or semi-structured attributes, not for relations
|
|
39
|
+
that need joins, constraints, or frequent filtering.
|
|
40
|
+
- Validate important queries with `explain (analyze, buffers)` before adding
|
|
41
|
+
indexes or denormalized columns.
|
|
42
|
+
|
|
43
|
+
## Quick Reference
|
|
44
|
+
|
|
45
|
+
### Index Cheat Sheet
|
|
46
|
+
|
|
47
|
+
| Query Pattern | Index Type | Example |
|
|
48
|
+
|--------------|------------|---------|
|
|
49
|
+
| `WHERE col = value` | B-tree (default) | `CREATE INDEX idx ON t (col)` |
|
|
50
|
+
| `WHERE col > value` | B-tree | `CREATE INDEX idx ON t (col)` |
|
|
51
|
+
| `WHERE a = x AND b > y` | Composite | `CREATE INDEX idx ON t (a, b)` |
|
|
52
|
+
| `WHERE jsonb @> '{}'` | GIN | `CREATE INDEX idx ON t USING gin (col)` |
|
|
53
|
+
| `WHERE tsv @@ query` | GIN | `CREATE INDEX idx ON t USING gin (col)` |
|
|
54
|
+
| Time-series ranges | BRIN | `CREATE INDEX idx ON t USING brin (col)` |
|
|
55
|
+
|
|
56
|
+
### Data Type Quick Reference
|
|
57
|
+
|
|
58
|
+
| Use Case | Correct Type | Avoid |
|
|
59
|
+
|----------|-------------|-------|
|
|
60
|
+
| IDs | `bigint` | `int`, random UUID |
|
|
61
|
+
| Strings | `text` | `varchar(255)` |
|
|
62
|
+
| Timestamps | `timestamptz` | `timestamp` |
|
|
63
|
+
| Money | `numeric(10,2)` | `float` |
|
|
64
|
+
| Flags | `boolean` | `varchar`, `int` |
|
|
65
|
+
|
|
66
|
+
### Common Patterns
|
|
67
|
+
|
|
68
|
+
**Composite Index Order:**
|
|
69
|
+
```sql
|
|
70
|
+
-- Equality columns first, then range columns
|
|
71
|
+
CREATE INDEX idx ON orders (status, created_at);
|
|
72
|
+
-- Works for: WHERE status = 'pending' AND created_at > '2024-01-01'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Covering Index:**
|
|
76
|
+
```sql
|
|
77
|
+
CREATE INDEX idx ON users (email) INCLUDE (name, created_at);
|
|
78
|
+
-- Avoids table lookup for SELECT email, name, created_at
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Partial Index:**
|
|
82
|
+
```sql
|
|
83
|
+
CREATE INDEX idx ON users (email) WHERE deleted_at IS NULL;
|
|
84
|
+
-- Smaller index, only includes active users
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
**RLS Policy (Optimized):**
|
|
88
|
+
```sql
|
|
89
|
+
CREATE POLICY policy ON orders
|
|
90
|
+
USING ((SELECT auth.uid()) = user_id); -- Wrap in SELECT!
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**UPSERT:**
|
|
94
|
+
```sql
|
|
95
|
+
INSERT INTO settings (user_id, key, value)
|
|
96
|
+
VALUES (123, 'theme', 'dark')
|
|
97
|
+
ON CONFLICT (user_id, key)
|
|
98
|
+
DO UPDATE SET value = EXCLUDED.value;
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Cursor Pagination:**
|
|
102
|
+
```sql
|
|
103
|
+
SELECT * FROM products WHERE id > $last_id ORDER BY id LIMIT 20;
|
|
104
|
+
-- O(1) vs OFFSET which is O(n)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Queue Processing:**
|
|
108
|
+
```sql
|
|
109
|
+
UPDATE jobs SET status = 'processing'
|
|
110
|
+
WHERE id = (
|
|
111
|
+
SELECT id FROM jobs WHERE status = 'pending'
|
|
112
|
+
ORDER BY created_at LIMIT 1
|
|
113
|
+
FOR UPDATE SKIP LOCKED
|
|
114
|
+
) RETURNING *;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### Anti-Pattern Detection
|
|
118
|
+
|
|
119
|
+
```sql
|
|
120
|
+
-- Find unindexed foreign keys
|
|
121
|
+
SELECT conrelid::regclass, a.attname
|
|
122
|
+
FROM pg_constraint c
|
|
123
|
+
JOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = ANY(c.conkey)
|
|
124
|
+
WHERE c.contype = 'f'
|
|
125
|
+
AND NOT EXISTS (
|
|
126
|
+
SELECT 1 FROM pg_index i
|
|
127
|
+
WHERE i.indrelid = c.conrelid AND a.attnum = ANY(i.indkey)
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
-- Find slow queries
|
|
131
|
+
SELECT query, mean_exec_time, calls
|
|
132
|
+
FROM pg_stat_statements
|
|
133
|
+
WHERE mean_exec_time > 100
|
|
134
|
+
ORDER BY mean_exec_time DESC;
|
|
135
|
+
|
|
136
|
+
-- Check table bloat
|
|
137
|
+
SELECT relname, n_dead_tup, last_vacuum
|
|
138
|
+
FROM pg_stat_user_tables
|
|
139
|
+
WHERE n_dead_tup > 1000
|
|
140
|
+
ORDER BY n_dead_tup DESC;
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Configuration Template
|
|
144
|
+
|
|
145
|
+
```sql
|
|
146
|
+
-- Connection limits (adjust for RAM)
|
|
147
|
+
ALTER SYSTEM SET max_connections = 100;
|
|
148
|
+
ALTER SYSTEM SET work_mem = '8MB';
|
|
149
|
+
|
|
150
|
+
-- Timeouts
|
|
151
|
+
ALTER SYSTEM SET idle_in_transaction_session_timeout = '30s';
|
|
152
|
+
ALTER SYSTEM SET statement_timeout = '30s';
|
|
153
|
+
|
|
154
|
+
-- Monitoring
|
|
155
|
+
CREATE EXTENSION IF NOT EXISTS pg_stat_statements;
|
|
156
|
+
|
|
157
|
+
-- Security defaults
|
|
158
|
+
REVOKE ALL ON SCHEMA public FROM public;
|
|
159
|
+
|
|
160
|
+
SELECT pg_reload_conf();
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Related
|
|
164
|
+
|
|
165
|
+
- Agent: `database-reviewer` - Full database review workflow
|
|
166
|
+
- Skill: `backend-patterns` - API and backend patterns
|
|
167
|
+
- Skill: `database-migrations` - Safe schema changes
|
|
168
|
+
|
|
169
|
+
## When to Use This Skill
|
|
170
|
+
|
|
171
|
+
- Writing SQL queries
|
|
172
|
+
- Designing database schemas
|
|
173
|
+
- Optimizing query performance
|
|
174
|
+
- Implementing Row Level Security
|
|
175
|
+
- Troubleshooting database issues
|
|
176
|
+
- Setting up PostgreSQL configuration
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
*Based on Supabase Agent Skills (credit: Supabase team) (MIT License)*
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Affaan Mustafa
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|