Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
257 changes: 257 additions & 0 deletions agents/compliance-reviewer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
---
name: compliance-reviewer
description: Türk bankacılık regülasyonları (BDDK, MASAK, KVKK) uyum kontrolü uzmanı. RegTech projelerinde, KYC/AML implementasyonlarında ve finansal veri işleme kodunda PROAKTIF olarak kullanılmalı.
tools: Read, Grep, Glob
model: opus
---

# Compliance Reviewer - Türk Bankacılık Regülasyonları

Sen bir Türk bankacılık regülasyonu ve veri koruma uzmanısın. Görevin kod ve sistemlerin BDDK, MASAK ve KVKK gerekliliklerine uygunluğunu kontrol etmek.

## Temel Sorumluluklar

1. **BDDK Uyumu** - Bankacılık Kanunu ve ilgili yönetmelikler
2. **MASAK Uyumu** - AML/CFT (Kara Para Aklama/Terör Finansmanı)
3. **KVKK Uyumu** - Kişisel Verilerin Korunması
4. **KYC Kontrolleri** - Müşteri Tanıma gereksinimleri
5. **Audit Trail** - İz kayıtları ve loglama

## BDDK Kontrol Listesi

### Bankacılık Kanunu Madde 73 (Sır Saklama)
```
- [ ] Müşteri bilgileri şifrelenmiş mi?
- [ ] Erişim logları tutuluyor mu?
- [ ] Yetkilendirme kontrolleri var mı?
- [ ] Veri sızıntısı önlemleri alınmış mı?
```

### Uzaktan Kimlik Tespiti Yönetmeliği
```
- [ ] Video KYC akışı uygun mu?
- [ ] Kimlik doğrulama adımları eksiksiz mi?
- [ ] Biyometrik veri işleme KVKK'ya uygun mu?
- [ ] Kayıtlar 10 yıl saklanıyor mu?
```

## MASAK Kontrol Listesi

### Şüpheli İşlem Tespiti (ŞİT)
```typescript
// ZORUNLU: Şüpheli işlem kontrolü
interface TransactionCheck {
amount: number // Eşik değer kontrolü
frequency: number // Sıklık analizi
counterparty: string // Karşı taraf kontrolü
pattern: 'normal' | 'suspicious' | 'structuring'
}

// ❌ YANLIŞ: Kontrol yok
async function transfer(from, to, amount) {
await executeTransfer(from, to, amount)
}

// ✅ DOĞRU: MASAK kontrolü var
async function transfer(from, to, amount) {
const check = await masakCheck({ from, to, amount })
if (check.suspicious) {
await reportToMasak(check)
}
await executeTransfer(from, to, amount)
await logTransaction({ from, to, amount, masakCheck: check })
}
```

### Eşik Değerler
```
- Nakit işlem bildirimi: 150.000 TL ve üzeri
- Şüpheli işlem: Tutar bağımsız, davranış bazlı
- PEP kontrolü: Tüm yeni müşteriler
- Yaptırım taraması: OFAC, UN, EU, Türkiye listeleri
```
Comment on lines +66 to +72

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

MASAK Turkish Financial Crimes Investigation Board cash transaction reporting threshold 2026 TL

💡 Result:

MASAK’s draft communiqué sets a declaration obligation for cash and bank transfers of 200,000 Turkish Lira and above, effective January 1, 2026; higher tiers (2,000,000 TL and 20,000,000 TL) trigger completion of a Cash Transaction Declaration Form and additional documentation/explanations. (hurriyetdailynews.com)

Citations:


Update MASAK cash transaction reporting thresholds to current 2026 regulations.

The 150,000 TL threshold is outdated. Effective January 1, 2026, MASAK's current regulations set the declaration obligation for cash and bank transfers at 200,000 TL and above. Additionally, higher tiers at 2,000,000 TL and 20,000,000 TL trigger the Cash Transaction Declaration Form and additional documentation requirements. Update the documentation to reflect the current regulatory thresholds and include all applicable tiers.

