xiaohongshu
xiaohongshu
check-repository-pattern
Validates database access follows repository pattern, detects god-trait regression, ensures focused repositories
Full skill instructions
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
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience