Community程式設計與開發github.com

mianhtsys/landingMod3

針對多個 Microsoft SQL Server 資料庫執行唯讀 SQL 查詢。適用時機:(1) 查詢 MSSQL/SQL Server 資料庫、(2) 探索資料庫結構/資料表、(3) 執行資料分析的 SELECT 查詢、(4) 檢查資料庫內容。支援多個資料庫連線,並提供描述以進行智慧自動選擇。為確保安全,禁止所有寫入操作(INSERT、UPDATE、DELETE、DROP 等)。

landingMod3 是什麼?

此技能讓 AI 代理可以安全地與 Microsoft SQL Server 資料庫進行互動,僅限於唯讀查詢。它為開發人員提供了一種無風險的方式來探索資料庫結構、執行資料分析查詢以及在不修改資料的情況下檢查內容。該工具支援透過「connections.json」設定檔配置多個資料庫連線,每個資料庫都有名稱和描述。AI 代理使用這些描述,根據使用者的意圖(例如「使用者」、「訂單」或「分析」)來智慧地選擇最合適的資料庫。它的主要安全功能包括嚴格只允許 SELECT、SHOW、EXPLAIN、WITH 和 SP_HELP 語句的查詢驗證、拒絕多語句查詢、強制執行 30 秒查詢逾時、將結果限制在最大 10,000 列,並對密碼等敏感憑證進行消毒處理。此技能設計用於任何可執行 Python 3.8+ 和 pymssql 命令列工具的 AI 代理平台上。

相容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mianhtsys/landingMod3/tree/HEAD/MODULO_3_DESARROLLO_AL_LADO_DEL_CLIENTE_Y_SERVIDOR_WEB/architecture-skills-framework/.agents/skills/mssql

Installed? Explore more 程式設計與開發 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

MSSQL 唯讀查詢技能

針對已設定的 Microsoft SQL Server 資料庫執行安全且唯讀的查詢。

需求

  • Python 3.8+
  • pymssql:pip install -r requirements.txt

設定

在技能目錄或 ~/.config/claude/mssql-connections.json 中建立 connections.json。

安全性:由於包含憑證,請將檔案權限設為 600:

chmod 600 connections.json
{
  "databases": [
    {
      "name": "production",
      "description": "主應用程式資料庫 - 使用者、訂單、交易",
      "host": "db.example.com",
      "port": 1433,
      "database": "app_prod",
      "user": "readonly_user",
      "password": "your-password",
      "encrypt": true,
      "tds_version": "7.3"
    }
  ]
}

設定欄位

欄位必填說明
name是資料庫的識別名稱(不區分大小寫)
description是此資料庫包含的資料內容(用於自動選擇)
host是資料庫主機名稱
port否連接埠號碼(預設值:1433)
database是資料庫名稱
user是使用者名稱
password是密碼
encrypt否啟用 TLS 加密(預設值:false)
tds_version否TDS 通訊協定版本:7.0, 7.1, 7.2, 7.3, 7.4(預設值:自動)

使用方式

列出已設定的資料庫

python3 scripts/query.py --list

查詢資料庫

python3 scripts/query.py --db production --query "SELECT TOP 10 * FROM users"

列出資料表

python3 scripts/query.py --db production --tables

顯示結構

python3 scripts/query.py --db production --schema

限制結果

python3 scripts/query.py --db production --query "SELECT * FROM orders" --limit 100

注意:MSSQL 使用 TOP N 而非 LIMIT。--limit 旗標會在 SELECT 之後自動插入 TOP N。

資料庫選擇

將使用者意圖與資料庫 description 進行比對:

使用者詢問關於尋找 description 包含
使用者、帳戶users, accounts, customers
訂單、銷售orders, transactions, sales
分析、指標analytics, metrics, reports
日誌、事件logs, events, audit

如果不清楚,請執行 --list 並詢問使用者要使用哪個資料庫。

安全功能

  • 唯讀強制執行:查詢驗證會封鎖寫入操作(請使用 db_datareader 角色使用者以獲得伺服器端保護)
  • 查詢驗證:僅允許 SELECT、SHOW、EXPLAIN、WITH、SP_HELP 查詢
  • 單一語句:拒絕每次查詢的多個語句
  • TLS 支援:可設定的加密,用於安全連線
  • 查詢逾時:透過 pymssql 強制執行 30 秒逾時
  • 連線逾時:10 秒登入逾時
  • 記憶體保護:每次查詢最多 10,000 列,以防止記憶體不足
  • 欄位寬度上限:每欄最多 100 個字元,以利輸出可讀
  • 憑證消毒:錯誤訊息不會洩漏密碼

疑難排解

錯誤解決方案
找不到設定檔在技能目錄中建立 connections.json
驗證失敗檢查設定檔中的使用者名稱/密碼
連線逾時驗證主機/連接埠,檢查防火牆/VPN
TDS 版本錯誤嘗試 "tds_version": "7.3" 或 "7.4"
加密錯誤針對 Azure SQL 設定 "encrypt": true
權限警告執行 chmod 600 connections.json

