@hanzlaa/rcode 2.8.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/AGENTS.md +11 -1
  2. package/CONTRIBUTING.md +7 -0
  3. package/README.md +39 -20
  4. package/cli/install.js +145 -47
  5. package/dist/rcode.js +134 -43
  6. package/package.json +2 -2
  7. package/rihal/agents/rihal-advisor-researcher.md +1 -1
  8. package/rihal/agents/rihal-assumptions-analyzer.md +1 -1
  9. package/rihal/agents/rihal-codebase-mapper.md +1 -1
  10. package/rihal/agents/rihal-docs-auditor.md +3 -3
  11. package/rihal/agents/rihal-executor.md +10 -0
  12. package/rihal/agents/rihal-integration-checker.md +1 -1
  13. package/rihal/agents/rihal-noor.md +2 -2
  14. package/rihal/agents/rihal-phase-researcher.md +1 -1
  15. package/rihal/agents/rihal-planner.md +25 -0
  16. package/rihal/agents/rihal-project-researcher.md +1 -1
  17. package/rihal/agents/rihal-research-synthesizer.md +1 -1
  18. package/rihal/agents/rihal-roadmapper.md +1 -1
  19. package/rihal/agents/rihal-sprint-checker.md +19 -1
  20. package/rihal/agents/rihal-verifier.md +1 -1
  21. package/rihal/agents/rihal-waleed.md +1 -2
  22. package/rihal/commands/code-review.md +1 -1
  23. package/rihal/commands/memory-audit.md +10 -0
  24. package/rihal/commands/memory-distill.md +11 -0
  25. package/rihal/commands/memory-init.md +12 -0
  26. package/rihal/commands/memory-update.md +12 -0
  27. package/rihal/config/model-profiles.json +5 -5
  28. package/rihal/references/karpathy-guidelines-full.md +1 -1
  29. package/rihal/references/no-unauthorized-git-ops.md +1 -1
  30. package/rihal/references/verb-dictionary.md +1 -1
  31. package/rihal/skills/actions/2-plan/rihal-frontend-design/SKILL.md +49 -139
  32. package/rihal/skills/actions/2-plan/rihal-frontend-design/references.md +79 -0
  33. package/rihal/skills/actions/4-implementation/rihal-browser-verify/SKILL.md +70 -0
  34. package/rihal/skills/actions/4-implementation/rihal-checkpoint-preview/SKILL.md +1 -1
  35. package/rihal/skills/actions/4-implementation/rihal-ci/SKILL.md +108 -0
  36. package/rihal/skills/actions/4-implementation/rihal-debug/SKILL.md +78 -0
  37. package/rihal/skills/actions/4-implementation/rihal-git-flow/SKILL.md +90 -0
  38. package/rihal/skills/actions/4-implementation/rihal-harden/SKILL.md +91 -0
  39. package/rihal/skills/actions/4-implementation/rihal-incremental/SKILL.md +50 -0
  40. package/rihal/skills/actions/4-implementation/rihal-migrate/SKILL.md +86 -0
  41. package/rihal/skills/actions/4-implementation/rihal-perf/SKILL.md +96 -0
  42. package/rihal/skills/actions/4-implementation/rihal-prove-it/SKILL.md +64 -0
  43. package/rihal/skills/actions/4-implementation/rihal-source-truth/SKILL.md +76 -0
  44. package/rihal/skills/actions/4-implementation/rihal-trim/SKILL.md +73 -0
  45. package/rihal/skills/agents/dalil-scout/SKILL.md +43 -125
  46. package/rihal/skills/agents/dalil-scout/references.md +67 -0
  47. package/rihal/skills/agents/majlis-council/SKILL.md +50 -144
  48. package/rihal/skills/agents/majlis-council/references.md +90 -0
  49. package/rihal/skills/agents/raees-orchestrator/SKILL.md +56 -117
  50. package/rihal/skills/agents/raees-orchestrator/references.md +47 -0
  51. package/rihal/skills/core/rihal-advanced-elicitation/SKILL.md +36 -136
  52. package/rihal/skills/core/rihal-advanced-elicitation/references.md +101 -0
  53. package/rihal/skills/core/rihal-auth-audit/SKILL.md +93 -0
  54. package/rihal/skills/core/rihal-brainstorming/SKILL.md +5 -0
  55. package/rihal/skills/core/rihal-client-gate/SKILL.md +91 -0
  56. package/rihal/skills/core/rihal-clone-website/SKILL.md +30 -371
  57. package/rihal/skills/core/rihal-clone-website/references.md +213 -0
  58. package/rihal/skills/core/rihal-deploy-unify/SKILL.md +87 -0
  59. package/rihal/skills/core/rihal-distillator/SKILL.md +37 -187
  60. package/rihal/skills/core/rihal-distillator/references.md +118 -0
  61. package/rihal/skills/core/rihal-editorial-review-prose/SKILL.md +5 -0
  62. package/rihal/skills/core/rihal-editorial-review-structure/SKILL.md +45 -183
  63. package/rihal/skills/core/rihal-editorial-review-structure/references.md +110 -0
  64. package/rihal/skills/core/rihal-help/SKILL.md +6 -1
  65. package/rihal/skills/core/rihal-incident-record/SKILL.md +161 -0
  66. package/rihal/skills/core/rihal-index-docs/SKILL.md +5 -0
  67. package/rihal/skills/core/rihal-init/SKILL.md +5 -0
  68. package/rihal/skills/core/rihal-memory-audit/SKILL.md +88 -0
  69. package/rihal/skills/core/rihal-memory-distill/SKILL.md +87 -0
  70. package/rihal/skills/core/rihal-memory-init/SKILL.md +77 -0
  71. package/rihal/skills/core/rihal-memory-update/SKILL.md +73 -0
  72. package/rihal/skills/core/rihal-mvp-graduate/SKILL.md +116 -0
  73. package/rihal/skills/core/rihal-ocr-consistency/SKILL.md +106 -0
  74. package/rihal/skills/core/rihal-party-mode/SKILL.md +5 -0
  75. package/rihal/skills/core/rihal-rebrand/SKILL.md +133 -0
  76. package/rihal/skills/core/rihal-review-adversarial-general/SKILL.md +5 -0
  77. package/rihal/skills/core/rihal-review-edge-case-hunter/SKILL.md +5 -0
  78. package/rihal/skills/core/rihal-shard-doc/SKILL.md +5 -0
  79. package/rihal/skills/core/rihal-theme-system/SKILL.md +113 -0
  80. package/rihal/team.yaml +3 -22
  81. package/rihal/templates/memory/INDEX.md +46 -0
  82. package/rihal/templates/memory/change-records/.gitkeep +4 -0
  83. package/rihal/templates/memory/distillates/project.distillate.md +11 -0
  84. package/rihal/templates/memory/distillates/stack.distillate.md +11 -0
  85. package/rihal/templates/memory/incidents/known-issues.md +27 -0
  86. package/rihal/templates/memory/incidents/post-mortems/.gitkeep +3 -0
  87. package/rihal/templates/memory/milestones/archive/.gitkeep +2 -0
  88. package/rihal/templates/memory/milestones/current.md +39 -0
  89. package/rihal/templates/memory/people/stakeholders.md +25 -0
  90. package/rihal/templates/memory/people/team.md +35 -0
  91. package/rihal/templates/memory/project/decisions.md +32 -0
  92. package/rihal/templates/memory/project/glossary.md +16 -0
  93. package/rihal/templates/memory/project/stack.md +46 -0
  94. package/rihal/workflows/audit.md +3 -3
  95. package/rihal/workflows/code-review.md +32 -1
  96. package/rihal/workflows/council.md +1 -1
  97. package/rihal/workflows/discuss-phase-power.md +3 -3
  98. package/rihal/workflows/do.md +1 -1
  99. package/rihal/workflows/docs-update.md +4 -4
  100. package/rihal/workflows/execute.md +61 -5
  101. package/rihal/workflows/help.md +5 -5
  102. package/rihal/workflows/karpathy-audit.md +9 -9
  103. package/rihal/workflows/memory-audit.md +83 -0
  104. package/rihal/workflows/memory-distill.md +103 -0
  105. package/rihal/workflows/memory-init.md +102 -0
  106. package/rihal/workflows/memory-update.md +83 -0
  107. package/rihal/workflows/plan.md +66 -1
  108. package/server/dashboard.js +6 -1
  109. package/server/lib/api.js +8 -2
  110. package/server/lib/html/client.js +63 -0
  111. package/server/lib/html/shell.js +5 -0
  112. package/server/lib/scanner.js +76 -1
  113. package/rihal/agents/rihal-architect.md +0 -79
  114. package/rihal/agents/rihal-tech-writer.md +0 -80
  115. package/rihal/commands/check-implementation-readiness.md +0 -8
  116. package/rihal/commands/discuss-phase-power.md +0 -11
  117. package/rihal/commands/karpathy-audit.md +0 -12
  118. package/rihal/commands/new-project-research.md +0 -11
  119. package/rihal/commands/new-project-roadmap.md +0 -11
  120. package/rihal/commands/report.md +0 -10
  121. package/rihal/commands/review-adversarial.md +0 -8
  122. package/rihal/commands/review-edge-case-hunter.md +0 -8
