@carllee1983/dbcli 1.5.2 → 1.7.0
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/CHANGELOG.md +28 -0
- package/README.dev.md +51 -54
- package/README.md +85 -17
- package/README.zh-TW.md +79 -15
- package/assets/SKILL.md +95 -500
- package/assets/reference.md +510 -0
- package/assets/snippets/.keep +0 -0
- package/assets/snippets/README.md +18 -0
- package/assets/snippets/diag/cache-hit.mysql.sql +19 -0
- package/assets/snippets/diag/cache-hit.postgres.sql +18 -0
- package/assets/snippets/diag/connections.mysql.sql +16 -0
- package/assets/snippets/diag/connections.postgres.sql +16 -0
- package/assets/snippets/diag/db-size.mysql.sql +10 -0
- package/assets/snippets/diag/db-size.postgres.sql +9 -0
- package/assets/snippets/diag/index-usage.mysql.sql +15 -0
- package/assets/snippets/diag/index-usage.postgres.sql +14 -0
- package/assets/snippets/diag/locks.mysql.sql +14 -0
- package/assets/snippets/diag/locks.postgres.sql +15 -0
- package/assets/snippets/diag/long-running.mysql.sql +14 -0
- package/assets/snippets/diag/long-running.postgres.sql +19 -0
- package/assets/snippets/diag/missing-indexes.mysql.sql +13 -0
- package/assets/snippets/diag/missing-indexes.postgres.sql +15 -0
- package/assets/snippets/diag/table-sizes.mysql.sql +14 -0
- package/assets/snippets/diag/table-sizes.postgres.sql +13 -0
- package/dist/cli.mjs +2591 -514
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,34 @@ All notable changes to dbcli are documented here.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [1.7.0] - 2026-05-04
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- `dbcli q @<name>` 執行已保存的參數化 SELECT 片段
|
|
13
|
+
- `dbcli queries list/show/new/edit/check` 管理片段
|
|
14
|
+
- 兩層片段儲存:`.dbcli-shared/queries/`(共享)+ `.dbcli/queries/`(個人覆蓋)
|
|
15
|
+
- 完整安全 invariants:拒絕非 SELECT/WITH、多語句、`${...}` / `{{...}}` 模板語法
|
|
16
|
+
- 子查詢式 size guard 包裹 (`SELECT * FROM (...) AS _dbcli_guard LIMIT 1000`)
|
|
17
|
+
- 內建 YAML 子集 frontmatter parser(無新增 npm 依賴)
|
|
18
|
+
- `queries list/show --format json` 為未來 MCP server 預留契約
|
|
19
|
+
|
|
20
|
+
## [1.6.0] - 2026-04-23
|
|
21
|
+
|
|
22
|
+
### Added
|
|
23
|
+
|
|
24
|
+
- **Full MongoDB Support**: Extended all core operations to support MongoDB.
|
|
25
|
+
- Data operations: `query`, `insert`, `update`, `delete`.
|
|
26
|
+
- Safeguards: Integrated `blacklist` protection and `query-size-guard` for MongoDB commands.
|
|
27
|
+
- Discovery: Implemented schema inspection for MongoDB collections.
|
|
28
|
+
- Diagnostics: Added comprehensive MongoDB environment and connection diagnostics to `dbcli doctor`.
|
|
29
|
+
- **Improved AI Skill Installation**: `dbcli skill --install` now deploys both `SKILL.md` (high-level workflow) and `reference.md` (full command syntax and examples) to target platforms (Claude Code, Gemini CLI, Copilot, Cursor).
|
|
30
|
+
- **Security model enhancement**: `dbcli init` now defaults to a more secure storage model, placing sensitive connection details in `~/.config/dbcli/` rather than the local project workspace.
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- **Documentation Refactor**: Updated and synchronized documentation (README, README.zh-TW, SKILL.md) to reflect full MongoDB capabilities and first-step walkthroughs.
|
|
35
|
+
|
|
8
36
|
## [1.5.2] - 2026-04-22
|
|
9
37
|
|
|
10
38
|
### Fixed
|
package/README.dev.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Development Guide
|
|
2
2
|
|
|
3
|
+
Scoped package: **`@carllee1983/dbcli`**. All `npm` / `npx` examples below use this name.
|
|
4
|
+
|
|
3
5
|
## npm Publishing Process
|
|
4
6
|
|
|
5
7
|
### Pre-Publication Checklist
|
|
@@ -9,115 +11,110 @@ Before running `npm publish`:
|
|
|
9
11
|
1. **Verify build is clean:**
|
|
10
12
|
```bash
|
|
11
13
|
bun run build
|
|
12
|
-
ls -lh dist/cli.mjs
|
|
14
|
+
ls -lh dist/cli.mjs # expect a few MB (bundled CLI + dependencies)
|
|
13
15
|
```
|
|
14
16
|
|
|
15
|
-
2. **Verify
|
|
17
|
+
2. **Verify tests pass (pick one):**
|
|
16
18
|
```bash
|
|
17
|
-
|
|
19
|
+
# Fast path: unit + core only (matches CI-style smoke)
|
|
20
|
+
bun run test:unit
|
|
21
|
+
|
|
22
|
+
# Full suite (Bun test runner)
|
|
23
|
+
bun test
|
|
18
24
|
```
|
|
19
25
|
|
|
20
|
-
For live database integration tests,
|
|
26
|
+
For live database integration tests, set an explicit config if needed:
|
|
21
27
|
```bash
|
|
22
28
|
LIVE_DB_CONFIG_PATH=/path/to/.dbcli bun test tests/integration/live-db.test.ts
|
|
23
29
|
```
|
|
24
30
|
|
|
25
31
|
If no live config is available, `tests/integration/live-db.test.ts` skips
|
|
26
|
-
instead of falling back to the default PostgreSQL configuration.
|
|
32
|
+
instead of falling back to the default PostgreSQL configuration. Use
|
|
33
|
+
`SKIP_INTEGRATION_TESTS=true` to skip integration tests when running a broad `bun test`.
|
|
27
34
|
|
|
28
35
|
3. **Update version in package.json:**
|
|
29
36
|
```bash
|
|
30
|
-
npm version minor
|
|
31
|
-
# OR
|
|
37
|
+
npm version minor # bumps version + creates git tag (in this repo)
|
|
38
|
+
# OR edit the "version" field in package.json by hand
|
|
32
39
|
```
|
|
33
40
|
|
|
34
41
|
4. **Verify package contents (dry run):**
|
|
35
42
|
```bash
|
|
36
43
|
npm pack --dry-run
|
|
37
|
-
# Should list only: dist/*, README.md, CHANGELOG.md, package.json
|
|
38
44
|
```
|
|
45
|
+
Expect **`dist/`** (at least `cli.mjs`), **`assets/`** (e.g. `SKILL.md`, `reference.md` for `dbcli skill`), **`README.md`**, **`CHANGELOG.md`**, **`LICENSE`**, and **`package.json`**. There must be **no** `src/`, `tests/`, or `node_modules/`. The listing may also include other root `README*.md` files (npm can still pack them even when `files` is set); dev-only readmes are listed in **`.npmignore`** — re-check with dry-run if you add or remove docs.
|
|
39
46
|
|
|
40
47
|
5. **Check package size:**
|
|
41
48
|
```bash
|
|
42
49
|
npm pack
|
|
43
|
-
ls -lh dbcli-*.tgz
|
|
44
|
-
rm dbcli-*.tgz
|
|
50
|
+
ls -lh carllee1983-dbcli-*.tgz # compressed tarball (typically well under 5MB)
|
|
51
|
+
rm carllee1983-dbcli-*.tgz # cleanup
|
|
45
52
|
```
|
|
46
53
|
|
|
47
54
|
### Publication
|
|
48
55
|
|
|
49
|
-
|
|
56
|
+
Publication uses the `prepublishOnly` script in `package.json`:
|
|
50
57
|
|
|
51
58
|
```bash
|
|
52
59
|
npm publish
|
|
53
60
|
```
|
|
54
61
|
|
|
55
|
-
|
|
56
|
-
1. `prepublishOnly` hook: Runs `bun run build` → ensures fresh dist/cli.mjs
|
|
57
|
-
2. npm creates tarball with `files` whitelist → only intended files included
|
|
58
|
-
3. npm applies `.npmignore` rules → additional safety layer
|
|
59
|
-
4. npm publishes to registry
|
|
62
|
+
What runs (conceptually):
|
|
60
63
|
|
|
61
|
-
|
|
64
|
+
1. **`prepublishOnly`:** `bun run build` — rebuilds `dist/cli.mjs` from `src/cli.ts` via `scripts/build.ts`.
|
|
65
|
+
2. **Tarball** — paths from the **`files`** field in `package.json`, further filtered by **`.npmignore`**. (Some npm versions also merge in extra root `README*` files; use dry-run to see exactly what will ship.)
|
|
66
|
+
3. **Registry** — with `"publishConfig": { "access": "public" }`, the scoped package is published as **public**.
|
|
67
|
+
|
|
68
|
+
A failed `bun run build` will fail the publish, so you should not ship a stale `dist/` from a previous local build.
|
|
62
69
|
|
|
63
70
|
### Verification (Post-Publication)
|
|
64
71
|
|
|
65
72
|
After publishing:
|
|
66
73
|
|
|
67
|
-
1. **
|
|
74
|
+
1. **Global install:**
|
|
68
75
|
```bash
|
|
69
|
-
npm install -g dbcli
|
|
70
|
-
which dbcli
|
|
76
|
+
npm install -g @carllee1983/dbcli
|
|
77
|
+
which dbcli
|
|
71
78
|
dbcli --version
|
|
72
79
|
```
|
|
73
80
|
|
|
74
|
-
2. **
|
|
81
|
+
2. **Zero-install (npx / bunx):**
|
|
75
82
|
```bash
|
|
76
|
-
cd /tmp
|
|
77
|
-
|
|
78
|
-
npx dbcli --
|
|
79
|
-
|
|
83
|
+
cd /tmp && mkdir -p test-dbcli && cd test-dbcli
|
|
84
|
+
npx @carllee1983/dbcli --help
|
|
85
|
+
npx @carllee1983/dbcli --version
|
|
86
|
+
# or: bunx @carllee1983/dbcli --help
|
|
80
87
|
```
|
|
81
88
|
|
|
82
|
-
3. **
|
|
83
|
-
- On Windows machine: `npm install -g dbcli`
|
|
84
|
-
- Verify: `dbcli --help` and `dbcli --version` work
|
|
85
|
-
- npm creates .cmd wrapper automatically; no manual .cmd needed
|
|
89
|
+
3. **Windows (if available):** `npm install -g @carllee1983/dbcli`, then `dbcli --help`. npm creates the `.cmd` stub for the `bin` entry; no hand-written `.cmd` in the repo.
|
|
86
90
|
|
|
87
91
|
### Rollback (if needed)
|
|
88
92
|
|
|
89
|
-
If
|
|
93
|
+
If a bad release must be mitigated:
|
|
90
94
|
|
|
91
95
|
```bash
|
|
92
|
-
npm unpublish dbcli
|
|
93
|
-
#
|
|
94
|
-
npm deprecate dbcli
|
|
96
|
+
npm unpublish @carllee1983/dbcli@<VERSION>
|
|
97
|
+
# and/or
|
|
98
|
+
npm deprecate @carllee1983/dbcli@<VERSION> "Reason; use <SAFE_VERSION> instead"
|
|
95
99
|
```
|
|
96
100
|
|
|
97
|
-
Then
|
|
101
|
+
Then ship a patch version with the fix. Prefer **deprecate** over **unpublish** when consumers may already depend on the version.
|
|
98
102
|
|
|
99
103
|
### Configuration Details
|
|
100
104
|
|
|
101
|
-
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
- **
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
- npm warns if consumer's environment is too old
|
|
109
|
-
- **Cross-platform support:** Shebang `#!/usr/bin/env bun` works on all platforms
|
|
110
|
-
- macOS/Linux: Direct shebang execution
|
|
111
|
-
- Windows: npm creates .cmd wrapper automatically (no manual creation needed)
|
|
112
|
-
- **Live integration tests:** `tests/integration/live-db.test.ts` reads `.dbcli/config.json`
|
|
113
|
-
by default or `LIVE_DB_CONFIG_PATH` when you need to point at another config
|
|
114
|
-
directory. Set `SKIP_INTEGRATION_TESTS=true` to skip all integration tests.
|
|
105
|
+
- **`files` (in `package.json`):** Publishes `dist/`, `assets/`, `README.md`, `CHANGELOG.md`, `LICENSE`. The `assets/` tree is required for `dbcli skill` to copy bundled `SKILL.md` / `reference.md` from the installed package.
|
|
106
|
+
- **`prepublishOnly`:** `bun run build` so `dist/cli.mjs` matches current source.
|
|
107
|
+
- **`engines`:** Declares `node >= 18.0.0` and `bun >= 1.3.3` so npm can warn on outdated runtimes.
|
|
108
|
+
- **Shebang:** `scripts/build.ts` prepends `#!/usr/bin/env bun` to `dist/cli.mjs`; the `bin` field in `package.json` points at that file.
|
|
109
|
+
- **Live DB tests:** `tests/integration/live-db.test.ts` uses project `.dbcli` by default or `LIVE_DB_CONFIG_PATH` when you point at another config directory. Set `SKIP_INTEGRATION_TESTS=true` to skip all integration tests.
|
|
110
|
+
|
|
111
|
+
For contributor workflow and release process, see **[CONTRIBUTING.md](./CONTRIBUTING.md)** and the main **[README.md](./README.md)** Development section.
|
|
115
112
|
|
|
116
113
|
### Troubleshooting
|
|
117
114
|
|
|
118
|
-
| Issue |
|
|
119
|
-
|
|
120
|
-
| prepublishOnly
|
|
121
|
-
|
|
|
122
|
-
| Windows
|
|
123
|
-
| npx
|
|
115
|
+
| Issue | What to do |
|
|
116
|
+
|-------|------------|
|
|
117
|
+
| `prepublishOnly` / build fails | Fix TypeScript or build errors, run `bun run test:unit`, then `bun run build` again. |
|
|
118
|
+
| Tarball unexpectedly large or bloated | Inspect the bundle: e.g. `bun build ./src/cli.ts --outfile=dist/cli.mjs --target=bun --metafile=meta.json` and review the metafile; trim dependencies or dev-only code paths. |
|
|
119
|
+
| Windows: `dbcli` not found after global install | Confirm PATH includes npm’s global `bin`; reinstall `npm i -g @carllee1983/dbcli`. |
|
|
120
|
+
| `npx` download slow or cache weird | `npm cache clean --force` and retry `npx @carllee1983/dbcli --version`. |
|
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ A unified database CLI tool that enables AI agents (Claude Code, Gemini, Copilot
|
|
|
6
6
|
|
|
7
7
|
**Core Value:** AI agents can safely and intelligently access project databases through a single, permission-controlled CLI tool with sensitive data protection.
|
|
8
8
|
|
|
9
|
+
> **Security update:** `dbcli init` now writes only a small project binding stub into `./.dbcli/config.json`. The full connection configuration is stored under `~/.config/dbcli/projects/<project-id>/config.json`, so sensitive settings do not live inside the project workspace by default.
|
|
10
|
+
|
|
9
11
|
## Internationalization (i18n)
|
|
10
12
|
|
|
11
13
|
dbcli supports multiple languages via the `DBCLI_LANG` environment variable:
|
|
@@ -76,6 +78,9 @@ When `dbcli` is not on your `PATH`, use `bun run src/cli.ts <subcommand> ...` (s
|
|
|
76
78
|
# Initialize project with database connection
|
|
77
79
|
dbcli init
|
|
78
80
|
|
|
81
|
+
# Interactive shell (SQL + dbcli commands, tab completion)
|
|
82
|
+
dbcli shell
|
|
83
|
+
|
|
79
84
|
# List available tables
|
|
80
85
|
dbcli list
|
|
81
86
|
|
|
@@ -85,6 +90,9 @@ dbcli schema users
|
|
|
85
90
|
# Query data
|
|
86
91
|
dbcli query "SELECT * FROM users"
|
|
87
92
|
|
|
93
|
+
# Preview schema DDL (dry-run by default; add --execute to apply)
|
|
94
|
+
dbcli migrate create posts --column "id:serial:pk" --column "title:varchar(200):not-null"
|
|
95
|
+
|
|
88
96
|
# Generate AI agent skill
|
|
89
97
|
dbcli skill --install claude
|
|
90
98
|
```
|
|
@@ -106,12 +114,16 @@ dbcli query '{"status":"active"}' --collection users --use atlas
|
|
|
106
114
|
|
|
107
115
|
For MongoDB, `list` and `query` operate on the database configured for the connection, and `query` requires `--collection <name>`.
|
|
108
116
|
|
|
117
|
+
For a command-by-command support matrix across PostgreSQL, MySQL, MariaDB, and MongoDB, see [docs/feature-matrix.md](./docs/feature-matrix.md).
|
|
118
|
+
|
|
109
119
|
---
|
|
110
120
|
|
|
111
121
|
## Multi-connection Support (v2)
|
|
112
122
|
|
|
113
123
|
dbcli supports multiple named database connections within a single project. This is useful for managing different environments (development, staging, production) or multiple databases.
|
|
114
124
|
|
|
125
|
+
The project `.dbcli` directory now acts as a binding + cache layer. The actual connection config is stored in `~/.config/dbcli/projects/<project-id>/`, which keeps sensitive settings out of the workspace by default.
|
|
126
|
+
|
|
115
127
|
### Initializing Named Connections
|
|
116
128
|
|
|
117
129
|
To create a named connection, use the `--conn-name` option during `init`. You can also specify a custom `.env` file for that connection.
|
|
@@ -170,13 +182,14 @@ dbcli init [OPTIONS]
|
|
|
170
182
|
```
|
|
171
183
|
|
|
172
184
|
**Options (Basic):**
|
|
173
|
-
- `--system <type>` — Database system: `postgresql`, `mysql`, `mariadb`
|
|
185
|
+
- `--system <type>` — Database system: `postgresql`, `mysql`, `mariadb`, `mongodb`
|
|
174
186
|
- `--host <host>` — Database host
|
|
175
187
|
- `--port <port>` — Database port
|
|
176
188
|
- `--user <user>` — Database user
|
|
177
189
|
- `--password <pass>` — Database password
|
|
178
190
|
- `--name <db>` — Database name
|
|
179
191
|
- `--permission <level>` — Permission level: `query-only`, `read-write`, `data-admin`, `admin`
|
|
192
|
+
- **MongoDB only:** `--uri <uri>` — full connection URI (`mongodb://…` or `mongodb+srv://…`); `--auth-source <db>` — auth database (default `admin` when using user/password)
|
|
180
193
|
- `--use-env-refs` — Store environment variable references instead of actual values in config
|
|
181
194
|
- `--skip-test` — Skip connection test
|
|
182
195
|
- `--no-interactive` — Non-interactive mode (requires all options)
|
|
@@ -191,7 +204,7 @@ dbcli init [OPTIONS]
|
|
|
191
204
|
**Behavior:**
|
|
192
205
|
- Reads `.env` file if present (auto-fills DATABASE_URL, DB_* variables)
|
|
193
206
|
- Prompts for missing values (host, port, user, password, database name, permission level)
|
|
194
|
-
- Creates `.dbcli`
|
|
207
|
+
- Creates a project binding stub in `.dbcli/config.json` and stores the full config under `~/.config/dbcli/projects/<project-id>/`
|
|
195
208
|
- Tests database connection before saving
|
|
196
209
|
|
|
197
210
|
**Examples:**
|
|
@@ -241,6 +254,8 @@ dbcli use --list
|
|
|
241
254
|
|
|
242
255
|
> **`--use-env-refs`:** When enabled, the config stores environment variable names (e.g., `{"$env": "DB_HOST"}`) instead of actual values. This avoids writing sensitive credentials into the config file, making it suitable for multi-environment deployments and CI/CD pipelines. At connection time, dbcli automatically reads the actual values from the referenced environment variables.
|
|
243
256
|
|
|
257
|
+
> **Storage model:** The project `.dbcli` directory is now a binding + cache layer, not the canonical home for secrets. If you inspect `./.dbcli/config.json`, you should only see the binding metadata; the full config lives in the home storage path shown above.
|
|
258
|
+
|
|
244
259
|
---
|
|
245
260
|
|
|
246
261
|
#### `dbcli list`
|
|
@@ -489,8 +504,8 @@ dbcli skill --install cursor # Install to Cursor IDE
|
|
|
489
504
|
```
|
|
490
505
|
|
|
491
506
|
**Behavior:**
|
|
492
|
-
- Ships
|
|
493
|
-
- Prints
|
|
507
|
+
- Ships canonical **`assets/SKILL.md`** + **`assets/reference.md`** (single source of truth: concise skill + long command reference)
|
|
508
|
+
- Prints the skill to **stdout**, writes it with **`--output`**, or copies it to a **platform-specific path** with **`--install`**
|
|
494
509
|
- Actual database access is still enforced by your `.dbcli` permission level and blacklist — the skill text describes the full CLI surface
|
|
495
510
|
|
|
496
511
|
**Examples:**
|
|
@@ -592,12 +607,8 @@ dbcli check users
|
|
|
592
607
|
dbcli check orders --checks nulls,orphans --format table
|
|
593
608
|
# Scan all tables
|
|
594
609
|
dbcli check --all
|
|
595
|
-
```
|
|
596
610
|
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
**Examples:**
|
|
600
|
-
```bash
|
|
611
|
+
# Table view + all-tables with selected checks
|
|
601
612
|
dbcli check orders --format table
|
|
602
613
|
dbcli check --all --checks nulls,duplicates --format json
|
|
603
614
|
```
|
|
@@ -690,7 +701,7 @@ dbcli upgrade --check # Only check, do not upgrade
|
|
|
690
701
|
|
|
691
702
|
**Background checks (stderr, skipped when `--quiet` or for `upgrade` / `skill`):**
|
|
692
703
|
- **CLI version:** dbcli checks the npm registry (cached, about once per 24 hours). If a newer package exists, a one-line hint prints after normal command output.
|
|
693
|
-
- **Installed skills:** If you used `dbcli skill --install <platform>`, dbcli compares each installed
|
|
704
|
+
- **Installed skills:** If you used `dbcli skill --install <platform>`, dbcli compares each installed primary skill file (`SKILL.md` or `dbcli.mdc`) to the bundled `assets/SKILL.md`. When they differ, a short reminder lists which platforms to re-install (`dbcli skill --install <platform>`). Run `dbcli upgrade` to see the same skill status together with version info. Re-installing also refreshes `reference.md` next to the skill.
|
|
694
705
|
|
|
695
706
|
#### `dbcli shell`
|
|
696
707
|
|
|
@@ -760,6 +771,43 @@ dbcli migrate drop-enum status --execute --force
|
|
|
760
771
|
|
|
761
772
|
---
|
|
762
773
|
|
|
774
|
+
## Query Risk Planning
|
|
775
|
+
|
|
776
|
+
Use `plan` to inspect SQL safety before execution. It reads local dbcli config, permissions, blacklist rules, and cached schema metadata only; it does not connect to the database.
|
|
777
|
+
|
|
778
|
+
```bash
|
|
779
|
+
dbcli plan "UPDATE users SET status='inactive'" --format json
|
|
780
|
+
```
|
|
781
|
+
|
|
782
|
+
Decisions are:
|
|
783
|
+
|
|
784
|
+
- `ALLOW` — no obvious risk was detected.
|
|
785
|
+
- `WARN` — inspect warnings before executing.
|
|
786
|
+
- `BLOCK` — unsafe, unsupported, or violates configured safety constraints.
|
|
787
|
+
|
|
788
|
+
Text output is concise for humans:
|
|
789
|
+
|
|
790
|
+
```text
|
|
791
|
+
Decision: BLOCK
|
|
792
|
+
Operation: UPDATE
|
|
793
|
+
Target tables: users
|
|
794
|
+
|
|
795
|
+
Risk factors:
|
|
796
|
+
- UPDATE statement has no WHERE clause.
|
|
797
|
+
|
|
798
|
+
Recommendations:
|
|
799
|
+
- Add a WHERE clause.
|
|
800
|
+
- Use --dry-run on the actual write command.
|
|
801
|
+
```
|
|
802
|
+
|
|
803
|
+
JSON output includes `suggestedCommands` for agents:
|
|
804
|
+
|
|
805
|
+
```bash
|
|
806
|
+
dbcli plan "SELECT id FROM users WHERE id = 1 LIMIT 1" --format json
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
---
|
|
810
|
+
|
|
763
811
|
## Global Options
|
|
764
812
|
|
|
765
813
|
All commands support these global options:
|
|
@@ -948,9 +996,25 @@ A Query-only agent cannot write to any table, and also cannot read blacklisted t
|
|
|
948
996
|
|
|
949
997
|
---
|
|
950
998
|
|
|
999
|
+
## Saved queries
|
|
1000
|
+
|
|
1001
|
+
Save parameterised SELECT snippets and re-run them by name:
|
|
1002
|
+
|
|
1003
|
+
```bash
|
|
1004
|
+
dbcli queries list
|
|
1005
|
+
dbcli queries show @dau
|
|
1006
|
+
dbcli q @dau --param days=30 --format json
|
|
1007
|
+
```
|
|
1008
|
+
|
|
1009
|
+
Snippets live in `.dbcli-shared/queries/` (committed) or `.dbcli/queries/`
|
|
1010
|
+
(gitignored, personal override). Each `.sql` file declares its frontmatter
|
|
1011
|
+
in a `-- ---` block. Read `assets/reference.md` for the full schema.
|
|
1012
|
+
|
|
1013
|
+
---
|
|
1014
|
+
|
|
951
1015
|
## AI Integration Guide
|
|
952
1016
|
|
|
953
|
-
dbcli ships AI-consumable skill
|
|
1017
|
+
dbcli ships AI-consumable skill files (`assets/SKILL.md` and `assets/reference.md`) and can copy them into your favorite AI tool directories.
|
|
954
1018
|
|
|
955
1019
|
### Quick Start
|
|
956
1020
|
|
|
@@ -982,7 +1046,7 @@ After installation, the AI agent will have access to dbcli commands and can use
|
|
|
982
1046
|
4. Restart Claude Code extension
|
|
983
1047
|
5. In Claude Code chat, ask: "Show me the database schema" or "Query active users"
|
|
984
1048
|
|
|
985
|
-
**Skill location:** `~/.claude/skills/dbcli
|
|
1049
|
+
**Skill location:** `~/.claude/skills/dbcli/` (SKILL.md + reference.md)
|
|
986
1050
|
|
|
987
1051
|
---
|
|
988
1052
|
|
|
@@ -994,7 +1058,7 @@ After installation, the AI agent will have access to dbcli commands and can use
|
|
|
994
1058
|
4. Start Gemini: `gemini start`
|
|
995
1059
|
5. In chat, request: "Query the users table" or "Show database tables"
|
|
996
1060
|
|
|
997
|
-
**Skill location:** `~/.gemini/skills/dbcli
|
|
1061
|
+
**Skill location:** `~/.gemini/skills/dbcli/` (SKILL.md + reference.md)
|
|
998
1062
|
|
|
999
1063
|
---
|
|
1000
1064
|
|
|
@@ -1006,7 +1070,7 @@ After installation, the AI agent will have access to dbcli commands and can use
|
|
|
1006
1070
|
4. Install Copilot CLI: `npm install -g @github-next/github-copilot-cli`
|
|
1007
1071
|
5. Use copilot preview: `copilot --help` and explore dbcli integration
|
|
1008
1072
|
|
|
1009
|
-
**Skill location:** `.github/skills/dbcli
|
|
1073
|
+
**Skill location:** `.github/skills/dbcli/` (SKILL.md + reference.md) when you run `dbcli skill --install copilot` in your project root.
|
|
1010
1074
|
|
|
1011
1075
|
---
|
|
1012
1076
|
|
|
@@ -1018,7 +1082,7 @@ After installation, the AI agent will have access to dbcli commands and can use
|
|
|
1018
1082
|
4. Open Cursor editor
|
|
1019
1083
|
5. Use Cursor's Composer: "Insert a new user" or "Export user data"
|
|
1020
1084
|
|
|
1021
|
-
**Skill location:** `.cursor/rules/dbcli.mdc` under the **current working directory** when you run `dbcli skill --install cursor
|
|
1085
|
+
**Skill location:** `.cursor/rules/dbcli.mdc` (summary + workflows) and `.cursor/skills/dbcli/reference.md` (full command flags and examples) under the **current working directory** when you run `dbcli skill --install cursor`.
|
|
1022
1086
|
|
|
1023
1087
|
---
|
|
1024
1088
|
|
|
@@ -1045,7 +1109,7 @@ dbcli skill --install claude
|
|
|
1045
1109
|
|
|
1046
1110
|
### Updating the skill after upgrades
|
|
1047
1111
|
|
|
1048
|
-
|
|
1112
|
+
`dbcli skill` copies the bundled **`assets/SKILL.md`** (and for `--install`, **`assets/reference.md`** next to it). It is **not** regenerated from your live config. When you **upgrade dbcli** or the bundled skill changes, re-copy it to each platform you use:
|
|
1049
1113
|
|
|
1050
1114
|
```bash
|
|
1051
1115
|
dbcli skill --install claude
|
|
@@ -1053,7 +1117,7 @@ dbcli skill --install gemini
|
|
|
1053
1117
|
# ... etc.
|
|
1054
1118
|
```
|
|
1055
1119
|
|
|
1056
|
-
If an installed
|
|
1120
|
+
If an installed primary skill file is older than the bundled `assets/SKILL.md`, dbcli prints a **stderr reminder** after most commands (see **`dbcli upgrade`**). Changing **permission level** or **blacklist** in `.dbcli` affects what the CLI allows at runtime — keep project context (e.g. `dbcli status`, `dbcli blacklist list`) in mind for agents even though the skill text lists the full command set.
|
|
1057
1121
|
|
|
1058
1122
|
---
|
|
1059
1123
|
|
|
@@ -1230,6 +1294,7 @@ chmod +x dist/cli.mjs
|
|
|
1230
1294
|
- **PostgreSQL:** 12.0+
|
|
1231
1295
|
- **MySQL:** 8.0+
|
|
1232
1296
|
- **MariaDB:** 10.5+
|
|
1297
|
+
- **MongoDB:** 4.4+ (query and collection listing via `mongodb://` and `mongodb+srv://`; see **MongoDB Atlas / SRV Connections** earlier in this document)
|
|
1233
1298
|
|
|
1234
1299
|
### Runtime
|
|
1235
1300
|
|
|
@@ -1248,12 +1313,15 @@ chmod +x dist/cli.mjs
|
|
|
1248
1313
|
|
|
1249
1314
|
```bash
|
|
1250
1315
|
bun test # full test suite (Bun test runner)
|
|
1316
|
+
bun run typecheck # TypeScript compile-time validation
|
|
1251
1317
|
bun run test:unit # unit + core tests only
|
|
1252
1318
|
bun run test:integration # integration tests
|
|
1253
1319
|
bun run test:docker # integration tests with docker-compose.test.yml (MySQL + PostgreSQL)
|
|
1254
1320
|
bun run build # bundle CLI to dist/ (used before publish)
|
|
1255
1321
|
```
|
|
1256
1322
|
|
|
1323
|
+
CI treats `bun run typecheck` and `bun test` as the required pass/fail validation gate on every push and pull request. Lint, build, smoke checks, and benchmarks run in addition to that gate.
|
|
1324
|
+
|
|
1257
1325
|
Live database integration tests use `.dbcli/config.json` by default. If your live
|
|
1258
1326
|
config lives elsewhere, set `LIVE_DB_CONFIG_PATH=/path/to/.dbcli` before running:
|
|
1259
1327
|
|