一键导入
check-repository-pattern
Validates database access follows repository pattern, detects god-trait regression, ensures focused repositories
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Validates database access follows repository pattern, detects god-trait regression, ensures focused repositories
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use when designing prompts for LLMs, optimizing model performance, building evaluation frameworks, or implementing advanced prompting techniques like chain-of-thought, few-shot learning, or structured outputs.
How to deploy Dravr infrastructure and apply Cloud Run config changes. Use when editing infra/ terraform, when a merged code change is live but a Cloud Run setting (cpu, memory, min/max instances, env var, scaling) hasn't taken effect, or when asked to plan/apply infra. Explains the two-pipeline model (app binary auto-deploys on push; terraform infra config is a separate manual apply) plus the cpu/cpu_idle guardrails.
Enforces zero-tolerance code quality policy using Clippy with strict lints, all warnings treated as errors
Write well-formatted notes to the dravr-vault Obsidian knowledge base. Use this skill whenever creating or updating an ADR, runbook, plan, API doc, guide, session output, or any structured document that should land in the vault — even when the user doesn't say "Obsidian" explicitly. Delegates to obsidian:obsidian-cli to write to the live vault and applies Dravr frontmatter and formatting standards.
Bootstrap Pierre server with database, admin user, coaches, and test users for development and testing
Validates coach markdown files for required frontmatter fields, sections, and naming conventions
| name | check-repository-pattern |
| description | Validates database access follows repository pattern, detects god-trait regression, ensures focused repositories |
| user-invocable | true |
Quick validation that database access follows the repository pattern (commit 6f3efef). Detects god-trait regression and ensures proper use of focused repositories.
Run this skill:
rg)# Check for repository pattern compliance
echo "🔍 Checking repository pattern..."
# 1. Check for DatabaseProvider god-trait (FORBIDDEN)
if rg "trait DatabaseProvider|impl DatabaseProvider" src/ --type rust --quiet; then
echo "❌ FAIL: DatabaseProvider god-trait detected!"
rg "DatabaseProvider" src/ --type rust -n | head -10
exit 1
else
echo "✓ PASS: No DatabaseProvider god-trait"
fi
# 2. Verify repository directory exists
if [ -d "src/database/repositories" ]; then
REPO_COUNT=$(ls -1 src/database/repositories/*_repository.rs 2>/dev/null | wc -l)
echo "✓ PASS: $REPO_COUNT repository files found"
else
echo "❌ FAIL: Repository directory missing!"
exit 1
fi
# 3. Check for direct database access in routes (anti-pattern)
if rg "sqlx::query|\.execute\(|\.fetch" src/routes/ --type rust --quiet; then
echo "⚠️ WARNING: Direct database access in routes detected"
rg "sqlx::query" src/routes/ --type rust -n | head -5
else
echo "✓ PASS: No direct database access in routes"
fi
# 4. Verify repository usage
REPO_USAGE=$(rg "Repository" src/routes/ src/protocols/ --type rust | wc -l)
echo "✓ Repository usage: $REPO_USAGE references"
echo ""
echo "✅ Repository pattern check PASSED"
🔍 Checking repository pattern...
✓ PASS: No DatabaseProvider god-trait
✓ PASS: 13 repository files found
✓ PASS: No direct database access in routes
✓ Repository usage: 127 references
✅ Repository pattern check PASSED
// ❌ Before
async fn handler(
Extension(db): Extension<Arc<dyn DatabaseProvider>>,
) -> AppResult<Json<User>> {
let user = db.get_user(id).await?;
Ok(Json(user))
}
// ✅ After
async fn handler(
Extension(user_repo): Extension<Arc<dyn UserRepository>>,
) -> AppResult<Json<User>> {
let user = user_repo.get_by_id(id).await?
.ok_or(AppError::new(
ErrorCode::ResourceNotFound,
format!("User {} not found", id)
))?;
Ok(Json(user))
}
// ❌ Before (direct sqlx usage in route)
async fn get_user(
Extension(pool): Extension<Arc<Pool<Database>>>,
Path(id): Path<Uuid>,
) -> AppResult<Json<User>> {
let user = sqlx::query_as::<_, User>(
"SELECT * FROM users WHERE id = $1"
)
.bind(id)
.fetch_one(&*pool)
.await?;
Ok(Json(user))
}
// ✅ After (use repository)
async fn get_user(
Extension(user_repo): Extension<Arc<dyn UserRepository>>,
Path(id): Path<Uuid>,
) -> AppResult<Json<User>> {
let user = user_repo.get_by_id(id).await?
.ok_or(AppError::new(
ErrorCode::ResourceNotFound,
format!("User {} not found", id)
))?;
Ok(Json(user))
}
src/database/repositories/mod.rs - Repository traitssrc/database/repositories/*_repository.rs - 13 implementationsrepository-pattern-guardian - Comprehensive repository validation# One-line check
rg "trait DatabaseProvider" src/ --type rust && echo "FAIL" || echo "PASS"
# Check repository count
ls -1 src/database/repositories/*_repository.rs | wc -l
# Check for direct database access
rg "sqlx::query" src/routes/ --type rust && echo "WARNING" || echo "PASS"
# Repository usage count
rg "Repository" src/routes/ src/protocols/ --type rust | wc -l