@@ -0,0 +1,93 @@
1
+ ---
2
+ name: rihal-auth-audit
3
+ description: Audit Keycloak ↔ Active Directory sync, JWT validation, and tenant isolation in multi-org Postgres. Use when seeing authentication weirdness — users disappearing, tokens accepted post-deactivation, "phantom" sessions, or tenant data leaking across orgs. Specifically encodes the lessons from the Rihal Keycloak data-loss incident — sync drift between Keycloak and AD silently broke logins.
4
+ triggers:
5
+ - "auth audit"
6
+ - "keycloak ad sync"
7
+ - "users disappearing"
8
+ - "ghost session"
9
+ - "tenant leak"
10
+ - "jwt validation check"
11
+ - "stale token"
12
+ - "session not invalidating"
13
+ user-invocable: true
14
+ ---
15
+
16
+ ## Overview
17
+
18
+ Authentication bugs are usually silent — the user just gets logged out, or worse, sees someone else's data. This skill encodes the specific failure modes that have actually bitten Rihal projects, with a runnable 10-minute checklist. Default scope is Keycloak + Active Directory + Postgres; adapt the specifics to whatever provider is in use.
19
+
20
+ ## The 10-minute checklist
21
+
22
+ ### Keycloak ↔ AD sync (the load-bearing one)
23
+
24
+ - [ ] Keycloak's AD federation is configured with **periodic sync ENABLED**, not just on-login. Without periodic sync, a user deactivated in AD keeps working in Keycloak until their token expires.
25
+ - [ ] Sync interval ≤ 1 hour for production. Longer windows are how the Rihal incident happened.
26
+ - [ ] Sync errors land in Sentry, not just Keycloak's internal log. If sync silently fails, no one notices for weeks.
27
+ - [ ] On AD deactivation, the corresponding Keycloak session is **explicitly invalidated** — don't rely on the JWT expiring.
28
+
29
+ ### JWT validation
30
+
31
+ - [ ] `iss`, `aud`, `exp`, signature — all four checked on every protected request.
32
+ - [ ] JWKS keys are **fetched dynamically with caching**, not pinned. Keycloak rotates them.
33
+ - [ ] Clock-skew tolerance is ≤ 60s. Larger windows give attackers reuse room.
34
+ - [ ] Token revocation list (or short TTL + refresh) is in place. Stateless JWTs are a CVE waiting for "logout doesn't actually log out".
35
+
36
+ ### Tenant isolation in Postgres
37
+
38
+ - [ ] Every query that reads tenant data has `WHERE tenant_id = $1` where `$1` is **derived from the JWT**, never from a request parameter or cookie.
39
+ - [ ] Postgres Row-Level Security (RLS) policies are enabled OR a query middleware enforces tenant_id (belt + suspenders preferred).
40
+ - [ ] No raw SQL strings interpolate tenant_id — always parameterised.
41
+ - [ ] Audit log captures the tenant_id from the JWT for every write.
42
+
43
+ ### Session lifecycle
44
+
45
+ - [ ] Password change → ALL sessions for that user invalidated (not just the current device).
46
+ - [ ] Permission change (role removed) → token re-validation forced on next request.
47
+ - [ ] Logout actually deletes the server-side session record, not just the cookie.
48
+
49
+ ## Workflow
50
+
51
+ 1. **Inventory the auth surfaces.** Login, refresh, password reset, role change, permission change, logout, OAuth callbacks if present.
52
+ 2. **Run the checklist** above for each surface. Cite the actual file and line for each pass / fail.
53
+ 3. **For each fail:** write a malicious test case before fixing — the test is the proof of regression-locked.
54
+ 4. **Persist findings** to `.rihal/memory/incidents/known-issues.md` if not fixable in this session, or `.rihal/memory/change-records/` if fixed.
55
+
56
+ ## Output Format
57
+
58
+ ```
59
+ Auth audit — <date>
60
+ Surfaces: <count>
61
+
62
+ Keycloak ↔ AD sync:
63
+ ✓ periodic sync enabled (interval: <X>)
64
+ ✗ sync errors not in Sentry
65
+ ⚠ <other findings>
66
+
67
+ JWT validation:
68
+ ✓ all 4 fields checked
69
+ ⚠ <other>
70
+
71
+ Tenant isolation:
72
+ ✗ <table>.<query> missing tenant_id filter — file:line
73
+
74
+ Session lifecycle:
75
+ ✓ <findings>
76
+
77
+ Critical (block launch / production): <count>
78
+ High (fix this sprint): <count>
79
+ Medium (track in known-issues.md): <count>
80
+ ```
81
+
82
+ ## Examples
83
+
84
+ **Happy path — sync drift caught** — Audit shows Keycloak sync is configured but interval is 24h, and errors aren't in Sentry. Findings: 2 critical. Fix: drop interval to 1h + wire sync errors to Sentry. Verify by deactivating a test user in AD and confirming Keycloak removes them within 1h.
85
+
86
+ **Edge case — RLS enabled but middleware bypasses it** — Postgres RLS is on, but the Strapi controllers use a service-role connection that bypasses RLS. Findings: critical. Fix: switch to per-request connections with the user's JWT-derived role.
87
+
88
+ **Negative — "we use OAuth so we're fine"** — Refuse. OAuth ≠ correctly-configured. Run the checklist anyway.
89
+
90
+ ## Memory Bank Hooks
91
+
92
+ - **Reads:** `.rihal/memory/incidents/post-mortems/` (prior auth incidents), `.rihal/memory/project/stack.md` (auth provider)
93
+ - **Writes:** `.rihal/memory/incidents/known-issues.md` (deferred); `.rihal/memory/change-records/YYYYMMDD-NNN.md` (the audit itself)
@@ -96,3 +96,8 @@ Follow the instructions in ./workflow.md.
96
96
  ### Negative boundary
