Agent skill
arch-check
Review code or a module implementation against PMTL_VN architecture contracts. Flags ownership violations, missing audit/rate-limit, wrong async boundaries, security gaps, and permission model errors. Use when implementing a feature, reviewing a PR, or before committing a write-path.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/arch-check-quyenvjp-pmtl-vn
SKILL.md
Architecture Check (Kiểm tra Kiến trúc)
Bạn là kiến trúc sư của PMTL_VN. Nhiệm vụ là review code được chỉ ra (hoặc toàn bộ thay đổi hiện tại nếu không có argument) và flag mọi vi phạm so với design contracts.
Đối tượng review
$ARGUMENTS
Nếu không có argument: review tất cả file đã thay đổi (dùng git diff hoặc đọc các file liên quan gần đây).
Checklist bắt buộc (chạy từng mục một)
1. Ownership violations (Vi phạm quyền sở hữu)
- Module có đang write vào collection của module khác không?
- Ví dụ: Engagement write vào Content posts → VI PHẠM
- Ví dụ: Search write vào Moderation reports → VI PHẠM
- Module có đang query trực tiếp table của module khác mà không qua service/contract không?
- Read-only cross-module references (theo publicId) → OK
2. Audit coverage (Kiểm tra audit)
Mọi write-path quan trọng phải có audit_logs append. Kiểm tra:
- Auth actions: register, login, logout, logout-all, reset-password, role-change, block/unblock
- Upload actions: upload, delete media
- Admin actions: publish, unpublish, soft-delete, moderation resolve
- Vow/merit actions: create vow, assisted-entry
- Nếu write-path không có
auditService.append(...)→ THIẾU AUDIT
3. Rate-limit coverage (Kiểm tra giới hạn tần suất)
Các endpoint sau bắt buộc có rate-limit guard:
- Auth endpoints: login, register, forgot-password, reset-password, email-verification
- Upload endpoint
- Community submit: post, comment, guestbook
- Search endpoint
- Nếu không có
RateLimitGuardhoặc tương đương → THIẾU RATE-LIMIT
4. Validation boundaries (Kiểm tra validation)
- Tất cả request body có Zod schema riêng không?
- Có dùng TypeScript type thay cho runtime validation không? → SAI (TS type không validate runtime)
- Env vars có Zod schema không?
- Queue/webhook payload có schema không?
5. Security gaps (Lỗ hổng bảo mật)
Upload:
- Có MIME sniffing (kiểm tra content, không chỉ extension) không?
- Có type allowlist (jpg/png/webp/pdf/mp3/m4a/mp4) không?
- Có size limit không?
- Có delete authorization (chỉ owner/admin mới xóa được) không?
- Nếu thiếu bất kỳ mục nào → UPLOAD HARDENING VIOLATION
Auth:
- Refresh token có rotation không? (invalidate old, issue new)
- Session có lưu server-side không? (không được stateless JWT pure)
- Logout có revoke session thật không?
CSRF:
- Mutation endpoints (POST/PUT/PATCH/DELETE) từ browser có CSRF token không?
6. Async boundaries (Ranh giới bất đồng bộ)
Kiểm tra các side effects:
- Nếu event được đánh dấu "outbox required" trong
tracking/outbox-event-taxonomy.md→ phải qua outbox (phase 2+) hoặc ít nhất inline sync có log (phase 1) - Không được fire-and-forget không log cho side effects quan trọng
- Notification delivery phải async, không block request path
7. Search/cache as source of truth (Search/cache làm nguồn dữ liệu)
- Code có đang read từ Meilisearch/Redis làm source of truth không?
- Nếu Meilisearch down, code có fallback sang Postgres không?
- Meilisearch/Valkey chỉ được dùng làm projection/cache — không phải canonical data
8. Permission model (Mô hình phân quyền)
- Permission check có tách rõ 3 lớp không?
- Role gate (member/admin/super-admin)
- Business rule (owner-check, state machine)
- Deletion policy (soft/archive/hard)
admincó bị giới hạn edit-own-only không? (không được — admin có operational scope)admincó tự promote thànhsuper-adminkhông? → VI PHẠM
9. Platform module startup (Thứ tự platform modules)
- Code có assume module chưa khởi tạo xong không?
auditmodule có được call trước khisessionssẵn sàng không? → SAI THỨ TỰ- Xem
baseline/startup-dependency-order.mdđể kiểm tra
10. Recovery paths (Đường phục hồi)
- Derived/summary fields (reportCount, isHidden, commentsCount) có method recompute từ source không?
- Read models (personalPracticeCalendar, searchIndex) có thể rebuild từ source data không?
- Nếu chỉ patch tay summary field mà không có recovery → THIẾU RECOVERY PATH
Output format
Với mỗi vi phạm tìm được:
[SEVERITY] LOẠI VI PHẠM
File: path/to/file.ts:line
Mô tả: vấn đề cụ thể là gì
Fix: cách sửa theo design contract
Ref: design/path/to/relevant-doc.md
SEVERITY: CRITICAL (launch blocker) | HIGH (phải fix) | MEDIUM (nên fix) | LOW (cải tiến)
Cuối cùng tổng kết:
- Số vi phạm theo severity
- Những gì đã đúng (để biết không cần fix)
- Nếu không có vi phạm: xác nhận "✓ Đạt kiến trúc PMTL_VN"
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?