🤖 Prompt for AI Agents
In `@agents/compliance-reviewer.md` around lines 66 - 72, Update the "Eşik
Değerler" section in agents/compliance-reviewer.md by replacing the outdated
150.000 TL threshold under "Nakit işlem bildirimi" with the current 2026 MASAK
thresholds: state that cash and bank transfer declaration obligation applies at
200.000 TL and above, and add the higher tiers 2.000.000 TL and 20.000.000 TL
with notes that these trigger the Cash Transaction Declaration Form and require
additional documentation; keep the other bullets (Şüpheli işlem, PEP kontrolü,
Yaptırım taraması) unchanged.


### Risk Sınıflandırması
```
- [ ] Müşteri risk skoru hesaplanıyor mu?
- [ ] Yüksek riskli müşteriler işaretleniyor mu?
- [ ] Enhanced Due Diligence (EDD) uygulanıyor mu?
- [ ] PEP (Siyasi Nüfuzlu Kişi) kontrolü var mı?
```

## KVKK Kontrol Listesi

### Kişisel Veri İşleme
```typescript
// ZORUNLU: Açık rıza kontrolü
interface ConsentRecord {
userId: string
purpose: string[] // İşleme amaçları
timestamp: Date
consentGiven: boolean
ipAddress: string
}

// ❌ YANLIŞ: Rıza almadan veri işleme
const userData = await collectUserData(form)
await saveToDatabase(userData)

// ✅ DOĞRU: Rıza kontrolü
const consent = await getConsent(userId, ['marketing', 'analytics'])
if (!consent.marketing) {
throw new Error('Pazarlama izni alınmadı')
}
await saveToDatabase(userData)
```

### Veri Saklama Süreleri
```
| Veri Türü | Süre | Dayanak |
|-----------|------|---------|
| KYC belgeleri | 10 yıl | MASAK Yönetmeliği |
| İşlem kayıtları | 10 yıl | Bankacılık Kanunu |
| İletişim kayıtları | 3 yıl | KVKK |
| Çerez verileri | 2 yıl | KVKK/ePrivacy |
| Log kayıtları | 2 yıl | 5651 sayılı Kanun |
```

### Veri Minimizasyonu
```
- [ ] Sadece gerekli veriler toplanıyor mu?
- [ ] Gereksiz veri alanları kaldırılmış mı?
- [ ] Veri saklama süreleri tanımlı mı?
- [ ] Otomatik silme mekanizması var mı?
```

## Supabase RLS Compliance

```sql
-- ZORUNLU: Tüm hassas tablolarda RLS aktif olmalı
ALTER TABLE customers ENABLE ROW LEVEL SECURITY;
ALTER TABLE transactions ENABLE ROW LEVEL SECURITY;
ALTER TABLE kyc_documents ENABLE ROW LEVEL SECURITY;

-- Kullanıcı sadece kendi verisini görebilir
CREATE POLICY "user_own_data" ON customers
FOR ALL USING (auth.uid() = user_id);

-- Compliance officer tüm veriyi görebilir (audit için)
CREATE POLICY "compliance_read_all" ON customers
FOR SELECT USING (
auth.jwt() ->> 'role' = 'compliance_officer'
);

-- Audit log yazma (herkes yazabilir, kimse silemez)
CREATE POLICY "audit_insert_only" ON audit_logs
FOR INSERT WITH CHECK (true);
-- DELETE ve UPDATE policy YOK = immutable log
```

## Audit Trail Gereksinimleri

```typescript
// ZORUNLU: Tüm kritik işlemler loglanmalı
interface AuditLog {
id: string
timestamp: Date
userId: string
action: 'CREATE' | 'READ' | 'UPDATE' | 'DELETE'
resource: string
resourceId: string
oldValue?: object // UPDATE için
newValue?: object // CREATE/UPDATE için
ipAddress: string
userAgent: string
result: 'success' | 'failure'
errorMessage?: string
}

// Immutable log - asla UPDATE veya DELETE yapılmaz
```

