# acaba ai refactor'u 1 dakikaya indirebilir mi

**Demo:** VS Code'un yetişmeye çalışmasını izle (video Türkçe, hız kaosunu göreceksin):

{% embed url="<https://www.youtube.com/watch?v=bcHBxW03g2Y>" %}

## 1. Problem (bu sen misin?)

Refactoring minimum 20-30 dakika sürüyor. Telegram botumda function'lar `features/` klasöründe her yere dağılmış—transcription, text-to-speech, compression, translation hepsi karışık. Yapı yok.

**Refactoring sorunun yoksa → buradan çık.**

## 2. Gereksinimler (bunları yapabilir misin?)

Denemeden önce:

* **Git version control** (rollback için zorunlu)
* **TypeScript projesi** (TS-morph bunu gerektirir)
* **TS-morph kurulu** (`npm install ts-morph`)
* **AI erişimi** (Claude/ChatGPT/Cursor)

**Git yok mu?** Risk alma. Geri alma yok = potansiyel felaket.

**TypeScript değil mi?** Bu çalışmaz. TS-morph TypeScript'e özel.

## 3. Sonuç (sana çok kaotik mi?)

AI'a dedim: "ts-morph kullan, features → actions taşı, action type'a göre düzenle"

**1 dakikada olanlar:**

* AI ts-morph script'leri yazdı
* Function'ları taşıdı: `compressFromTelegram()` → `actions/save-text/`
* Function'ları taşıdı: `transcribeFromHammerspoon()` → `actions/save-media/`
* Function'ları taşıdı: `translateText()` → `actions/save-text/`
* Tüm codebase'de her import'u güncelledi
* Her yerdeki tüm referansları yeniden adlandırdı
* Yeni klasör yapısı oluşturdu

**Kaos:**

* VS Code yetişemedi (restart gerekti)
* Saniyeler içinde yüzlerce dosya değişti
* Git diff temiz refactor gösterdi
* Sıfır hata
* Sıfır manuel edit

**"Çok kaotik" korkutucu geliyorsa → bu senin için değil.** Educational seeker'lar buradan çıkar.

Discovery explorer'lar okumaya devam eder.

## 4. Nasıl (pattern)

**TS-morph** = TypeScript compiler API. Kod yapısını anlar (function'lar, import'lar, referanslar, dependency'ler). Regex değil. Gerçek AST manipülasyonu.

**Pattern:**

```
Sen: "ts-morph kullan, X'i Y'ye taşı, tüm referansları güncelle"
AI: script yazar → çalıştırır → git diff ile verify eder
Sen: değişiklikleri review et veya rollback yap
```

**AI'ın oluşturduğu örnek script:**

```typescript
import { Project } from 'ts-morph'

const project = new Project({ tsConfigFilePath: './tsconfig.json' })

// Kaynak dosyayı bul
const sourceFile = project.getSourceFile('src/features/text.ts')
const targetFile = project.getSourceFile('src/actions/save-text.ts')

// Function'ı taşı
const fn = sourceFile.getFunction('compressFromTelegram')
fn.moveTo(targetFile)

// Tüm referanslar otomatik güncellenir
project.save()
```

AI'a ts-morph kullanmasını söyle. AI script oluşturur. Script kodu taşır. Tüm referanslar otomatik güncellenir.

**Kritik güvenlik ağı:** Git rollback. Patlarsa → `git reset --hard`. Sıfır risk.

## 5. Neden Önemli

**Eski gerçeklik:** Refactoring = 20-30 dakika → insanlar mimariyi önceden planlar (haklı overhead)

**Yeni olasılık:** Refactoring = 1 dakika → design pattern'leri hıza göre seç, güvenliğe göre değil

Pattern oluşurken çıkar (önceden planlanmaz). Refactoring ucuzlaşır → mimari keşif yapılabilir olur.

## Dene

Kendin dene. Ne kadar hızlı olduğunu paylaş. Ölçekte ne bozulduğunu bul.

**Son filtre:** Buraya kadar geldiysen discovery explorer'sın. Educational seeker'lar çoktan çıktı.

**Benim promptum:**

```md
**MANDATORY: Write tool + bun for TypeScript discovery**
  Write to `/tmp/attention-discover-{domain}-{keyword}-{uid}.ts` + run with `bun` (we have A LOT tmp/scripts so NEVER use short names)
  - Use `ts-morph` for analysis (tsconfig required for path aliases)
  - File Imports (dependencies IN)
  - Importers (dependents OUT)
  - Exports (API surface)
  - All Identifiers (params, vars, calls, props)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yemreak.com/claude-code/acaba-ai-refactoru-1-dakikaya-indirebilir-mi.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
