From 1098f97c05c42e14ddacb7c2ce7a847c9fde3460 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Tue, 21 Jul 2026 18:38:27 +0700 Subject: [PATCH] =?UTF-8?q?fix:=20remove=20duplicate=20clean-code.md=20?= =?UTF-8?q?=E2=80=94=20only=20keep=20the=20symlink=20to=20kana-best-practi?= =?UTF-8?q?ce-engineering?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/skills/clean-code.md | 58 ------------------------------------ 1 file changed, 58 deletions(-) delete mode 100644 .claude/skills/clean-code.md diff --git a/.claude/skills/clean-code.md b/.claude/skills/clean-code.md deleted file mode 100644 index 1310aa6..0000000 --- a/.claude/skills/clean-code.md +++ /dev/null @@ -1,58 +0,0 @@ ---- -name: clean-code -description: Clean Code, Clean Architecture, SOLID principles untuk proyek Asepharyana Hub ---- - -# Clean Code — Asepharyana Hub - -## Prinsip Dasar - -### 1. Naming -- **Gunakan nama yang mengungkapkan intensi**: `calculateTotal`, `fetchAnimeData`, `ImageCacheRepository` — bukan `calc`, `getData`, `Repo`. -- **Boolean prefix** dengan `is`, `has`, `should`: `isHealthy`, `hasPoster`, `shouldRetry`. -- **Hindari singkatan** kecuali sangat umum (`config`, `url`, `db`). - -### 2. Fungsi -- **Satu fungsi = satu tanggung jawab**. Max 20 baris. -- **Nama fungsi sebagai kata kerja**: `validateToken()`, `cacheImage()`. -- **Parameter minimal**: max 3 parameter. Lebih dari itu bungkus jadi struct/object. - -### 3. Clean Architecture Layers - -``` -Domain → Entities, Repository traits, Error enums -Application → Use cases -Infrastructure → Implementasi konkret (SeaORM, Redis, HTTP clients) -Presentation → Axum handlers, DTOs, middleware -``` - -Dependency rule: **kode layer dalam tidak tahu tentang layer luar**. Domain gak import framework. - -### 4. Error Handling -- **Gunakan `thiserror`** untuk domain errors, bukan `anyhow` untuk library code. -- **`anyhow` hanya untuk** binary/app entry point dan test. -- **Convert domain errors ke HTTP** di presentation layer, bukan di use case. - -### 5. Testing -- **TDD mindset**: tulis test sebelum implementasi untuk logic bisnis. -- **Unit test untuk use case + domain** (tanpa infra). -- **Integration test untuk repository** (dengan test container). -- **Mock trait**, bukan struct konkret. - -## Untuk Proyek Ini - -### Scraper Service (Rust) -- `src/domain/` — tipe data murni, trait, error — **tanpa framework** -- `src/application/` — use cases, orchestrasi, **tanpa HTTP** -- `src/infrastructure/` — implementasi repository, cache, HTTP client -- `src/presentation/` — handler Axum, routing, middleware - -### Event-Driven (Dapr + NATS) -- Event schema pake CloudEvents format -- Topic naming: `hub..` (e.g. `hub.image.cached`) -- Handler hanya untuk satu tipe event, pisah file per domain - -### Infra Config (YAML) -- Satu compose file per service -- Networking via `app-shared-net` -- Image tag selalu `sha-`, bukan `latest` di production