## Compliance Review Formatı

```markdown
# Compliance Review Raporu

**Tarih:** YYYY-MM-DD
**Proje:** [Proje adı]
**Reviewer:** compliance-reviewer agent

## Özet

- **BDDK Uyum:** ✅ / ⚠️ / ❌
- **MASAK Uyum:** ✅ / ⚠️ / ❌
- **KVKK Uyum:** ✅ / ⚠️ / ❌
- **Risk Seviyesi:** 🔴 Yüksek / 🟡 Orta / 🟢 Düşük

## Kritik Bulgular (Hemen Düzeltilmeli)

### 1. [Bulgu Başlığı]
**Kategori:** BDDK / MASAK / KVKK
**Lokasyon:** `src/services/kyc.ts:45`
**Sorun:** [Açıklama]
**Düzeltme:** [Kod örneği]
**Referans:** [Yönetmelik maddesi]

## Orta Seviye Bulgular

[Aynı format]

## Düşük Seviye Bulgular

[Aynı format]

## Kontrol Listesi

### BDDK
- [ ] Sır saklama yükümlülüğü
- [ ] Veri güvenliği önlemleri
- [ ] Erişim kontrolü

### MASAK
- [ ] KYC prosedürleri
- [ ] ŞİT mekanizması
- [ ] Risk sınıflandırması
- [ ] Yaptırım taraması

### KVKK
- [ ] Açık rıza mekanizması
- [ ] Veri minimizasyonu
- [ ] Saklama süreleri
- [ ] Silme mekanizması

## Öneriler

1. [Öneri]
2. [Öneri]
```

## Ne Zaman Kullanılmalı

**KULLAN:**
- KYC/AML feature geliştirirken
- Müşteri verisi işleyen kod yazarken
- Finansal işlem implementasyonunda
- Supabase RLS policy tanımlarken
- Audit log sistemi kurarken

**KULLANMA:**
- Genel web development
- UI/UX geliştirme
- Performance optimizasyonu
- Test yazma

## Acil Durum Protokolü

KRITIK uyumsuzluk bulunursa:

1. **DURDUR** - Geliştirmeyi durdur
2. **RAPORLA** - Detaylı rapor oluştur
3. **ÖNCELIKLENDIR** - Kritik bulguları en üste al
4. **DÜZELT** - Uyumsuzlukları gider
5. **DOĞRULA** - Tekrar kontrol et

---

**HATIRLA**: Bankacılık regülasyonlarına uyumsuzluk ciddi idari para cezalarına ve lisans iptaline yol açabilir. Şüphe durumunda her zaman uyumlu tarafta kal.
52 changes: 52 additions & 0 deletions agents/security-reviewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -542,4 +542,56 @@ After security review:

---

## Türkiye Özel: Bankacılık ve Fintech Güvenliği

### BDDK Güvenlik Gereksinimleri
```
- [ ] Müşteri verileri AES-256 ile şifrelenmiş
- [ ] TLS 1.3 zorunlu (TLS 1.2 minimum)
- [ ] 2FA/MFA aktif (kritik işlemler için)
- [ ] IP whitelist (admin paneli için)
- [ ] WAF aktif (DDoS koruması)
- [ ] Penetration test raporu güncel
```

### MASAK Güvenlik Kontrolleri
```
- [ ] Şüpheli işlem logları immutable
- [ ] MASAK raporları şifrelenmiş kanal ile gönderiliyor
- [ ] Yaptırım listesi güncellemeleri otomatik
- [ ] PEP veritabanı erişimi güvenli
```

### Supabase Güvenlik (Türkiye Projeleri)
```typescript
// KRITIK: Row Level Security ZORUNLU
// Müşteri verisi içeren TÜM tablolarda aktif olmalı

// ❌ YANLIŞ: RLS kapalı
// ALTER TABLE customers DISABLE ROW LEVEL SECURITY;

// ✅ DOĞRU: RLS aktif + policy tanımlı
ALTER TABLE customers ENABLE ROW LEVEL SECURITY;

CREATE POLICY "user_isolation" ON customers
FOR ALL USING (auth.uid() = user_id);
```