結束代碼

  • 0:成功
  • 1:錯誤(設定檔遺失、驗證失敗、無效查詢、資料庫錯誤)

工作流程

  1. 執行 --list 以顯示可用的資料庫
  2. 將使用者意圖與資料庫 description 進行比對
  3. 執行 --tables 或 --schema 以探索結構
  4. 使用適當的 --limit 執行查詢(會自動轉換為 TOP N)

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

mianhtsys/landingMod3

Implement WCAG 2.2 compliant interfaces with mobile accessibility, inclusive design patterns, and assistive technology support. Use when auditing accessibility, implementing ARIA patterns, building for screen readers, or ensuring inclusive user experiences.

mianhtsys/landingMod3

Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use when designing new APIs, reviewing API specifications, or establishing API design standards.

mianhtsys/landingMod3

Diseña y compara alternativas arquitectónicas trazables a RF/RNF sin implementar código.

mianhtsys/landingMod3

Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.

mianhtsys/landingMod3

Revisión adversarial de la arquitectura contra RF/RNF, detectando contradicciones, cobertura faltante y complejidad innecesaria.

mianhtsys/landingMod3

Master authentication and authorization patterns including JWT, OAuth2, session management, and RBAC to build secure, scalable access control systems. Use when implementing auth systems, securing APIs, or debugging security issues.

mianhtsys/landingMod3

>- Generate grounded-and-verified, engine-agnostic database documentation that reaches 100% parity with the real schema. Introspects the LIVE database as ground truth and cross-validates it against ORM models, migrations, generated types, seeds, and application queries, then proves completeness by diffing the docs back against the database. Produces ER diagrams (mermaid), per-table data dictionaries, and a machine-readable schema.json. Works with PostgreSQL, MySQL, SQL Server, and SQLite across any ORM (Prisma, TypeORM, Drizzle, Sequelize, Knex, Django, Rails) or raw SQL. Use when asked to document a database, produce an ERD or data dictionary, write db/schema docs, audit schema drift, or refresh existing DB docs.

mianhtsys/landingMod3

Compara estrategias de persistencia y motores de datos según consistencia, concurrencia, volumen, recuperación y operación.

mianhtsys/landingMod3

Design robust, scalable database schemas for SQL and NoSQL databases. Provides normalization guidelines, indexing strategies, migration patterns, constraint design, and performance optimization. Ensures data integrity, query performance, and maintainable data models.

mianhtsys/landingMod3

Consolida análisis especializados en una recomendación arquitectónica, matriz de decisión, ADR y plan de validación.

mianhtsys/landingMod3

Master error handling patterns across languages including exceptions, Result types, error propagation, and graceful degradation to build resilient applications. Use when implementing error handling, designing APIs, or improving application reliability.

mianhtsys/landingMod3

Build and maintain web frontends — component architecture, state management, API integration, responsive layout, client-side performance, and frontend testing patterns. Framework agnostic, focused on web frontend implementation. Do not use for backend service implementation, data engineering, or platform infrastructure work.

mianhtsys/landingMod3

Evalúa despliegue, contenedores, escalado, alta disponibilidad, observabilidad, backup, recuperación y CI/CD de forma proporcional.

mianhtsys/landingMod3

Generate and maintain OpenAPI 3.1 specifications from code, design-first specs, and validation patterns. Use when creating API documentation, generating SDKs, or ensuring API contract compliance.

mianhtsys/landingMod3

PHP 8.0+ development — XAMPP, RESTful APIs, PDO/MySQL/MariaDB, and authentication. Use when building PHP backends, creating API endpoints, configuring XAMPP, or integrating PHP with databases.

mianhtsys/landingMod3

Use this skill when designing or reviewing a PostgreSQL-specific schema. Covers best-practices, data types, indexing, constraints, performance patterns, and advanced features

mianhtsys/landingMod3

Analiza requisitos funcionales y no funcionales, reglas, restricciones, capacidad y ambigüedades antes de seleccionar tecnologías.

mianhtsys/landingMod3

Implement modern responsive layouts using container queries, fluid typography, CSS Grid, and mobile-first breakpoint strategies. Use when building adaptive interfaces, implementing fluid layouts, or creating component-level responsive behavior.

mianhtsys/landingMod3

>- Use when designing or implementing software securely: define security requirements, threat-model a feature, choose secure defaults, design authentication and authorization, handle untrusted data and secrets, evaluate dependencies, design multi-tenant trust boundaries, or review security-sensitive changes. Use for prevention during requirements, design, implementation, and review; not for post-build security assessments or scanning an existing codebase.

mianhtsys/landingMod3

Revisa seguridad arquitectónica, identidad, autorización, secretos, APIs, auditoría, fraude y resiliencia antes de implementar.

相關技能