# acaba ai kendi arama agentını yapabilir mi

**Demo:** Hook'un Explore'u engelleyip attention-agent'ı çağırışını izle (video Türkçe, workflow görülüyor):

{% embed url="<https://youtu.be/hxseDqGaGSg>" %}

## 1. Problem (bu sen misin?)

Claude Code'un Explore agentı yavaş ve yanlış yerlere bakıyor. "X nerede implement edilmiş?" dediğinde grep-based arama yapıyor, project graph anlamıyor, alakasız sonuçlar veriyor.

**Explore ile sorunun yoksa → buradan çık.**

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

Denemeden önce:

* **Claude Code kullanıyor olmalısın** (hook sistemi için)
* **TypeScript projesi** (TS-morph için)
* **TS-morph kurulu** (`npm install ts-morph`)
* **Hook yazmayı bilmeli** (veya öğrenmeye açık)

**Claude Code kullanmıyorsan** → bu pattern çalışmaz.

**Hook nedir bilmiyorsan** → önce dokümantasyonu oku: <https://docs.claude.com/en/docs/claude-code/hooks>

## 3. Sonuç (çok teknik mi?)

Explore'u custom attention-agent ile değiştirdim.

**Ne değişti:**

* Explore engellendi (PreToolUse hook)
* Attention-agent devreye girdi
* TS-morph script'leri → dosya yollarını buldu
* Main agent yolları okudu
* Context kaybı yok (10x hızlı)

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

Discovery explorer'lar okumaya devam eder.

## 4. Nasıl (hook + agent pattern)

### Hook: Explore'u engelle

Claude Code'da `.claude/hooks/` altında PreToolUse hook oluştur:

```markdown
# PreToolUse Hook: Explore yerine attention-agent kullan

Ne zaman: Task tool subagent_type="Explore"
Aksiyon: Context inject et

"Explore kapalı. attention-agent + ts-morph kullan.

Workflow:
1. Sen (main) → attention-agent'a nereye bakacağını sor
2. Attention-agent → /tmp/attention-discover-{domain}-{keyword}-{uid}.ts yaz
3. Bun ile çalıştır
4. Sen (main) → yolları oku + karar ver

Sonuç: Context kaybı yok"
```

Hook dokümantasyonu: <https://docs.claude.com/en/docs/claude-code/hooks>

### Agent: Dosya yollarını bul

`.claude/agents/attention-agent.md` oluştur:

````markdown
---
name: attention-agent
description: Proje içinde dosya yollarını bulur (içerik değil)
tools: Write, Bash(bun)
model: haiku
---

# KURAL: Sadece yolları döndür

Protokol:
1. Task → domain keyword
2. /tmp/attention-discover-{domain}-{keyword}-{uid}.ts yaz
3. TS-morph: Imports, Importers, Exports, Identifiers
4. Bun ile çalıştır
5. Yolları döndür

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

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

const files = project.getSourceFiles()
  .filter(f => f.getFullText().includes(keyword))

console.log(JSON.stringify(
  files.map(f => ({
    path: f.getFilePath(),
    functions: f.getFunctions().map(fn => fn.getName()),
    imports: f.getImportDeclarations().map(i => i.getModuleSpecifierValue())
  })), null, 2
))
````

### Workflow

```
Sen: "Telegram handler nerede?"
  ↓
Main Agent: Explore kullanmayı deniyor
  ↓
PreToolUse Hook: Explore'u engelliyor
  ↓
Main Agent: attention-agent'ı çağırıyor
  ↓
Attention-Agent:
  - /tmp/attention-discover-messaging-telegram-{uid}.ts yazar
  - Bun ile çalıştırır
  - Yolları döndürür
  ↓
Main Agent: yolları okur → karar verir
```

## 5. Neden Önemli

**Context preservation:**

* Worker dosyaları okursa → main agent unutur
* Worker yolları döndürürse → main agent okur → hatırlar

**Hız:**

* TS-morph → AST (compiler API)
* Grep → regex (pattern matching)
* 10x fark

**Doğruluk:**

* Project graph → gerçek bağımlılıklar
* String search → yanlış eşleşmeler

## Dene

Kendin dene. Kendi attention-agent'ını yap. Hangi pattern'leri bulduğunu paylaş.

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


---

# 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-kendi-arama-agentini-yapabilir-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.