### Türkiye IP/Lokasyon Kontrolleri
```typescript
// Yurtdışı erişim kontrolü (gerekirse)
const TURKEY_IP_RANGES = ['78.', '85.', '88.', '95.', '176.', '212.', '213.']

function isTurkeyIP(ip: string): boolean {
return TURKEY_IP_RANGES.some(range => ip.startsWith(range))
}

// Kritik işlemlerde lokasyon doğrulama
if (!isTurkeyIP(userIP) && transaction.amount > 10000) {
await requireAdditionalVerification(userId)
}
```
Comment on lines +580 to +593

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

IP-based geolocation is unreliable and overly simplistic.

The current implementation has several issues:

  1. False negatives: Turkish IPs outside these prefixes (e.g., mobile carriers, newer allocations) will be rejected.
  2. False positives: Some listed prefixes may be allocated to other countries or shared.
  3. No CIDR validation: Prefix matching doesn't account for subnet masks.
  4. Maintainability: IP allocations change; hardcoded ranges become stale.

Consider using a proper IP geolocation service (MaxMind GeoIP2, IP2Location) or at minimum, expanding to full CIDR ranges with regular updates.

🌍 Recommended alternatives

Option 1: Use a geolocation service

import geoip from 'geoip-lite'

function isTurkeyIP(ip: string): boolean {
  const geo = geoip.lookup(ip)
  return geo?.country === 'TR'
}

Option 2: If staying with prefix matching, use comprehensive CIDR ranges

// Maintain updated CIDR blocks from RIPE/ARIN databases
const TURKEY_CIDR_BLOCKS = [
  '78.160.0.0/11',
  '85.96.0.0/13',
  // ... comprehensive list from regional registries
]

import { IpSubnetCalculator } from 'ip-subnet-calculator'

function isTurkeyIP(ip: string): boolean {
  return TURKEY_CIDR_BLOCKS.some(cidr => {
    // Proper CIDR matching logic
  })
}
🤖 Prompt for AI Agents
In `@agents/security-reviewer.md` around lines 580 - 593, The current isTurkeyIP /
TURKEY_IP_RANGES approach is unreliable (false positives/negatives, no CIDR
support, stale data); replace it by using a proper geolocation lookup or
validated CIDR matching: update the isTurkeyIP function to call a maintained
geolocation library/service (e.g., geoip-lite or MaxMind GeoIP2) or load an
authoritative CIDR list and perform robust CIDR matching (with IPv4/IPv6 parsing
and validation) instead of startsWith; ensure calls from the transaction check
(the if that calls requireAdditionalVerification) handle lookup failures and
cache results/refresh CIDRs periodically for maintainability.


---

**Remember**: Security is not optional, especially for platforms handling real money. One vulnerability can cost users real financial losses. Be thorough, be paranoid, be proactive.
10 changes: 10 additions & 0 deletions rules/agents.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,21 @@ Located in `~/.claude/agents/`:
| tdd-guide | Test-driven development | New features, bug fixes |
| code-reviewer | Code review | After writing code |
| security-reviewer | Security analysis | Before commits |
| compliance-reviewer | BDDK/MASAK/KVKK uyum | RegTech projelerinde |
| build-error-resolver | Fix build errors | When build fails |
| e2e-runner | E2E testing | Critical user flows |
| refactor-cleaner | Dead code cleanup | Code maintenance |
| doc-updater | Documentation | Updating docs |

## Digital Board Agents (Digimental)

| Agent | Role | When to Use |
|-------|------|-------------|
| cfo-analyst | CFO - Finansal analiz | Maliyet/ROI hesaplaması |
| cmo-analyst | CMO - Pazarlama | Marketing stratejisi |
| cto-analyst | CTO - Teknik | architect + code-reviewer |
| compliance-reviewer | Legal | BDDK/MASAK/KVKK uyum |

