bereke1t2/cpd-hub-backend/phase-07-consistency
Claude Code and agent skill by bereke1t2/cpd-hub-backend
- community
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install bereke1t2/cpd-hub-backend/phase-07-consistencySKILL.md
The same SKILL.md was published earlier as bereke1t2/cpd-hub-backend/phase-07-consistency.
Phase 7 — Consistency Engine (NEW feature)
Goal: Build the backend for the mobile consistency feature (streaks, weekly goals, rating ladders) which today runs entirely on a mock data source. Persist per-user streak/goal state and serve the rung ladders, so progress survives reinstalls and syncs across devices.
Depends on: Phase 4 (solves drive the streak; daily_solves already exists). Risk: Medium. Net-new domain, but it reuses signals (daily_solves, user_problems.solved) already captured. Follows the Phase-0 feature recipe exactly.
The contract (must match the Flutter models — snake_case)
From ../CPD_HUB/lib/features/consistency/data/models/:
Endpoints:
Checklist
- [x] 7.1 Domain entities + repository interface (
internal/domain/consistency.go). - [x] 7.2 Migration
0008_consistency(streaks,goals,ladders+ladder_rungs,user_ladder_solved). - [x] 7.3 Repository (
consistency_repo.go). - [x] 7.4 Usecase: derive/recompute streak from
daily_solves; default goal for new users. - [x] 7.5 Handlers + routes + wire repo in
main.go. - [x] 7.6 Seed the base ladders (Div 2 A/B ladders, etc.).
7.1 Domain
Copy `consistency.go` to internal/domain/consistency.go. JSON tags are snake_case to match the client. Note Streak.LastActiveDay is a nullable date → use *string (formatted YYYY-MM-DD) or *time.Time with a custom date format; the template uses formatted strings to avoid timezone surprises.
7.2 Migration
Copy `0008_consistency.up.sql` / .down.sql to migrations/. Tables:
streaks(username PK, current, longest, last_active_day, freezes_available).streak_active_days(username, day)— theactive_daysset.goals(username, id, type, target, progress, period_start)— PK(username, id).ladders(id PK, title, from_rating, to_rating)+ladder_rungs(ladder_id, problem_id, rating, topic_id, ord).user_ladder_solved(username, problem_id)— the per-user solved overlay for ladder rungs.
7.3 Repository
Copy `consistency_repo.go`. GetLadders(username) loads base ladders + rungs, then overlays solved from user_ladder_solved (or reuse user_problems.solved keyed by problem_id so solving a problem anywhere lights up the ladder — preferred; the template does this).
7.4 Usecase — streak recompute
The streak is derived, not just stored. Copy `consistency_usecase.go`. On GET /streak it recomputes from daily_solves:
current= length of the consecutive-day run ending today (or yesterday, with a freeze).longest= max run ever.active_days= the set of days with ≥1 solve.- A freeze lets one gap day not break the streak; decrement
freezes_availablewhen used.
This keeps the streak honest even if the client never PUTs. PUT /streak is still accepted (e.g. to spend a freeze or for offline reconciliation) but the server is the source of truth. The goal's progress is likewise recomputed from solves within [period_start, period_start+7d).
7.5–7.6 Delivery + seed
Add GetStreak/PutStreak/GetGoal/PutGoal/GetLadders/PutLadder handlers, register routes under a /consistency protected group, add Consistency domain.ConsistencyRepository to Repos + the Handler interface, wire in main.go. Seed a couple of base ladders in cmd/seed so GET /ladders returns content.
Definition of Done
- [x]
GET /consistency/streakreturns a streak computed from the caller's real solves; solving today bumps
current.
- [x] A new user gets a sensible default goal (
weekly-problems, target 5) without a 404. - [x]
GET /consistency/goalshowsprogress= problems solved this period. - [x]
GET /consistency/laddersreturns base ladders with the caller'ssolvedoverlaid per rung. - [x] All JSON field names match the Flutter models (snake_case) — the app's mock source can be swapped for
the remote one with no model changes.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingdocs/phase-07-consistency/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/bereke1t2/cpd-hub-backend/phase-07-consistency)