97
97
  **User:** "brainstorm which tech stack to use"
98
98
  **Result:** Redirects to `/rihal:council` or Waleed (CTO) — architecture decisions need structured ADR evaluation, not open ideation.
99
+
100
+ ## Memory Bank Hooks
101
+
102
+ - **Reads:** `.rihal/memory/project/glossary.md` (so generated ideas use project domain terms)
103
+ - **Writes:** the brainstorm output document at the user-specified path; if any idea becomes a committed direction, the user should run `rcode-memory-update` to log it as a decision
@@ -0,0 +1,91 @@
1
+ ---
2
+ name: rihal-client-gate
3
+ description: Client requirement freeze gates and async-comm patterns to stop late requirements from derailing delivery. Use when a project keeps slipping because the client adds requirements mid-sprint, or when the client takes a week to respond to a blocking question. Specifically encodes Rihal's "client late requirements caused project delays" pain — the fix isn't to "communicate better", it's structural gates that the project actually enforces.
4
+ triggers:
5
+ - "client gate"
6
+ - "freeze requirements"
7
+ - "scope creep"
8
+ - "client slow response"
9
+ - "requirements freeze"
10
+ - "client comm pattern"
11
+ - "stop late requirements"
12
+ - "delivery slipping"
13
+ user-invocable: true
14
+ ---
15
+
16
+ ## Overview
17
+
18
+ Late client requirements aren't the client's fault — they're the project's structural failure to define when input is welcome and when it's not. This skill installs three gates: a **scope freeze** at sprint start, a **decision deadline** for blocking questions, and a **change-control** path for everything that arrives after the freeze. Without these, every client comment becomes a potential mid-sprint pivot.
19
+
20
+ ## The 3 gates
21
+
22
+ ### Gate 1 — Scope freeze at sprint start
23
+
24
+ - Sprint scope is locked at sprint kickoff, in writing, with the client signing off.
25
+ - "Locked" means: no new stories enter the sprint without going through Gate 3 (change control).
26
+ - The scope doc lives in `.rihal/memory/milestones/current.md` (not just a Slack message).
27
+ - Sign-off is explicit — a thumbs-up emoji doesn't count. Email or document sign-off.
28
+
29
+ ### Gate 2 — Decision deadline for blocking questions
30
+
31
+ - Every blocking question to the client carries a deadline: e.g. "we need an answer by Wed EOD or we ship the default option".
32
+ - Deadlines are enforced — when missed, the team picks the documented default and moves on.
33
+ - Defaults are documented BEFORE asking — "if you don't reply, we'll do X".
34
+ - Stakeholder response cadences from `.rihal/memory/people/stakeholders.md` inform the deadline (don't give a 24h deadline to a stakeholder with a documented 1-week cadence).
35
+
36
+ ### Gate 3 — Change control after the freeze
37
+
38
+ - Anything new that arrives after the sprint kickoff goes into a queue, not the current sprint.
39
+ - Each change-request gets evaluated weekly:
40
+ - **Critical** (broken core flow, security): emergency mid-sprint slot — but explicit, with a story shipped late.
41
+ - **High** (next sprint priority): goes to top of next sprint's backlog.
42
+ - **Medium / nice-to-have**: parked, reviewed at next milestone.
43
+ - Client sees the queue; transparency prevents "where did my request go?" friction.
44
+
45
+ ## Workflow
46
+
47
+ 1. **At project kickoff:** install the 3 gates. Walk the client through them — explain that this is how delivery dates stay credible.
48
+ 2. **At each sprint kickoff:** run Gate 1. Write down the scope. Get sign-off.
49
+ 3. **Throughout the sprint:** any blocking question gets Gate 2 (deadline + default). Any new requirement gets Gate 3 (queue).
50
+ 4. **At sprint close:** review the change queue with the client. Triage.
51
+ 5. **Persist all gate events** to `.rihal/memory/people/stakeholders.md` and the change-records folder. The pattern of "client always responds Friday afternoon" becomes a planning input.
52
+
53
+ ## Output Format
54
+
55
+ For each sprint:
56
+
57
+ ```
58
+ Sprint kickoff — <date>
59
+ Scope (signed off by <client>):
60
+ - Story 1
61
+ - Story 2
62
+ ...
63
+
64
+ Active blocking questions:
65
+ Q1 (asked <date>, deadline <date>): <question>
66
+ Default if no answer: <documented default>
67
+
68
+ Change queue (post-freeze):
69
+ Critical: <count>
70
+ High: <count>
71
+ Medium: <count>
72
+
73
+ Memory Bank update:
74
+ → .rihal/memory/milestones/current.md (scope sign-off)
75
+ → .rihal/memory/people/stakeholders.md (cadence observations)
76
+ ```
77
+
78
+ ## Examples
79
+
80
+ **Happy path — government client** — Client has documented 1-week response cadence. Gate 2 deadline becomes 5 days, with a default ("we'll go with option B unless you reply"). Project ships on time despite slow comms.
81
+
82
+ **Happy path — scope freeze enforced** — Day 4 of sprint, client adds 3 requirements. Gate 3 queues all 3. Client sees them in the next-sprint backlog. No mid-sprint pivot.
83
+
84
+ **Edge case — "but this requirement is critical"** — Run the Gate 3 critical-or-not test: does this break a core flow? Is it a security issue? If yes, emergency mid-sprint slot with explicit story shipped late. If no, it's a next-sprint priority. Don't let "critical" be a synonym for "I'd really like this".
85
+
86
+ **Negative — "we'll just be more flexible"** — Refuse. Flexibility without gates is how every Rihal-style late-requirements incident happens. Gates make the flexibility explicit and survivable.
87
+
88
+ ## Memory Bank Hooks
89
+
90
+ - **Reads:** `.rihal/memory/people/stakeholders.md` (response cadences), `.rihal/memory/milestones/current.md`
91
+ - **Writes:** scope sign-offs to `.rihal/memory/milestones/current.md`; client change requests to `.rihal/memory/change-records/YYYYMMDD-NNN.md`
@@ -10,15 +10,13 @@ description: >
10
10
  "yeh site clone karo", or "exact same UI chahiye like [URL]". Provide the
11
11
  target URL as input. Do NOT use for: creating original designs from scratch
12
12
  (use rihal-create-ux-design with Layla), writing new components from a
13
- brief (use rihal-dev-story with Hanzla or Bilal), or inspiration-only
14
- references without rebuild intent.
13
+ brief (use rihal-dev-story with Hanzla), or inspiration-only references
14
+ without rebuild intent.
15
15
  triggers:
16
- - "clone
17
- this website"
16
+ - "clone this website"
18
17
  - "clone this site"
19
18
  - "rebuild this page"
20
- - "replicate this
21
- UI"
19
+ - "replicate this UI"
22
20
  - "pixel-perfect clone"
23
21
  - "make exact UI like this"
24
22
  - "copy this site"
@@ -31,386 +29,47 @@ argument-hint: "<url>"
31
29
  user-invocable: true
32
30
  ---
33
31
 
34
- # Clone Website (Rihal)
35
-
36
- You are about to reverse-engineer and rebuild **$ARGUMENTS** as a pixel-perfect clone.
37
-
38
- This is not a two-phase process (inspect then build). You are a **foreman walking the job site** — as you inspect each section of the page, you write a detailed specification to a file, then hand that file to a specialist builder agent with everything they need. Extraction and construction happen in parallel, but extraction is meticulous and produces auditable artifacts.
39
-
40
- ## Pre-Flight
41
-
42
- 1. **Chrome MCP is required.** Test it immediately. If it's not available, stop and tell the user to enable it — this skill cannot work without browser automation.
43
- 2. Read `TARGET.md` for URL and scope. If the URL doesn't match `$ARGUMENTS`, update it.
44
- 3. Verify the base project builds: `npm run build`. The Next.js + shadcn/ui + Tailwind v4 scaffold should already be in place. If not, tell the user to set it up first.
45
- 4. Create the output directories if they don't exist: `docs/research/`, `docs/research/components/`, `docs/design-references/`, `scripts/`.
46
-
47
- ## Guiding Principles
48
-
49
- These are the truths that separate a successful clone from a "close enough" mess. Internalize them — they should inform every decision you make.
50
-
51
- ### 1. Completeness Beats Speed
52
-
53
- Every builder agent must receive **everything** it needs to do its job perfectly: screenshot, exact CSS values, downloaded assets with local paths, real text content, component structure. If a builder has to guess anything — a color, a font size, a padding value — you have failed at extraction. Take the extra minute to extract one more property rather than shipping an incomplete brief.
54
-
55
- ### 2. Small Tasks, Perfect Results
56
-
57
- When an agent gets "build the entire features section," it glosses over details — it approximates spacing, guesses font sizes, and produces something "close enough" but clearly wrong. When it gets a single focused component with exact CSS values, it nails it every time.
58
-
59
- Look at each section and judge its complexity. A simple banner with a heading and a button? One agent. A complex section with 3 different card variants, each with unique hover states and internal layouts? One agent per card variant plus one for the section wrapper. When in doubt, make it smaller.
60
-
61
- **Complexity budget rule:** If a builder prompt exceeds ~150 lines of spec content, the section is too complex for one agent. Break it into smaller pieces. This is a mechanical check — don't override it with "but it's all related."
62
-
63
- ### 3. Real Content, Real Assets
64
-
65
- Extract the actual text, images, videos, and SVGs from the live site. This is a clone, not a mockup. Use `element.textContent`, download every `<img>` and `<video>`, extract inline `<svg>` elements as React components. The only time you generate content is when something is clearly server-generated and unique per session.
66
-
67
- **Layered assets matter.** A section that looks like one image is often multiple layers — a background watercolor/gradient, a foreground UI mockup PNG, an overlay icon. Inspect each container's full DOM tree and enumerate ALL `<img>` elements and background images within it, including absolutely-positioned overlays.
68
-
69
- ### 4. Foundation First
70
-
71
- Nothing can be built until the foundation exists: global CSS with the target site's design tokens (colors, fonts, spacing), TypeScript types for the content structures, and global assets (fonts, favicons). This is sequential and non-negotiable. Everything after this can be parallel.
72
-
73
- ### 5. Extract How It Looks AND How It Behaves
74
-
75
- A website is not a screenshot — it's a living thing. Elements move, change, appear, and disappear in response to scrolling, hovering, clicking, resizing, and time. If you only extract the static CSS of each element, your clone will look right in a screenshot but feel dead when someone actually uses it.
76
-
77
- For every element, extract its **appearance** (exact computed CSS via `getComputedStyle()`) AND its **behavior** (what changes, what triggers the change, and how the transition happens).
78
-
79
- Examples of behaviors to watch for:
80
- - Navbar that shrinks/changes background/gains shadow after scroll threshold
81
- - Elements that animate into view on viewport entry (fade-up, slide-in, stagger)
82
- - Sections with `scroll-snap-type`
83
- - Parallax layers
84
- - Hover state transitions (duration and easing matter)
85
- - Dropdowns/modals/accordions with enter/exit animations
86
- - Auto-playing carousels
87
- - Tabbed/pill content that cycles
88
- - Scroll-driven tab/accordion switching (IntersectionObserver, NOT click handlers)
89
- - Smooth scroll libraries (Lenis, Locomotive Scroll)
90
-
91
- ### 6. Identify the Interaction Model Before Building
92
-
93
- This is the single most expensive mistake in cloning: building a click-based UI when the original is scroll-driven, or vice versa.
94
-
95
- How to determine this:
96
- 1. **Don't click first.** Scroll through the section slowly and observe if things change on their own as you scroll.
97
- 2. If they do, it's scroll-driven. Extract the mechanism.
98
- 3. If nothing changes on scroll, THEN click/hover to test for click/hover-driven interactivity.
99
- 4. Document the interaction model explicitly in the component spec.
100
-
101
- ### 7. Extract Every State, Not Just the Default
102
-
103
- For tabbed/stateful content: click each tab via Chrome MCP and extract content per state. For scroll-dependent elements: capture at scroll position 0 and after crossing the trigger threshold.
104
-
105
- ### 8. Spec Files Are the Source of Truth
106
-
107
- Every component gets a specification file in `docs/research/components/` BEFORE any builder is dispatched. The builder receives the spec file contents inline in its prompt — the file also persists as an auditable artifact.
108
-
109
- ### 9. Build Must Always Compile
110
-
111
- Every builder agent must verify `npx tsc --noEmit` passes before finishing. After merging worktrees, you verify `npm run build` passes.
112
-
113
- ## Phase 1: Reconnaissance
114
-
115
- Navigate to the target URL with Chrome MCP.
116
-
117
- ### Screenshots
118
- - Take **full-page screenshots** at desktop (1440px) and mobile (390px) viewports
119
- - Save to `docs/design-references/` with descriptive names
120
-
121
- ### Global Extraction
122
- Extract before anything else:
123
-
124
- **Fonts** — Inspect `<link>` tags for Google Fonts or self-hosted fonts. Check computed `font-family` on key elements. Configure in `src/app/layout.tsx` using `next/font`.
125
-
126
- **Colors** — Extract color palette from computed styles. Update `src/app/globals.css` with the target's actual colors.
127
-
128
- **Favicons & Meta** — Download to `public/seo/` and update `layout.tsx` metadata.
129
-
130
- **Global UI patterns** — Custom scrollbar, scroll-snap on page container, global keyframes, backdrop filters, smooth scroll libraries.
131
-
132
- ### Mandatory Interaction Sweep
133
-
134
- **Scroll sweep:** Scroll the page slowly from top to bottom. Record header changes, viewport animations, auto-switching sidebars, scroll-snap points, smooth scroll libraries.
135
-
136
- **Click sweep:** Click every element that looks interactive.
137
-
138
- **Hover sweep:** Hover over every interactive element.
139
-
140
- **Responsive sweep:** Test at 1440px, 768px, 390px. Note layout changes at each breakpoint.
141
-
142
- Save findings to `docs/research/BEHAVIORS.md`.
143
-
144
- ### Page Topology
145
- Map every distinct section from top to bottom. Give each a working name. Save as `docs/research/PAGE_TOPOLOGY.md`.
146
-
147
- ## Phase 2: Foundation Build
148
-
149
- Sequential. Do it yourself:
150
-
151
- 1. **Update fonts** in `layout.tsx`
152
- 2. **Update globals.css** with target's color tokens, spacing, keyframes, scroll behaviors
153
- 3. **Create TypeScript interfaces** in `src/types/`
154
- 4. **Extract SVG icons** as React components in `src/components/icons.tsx`
155
- 5. **Download global assets** via `scripts/download-assets.mjs`
156
- 6. Verify: `npm run build` passes
157
-
158
- ### Asset Discovery Script
159
-
160
- Run via Chrome MCP:
161
-
162
- ```javascript
163
- JSON.stringify({
164
- images: [...document.querySelectorAll('img')].map(img => ({
165
- src: img.src || img.currentSrc,
166
- alt: img.alt,
167
- width: img.naturalWidth,
168
- height: img.naturalHeight,
169
- parentClasses: img.parentElement?.className,
170
- position: getComputedStyle(img).position,
171
- zIndex: getComputedStyle(img).zIndex
172
- })),
173
- videos: [...document.querySelectorAll('video')].map(v => ({
174
- src: v.src || v.querySelector('source')?.src,
175
- poster: v.poster,
176
- autoplay: v.autoplay, loop: v.loop, muted: v.muted
177
- })),
178
- backgroundImages: [...document.querySelectorAll('*')].filter(el => {
179
- const bg = getComputedStyle(el).backgroundImage;
180
- return bg && bg !== 'none';
181
- }).map(el => ({
182
- url: getComputedStyle(el).backgroundImage,
183
- element: el.tagName + '.' + el.className?.split(' ')[0]
184
- })),
185
- fonts: [...new Set([...document.querySelectorAll('*')].slice(0, 200).map(el => getComputedStyle(el).fontFamily))],
186
- favicons: [...document.querySelectorAll('link[rel*="icon"]')].map(l => ({ href: l.href, sizes: l.sizes?.toString() }))
187
- });
188
- ```
189
-
190
- ## Phase 3: Component Specification & Dispatch
191
-
192
- For each section (top to bottom): **extract → write spec file → dispatch builders**.
193
-
194
- ### Step 1: Extract
195
-
196
- 1. **Screenshot** the section in isolation
197
- 2. **Extract CSS** via this script (replace SELECTOR):
198
-
199
- ```javascript
200
- (function(selector) {
201
- const el = document.querySelector(selector);
202
- if (!el) return JSON.stringify({ error: 'Element not found: ' + selector });
203
- const props = [
204
- 'fontSize','fontWeight','fontFamily','lineHeight','letterSpacing','color',
205
- 'textTransform','textDecoration','backgroundColor','background',
206
- 'padding','paddingTop','paddingRight','paddingBottom','paddingLeft',
207
- 'margin','marginTop','marginRight','marginBottom','marginLeft',
208
- 'width','height','maxWidth','minWidth','maxHeight','minHeight',
209
- 'display','flexDirection','justifyContent','alignItems','gap',
210
- 'gridTemplateColumns','gridTemplateRows',
211
- 'borderRadius','border','borderTop','borderBottom','borderLeft','borderRight',
212
- 'boxShadow','overflow','overflowX','overflowY',
213
- 'position','top','right','bottom','left','zIndex',
214
- 'opacity','transform','transition','cursor',
215
- 'objectFit','objectPosition','mixBlendMode','filter','backdropFilter',
216
- 'whiteSpace','textOverflow','WebkitLineClamp'
217
- ];
218
- function extractStyles(element) {
219
- const cs = getComputedStyle(element);
220
- const styles = {};
221
- props.forEach(p => {
222
- const v = cs[p];
223
- if (v && v !== 'none' && v !== 'normal' && v !== 'auto' && v !== '0px' && v !== 'rgba(0, 0, 0, 0)') styles[p] = v;
224
- });
225
- return styles;
226
- }
227
- function walk(element, depth) {
228
- if (depth > 4) return null;
229
- const children = [...element.children];
230
- return {
231
- tag: element.tagName.toLowerCase(),
232
- classes: element.className?.toString().split(' ').slice(0, 5).join(' '),
233
- text: element.childNodes.length === 1 && element.childNodes[0].nodeType === 3 ? element.textContent.trim().slice(0, 200) : null,
234
- styles: extractStyles(element),
235
- images: element.tagName === 'IMG' ? { src: element.src, alt: element.alt, naturalWidth: element.naturalWidth, naturalHeight: element.naturalHeight } : null,
236
- childCount: children.length,
237
- children: children.slice(0, 20).map(c => walk(c, depth + 1)).filter(Boolean)
238
- };
239
- }
240
- return JSON.stringify(walk(el, 0), null, 2);
241
- })('SELECTOR');
242
- ```
243
-
244
- 3. **Extract multi-state styles** — capture before AND after trigger states
245
- 4. **Extract real content** — all text, alt, aria labels
246
- 5. **Identify assets** — which downloaded images/videos/icons
247
- 6. **Assess complexity** — split if necessary
248
-
249
- ### Step 2: Write Component Spec File
250
-
251
- Template at `docs/research/components/<component-name>.spec.md`:
252
-
253
- ```markdown
254
- # <ComponentName> Specification
255
-
256
32
  ## Overview
257
- - **Target file:** `src/components/<ComponentName>.tsx`
258
- - **Screenshot:** `docs/design-references/<screenshot-name>.png`
259
- - **Interaction model:** <static | click-driven | scroll-driven | time-driven>
260
-
261
- ## DOM Structure
262
- <hierarchy>
263
-
264
- ## Computed Styles (exact values)
265
- ### Container
266
- - display, padding, maxWidth, etc.
267
-
268
- ### <Child element>
269
- - every relevant property
270
-
271
- ## States & Behaviors
272
- ### <Behavior name>
273
- - **Trigger:** <exact mechanism>
274
- - **State A (before):** CSS values
275
- - **State B (after):** CSS values
276
- - **Transition:** transition CSS
277
- - **Implementation approach:** <CSS transition | IntersectionObserver | etc.>
278
33
 
279
- ## Assets
280
- - Background/overlay images with paths
281
- - Icons used from icons.tsx
34
+ Reverse-engineer a target URL into a working Next.js + shadcn/ui + Tailwind clone. The skill is **foreman-style**: extract a section, write a spec file, dispatch a builder agent in a worktree, move on to the next section. Extraction is meticulous (computed CSS, real assets, both static and behavioral) — building runs in parallel. Detailed principles, scripts, and templates live in [`references.md`](references.md).
282
35
 
283
- ## Text Content (verbatim)
284
- <copy-pasted from live site>
36
+ ## Process
285
37
 
286
- ## Responsive Behavior
287
- - Desktop (1440px): <layout>
288
- - Tablet (768px): <changes>
289
- - Mobile (390px): <changes>
290
- - Breakpoint: ~<N>px
291
- ```
292
-
293
- ### Step 3: Dispatch Builders
294
-
295
- **Simple section** (1-2 sub-components): One builder agent.
296
- **Complex section** (3+ sub-components): Break up. One agent per sub-component + one for wrapper.
297
-
298
- Each builder receives:
299
- - Full spec file contents inline
300
- - Path to section screenshot
301
- - Which shared components to import
302
- - Target file path
303
- - Instruction to verify `npx tsc --noEmit`
304
-
305
- **Don't wait** — as soon as one builder is dispatched, move to next section extraction.
306
-
307
- ### Step 4: Merge
308
-
309
- As agents complete: merge worktree branches, verify build passes, fix conflicts intelligently.
310
-
311
- ## Phase 4: Page Assembly
312
-
313
- Wire everything together in `src/app/page.tsx`:
314
- - Import all section components
315
- - Implement page-level layout (scroll containers, z-index)
316
- - Connect real content to component props
317
- - Implement page-level behaviors (scroll-snap, smooth scroll, theme transitions)
318
- - Verify `npm run build` passes
319
-
320
- ## Phase 5: Visual QA Diff
321
-
322
- Take side-by-side screenshots with original. Compare section by section at 1440px AND 390px. For each discrepancy: re-extract, update spec, fix component. Test all interactive behaviors.
323
-
324
- ## Pre-Dispatch Checklist
325
-
326
- Before dispatching ANY builder:
327
- - [ ] Spec file written with ALL sections filled
328
- - [ ] Every CSS value is from `getComputedStyle()`, not estimated
329
- - [ ] Interaction model identified and documented
330
- - [ ] All states captured (not just default)
331
- - [ ] Scroll/hover triggers with before/after/transition recorded
332
- - [ ] All images identified including overlays
333
- - [ ] Responsive behavior documented
334
- - [ ] Text content verbatim
335
- - [ ] Builder prompt ≤150 lines
38
+ 1. **Pre-flight** — Chrome MCP available, Next.js + shadcn scaffold builds clean, output dirs exist.
39
+ 2. **Phase 1 — Reconnaissance** — full-page screenshots (desktop + mobile), global extraction (fonts, colors, favicons), mandatory interaction sweep (scroll, click, hover, responsive), page topology map.
40
+ 3. **Phase 2 — Foundation build** — fonts, `globals.css`, TypeScript types, SVG icons, downloaded assets. Sequential, must compile.
41
+ 4. **Phase 3 — Component spec & dispatch** — for each section: extract DOM + computed CSS + states + content + assets → write `docs/research/components/<name>.spec.md` → dispatch builder agent with full spec inline. Don't wait between sections.
42
+ 5. **Phase 4 — Page assembly** — wire components in `src/app/page.tsx`, implement page-level behaviours (scroll-snap, smooth scroll, theme transitions). Build must pass.
43
+ 6. **Phase 5 — Visual QA diff** — side-by-side screenshots vs original at 1440px and 390px. Re-extract on discrepancies.
336
44
 
337
45
  ## Output Format
338
46
 
339
- - Every builder dispatches with an inline spec (not a file reference)
340
- - Every commit keeps `npm run build` green
341
- - Final report structure:
342
- - Total sections built: N
343
- - Total components created: N
344
- - Total spec files written: N (must match components)
345
- - Total assets downloaded: N
346
- - Build status: PASS/FAIL
347
- - Visual QA discrepancies: list
348
- - Do NOT include: vague status like "mostly done", builders dispatched without spec files, or estimated CSS values
349
- - Do NOT merge with red builds
350
- - Do NOT skip responsive extraction
351
-
352
- ## Workflow
47
+ ```
48
+ Total sections built: N
49
+ Total components created: N
50
+ Total spec files written: N (must match component count)
51
+ Total assets downloaded: N (images / videos / SVGs / fonts)
52
+ Build status: PASS | FAIL
53
+ Visual QA discrepancies: <list of remaining diffs>
54
+ ```
353
55
 
354
- 1. Read the user request and extract key parameters.
355
- 2. Execute the skill logic as described in the Overview.
356
- 3. Return output in the format specified below.
56
+ Do NOT include: vague status like "mostly done", builders dispatched without spec files, or estimated CSS values.
357
57
 
358
58
  ## Examples
359
59
 
360
- ### Happy Path
361
- **Input:** "clone https://linear.app"
362
-
363
- **Expected behavior:**
364
- 1. Pre-flight: verify Chrome MCP, base Next.js+shadcn scaffold
365
- 2. Reconnaissance: full-page screenshots, global extraction (fonts/colors/favicons), interaction sweep
366
- 3. Foundation build: update layout.tsx fonts, globals.css colors, icons.tsx, download assets
367
- 4. For each section top-to-bottom: extract CSS via getComputedStyle, write spec file, dispatch builder in worktree
368
- 5. Merge branches as builders complete, keep build green
369
- 6. Visual QA diff at desktop + mobile
370
- 7. Report with component counts, asset counts, build status
371
-
372
- ### Edge Case: Missing Chrome MCP
373
- **Input:** "clone this site: https://example.com"
374
-
375
- **Expected behavior:** STOP immediately. Respond: "Chrome MCP not available. Enable it first — this skill requires browser automation to extract computed styles and screenshots. Without it, I'd be guessing from HTML which produces bad clones."
376
-
377
- ### Edge Case: Scroll-Driven Site Mistaken for Click-Driven
378
- **Input:** User asks to clone a site with scroll-driven tabs
379
-
380
- **Expected behavior:** During interaction sweep, scroll BEFORE clicking. If content switches on scroll, document as "INTERACTION MODEL: scroll-driven with IntersectionObserver". Do NOT build click-based tabs.
381
-
382
- ### Edge Case: Builder Prompt Too Long
383
- **Input:** (Extracting a complex section with 4 card variants)
60
+ **Happy path** — `clone https://linear.app` → reconnaissance → foundation → spec each section → dispatch builders → assemble → visual QA. ~6 phases, parallel where possible.
384
61
 
385
- **Expected behavior:** Check the 150-line rule. If spec exceeds it, split: one builder per card variant + one for the section wrapper. Do NOT override with "it's all related."
62
+ **Edge case missing Chrome MCP** STOP immediately and tell the user to enable it. Without browser automation we'd be guessing from HTML, which produces bad clones.
386
63
 
387
- ### Negative Test
388
- **Input:** "Design a new landing page for our Rihal product"
64
+ **Edge case — scroll-driven site** — during interaction sweep, scroll BEFORE clicking. If content switches on scroll, document as "INTERACTION MODEL: scroll-driven (IntersectionObserver)" and do NOT build click-based tabs. This is the #1 expensive mistake.
389
65
 
390
- **Expected behavior:** Stay silent. This is original design worknot cloning. Redirect: "This needs original design invoke Layla (rihal-agent-layla) for UX or Bilal (rihal-agent-bilal) for direct build. I clone existing sites, not create new ones."
66
+ **Negative original design request**"Design a new landing page" is not a clone. Redirect to Layla (UX) or Hanzla (direct build).
391
67
 
392
- ## What NOT to Do
68
+ ## Memory Bank Hooks
393
69
 
394
- - Don't build click-based tabs when the original is scroll-driven
395
- - Don't extract only the default state of tabbed content
396
- - Don't miss overlay/layered images
397
- - Don't build HTML mockups for content that's actually videos/Lottie/canvas
398
- - Don't approximate CSS classes — extract exact values
399
- - Don't build monolithic commits
400
- - Don't reference external docs from builder prompts — inline everything
401
- - Don't skip asset extraction
402
- - Don't give a builder too much scope
403
- - Don't bundle unrelated sections into one agent
404
- - Don't skip responsive extraction at 1440/768/390
405
- - Don't forget smooth scroll libraries (Lenis, Locomotive)
406
- - Don't dispatch builders without a spec file
70
+ - **Reads:** `package.json` and existing `src/` to detect scaffold; `.rihal/memory/project/stack.md` if present (records the stack used)
71
+ - **Writes:** `docs/research/` (artefacts, persistent), `docs/design-references/` (screenshots), nothing in `.rihal/memory/` directly
407
72
 
408
- ## Completion Report
73
+ ## Detailed reference
409
74
 
410
- - Total sections built: N
411
- - Total components created: N
412
- - Total spec files written: N
413
- - Total assets downloaded (images/videos/SVGs/fonts): N
414
- - Build status: `npm run build` result
415
- - Visual QA results: any remaining discrepancies
416
- - Any known gaps or limitations
75
+ See [`references.md`](references.md) for: the 9 guiding principles, the asset discovery script, the CSS extraction script, the component spec template, the pre-dispatch checklist, and the "what NOT to do" list.