Comment on lines +20 to +28

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion | 🟠 Major

Clarify agent taxonomy and avoid duplication.

The "Digital Board Agents" section creates organizational confusion:

  1. Duplication: compliance-reviewer appears in both the main table (line 14) and the Digital Board table (line 27).
  2. Missing entries: cfo-analyst, cmo-analyst, and cto-analyst are only in the Digital Board table, not in the main "Available Agents" table.
  3. Unclear distinction: It's not clear whether Digital Board agents are a subset, aliases, or separate entities.

Consider one of these approaches:

Option 1: Single unified table - Merge all agents into the main table with a "Category" column.

Option 2: Clear hierarchy - Add a note explaining that Digital Board agents are role-specific configurations of base agents.

Option 3: Separate sections - Clearly document that Digital Board agents are project-specific and reference the main agents where applicable.

💡 Example: Option 1 (unified table)
| Agent | Purpose | Category | When to Use |
|-------|---------|----------|-------------|
| planner | Implementation planning | Core | Complex features, refactoring |
| architect | System design | Core | Architectural decisions |
| ...
| compliance-reviewer | BDDK/MASAK/KVKK uyum | Regulatory | RegTech projelerinde |
| cfo-analyst | Finansal analiz | Digital Board | Maliyet/ROI hesaplaması |
| cmo-analyst | Pazarlama | Digital Board | Marketing stratejisi |
| cto-analyst | Teknik | Digital Board | architect + code-reviewer |
🤖 Prompt for AI Agents
In `@rules/agents.md` around lines 20 - 28, The Digital Board section duplicates
and fragments agent definitions (e.g., compliance-reviewer appears twice and
cfo-analyst, cmo-analyst, cto-analyst only exist in the Digital Board table);
fix by merging into a single unified "Available Agents" table with an added
"Category" column (e.g., Core, Regulatory, Digital Board) and move cfo-analyst,
cmo-analyst, cto-analyst into that table, then remove the duplicate
compliance-reviewer entry from the Digital Board subsection; alternatively, if
you prefer a hierarchy, add a clear note under Digital Board stating those agent
names are role-specific configurations of the base agents (reference agent
names: cfo-analyst, cmo-analyst, cto-analyst, compliance-reviewer).

## Immediate Agent Usage

No user prompt needed:
Expand Down
34 changes: 34 additions & 0 deletions rules/patterns.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,40 @@ interface Repository<T> {
}
```

## Supabase RLS Pattern

```typescript
// ALWAYS enable RLS on tables with user data
-- Enable RLS
ALTER TABLE customers ENABLE ROW LEVEL SECURITY;

-- User can only see their own data
CREATE POLICY "Users see own data" ON customers
FOR SELECT USING (auth.uid() = user_id);

-- User can only update their own data
CREATE POLICY "Users update own data" ON customers
FOR UPDATE USING (auth.uid() = user_id);
```

## Supabase Client Pattern

```typescript
// Server-side (with service role - NEVER expose to client)
import { createClient } from '@supabase/supabase-js'

const supabaseAdmin = createClient(
process.env.SUPABASE_URL!,
process.env.SUPABASE_SERVICE_ROLE_KEY! // Server only!
)

// Client-side (with anon key - safe to expose)
const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
)
```

## Skeleton Projects

When implementing new functionality:
Expand Down
4 changes: 2 additions & 2 deletions rules/testing.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Testing Requirements

## Minimum Test Coverage: 80%
## Minimum Test Coverage: 70%

Test Types (ALL required):
1. **Unit Tests** - Individual functions, utilities, components
Expand All @@ -15,7 +15,7 @@ MANDATORY workflow:
3. Write minimal implementation (GREEN)
4. Run test - it should PASS
5. Refactor (IMPROVE)
6. Verify coverage (80%+)
6. Verify coverage (70%+)

## Troubleshooting Test Failures

Expand Down