---
name: devdna
description: Activate DevDNA team memory system — reads and maintains team coding standards, architectural decisions, developer profiles, and engineering habits in .devdna/ directory. Use when writing code, reviewing, onboarding, or making architectural decisions.
---

# DevDNA — Team Memory System

You have access to a persistent team memory system stored in `.devdna/state/`. This memory makes you aware of how this team builds software.

## Memory Files

Before writing code, reviewing, or answering architecture questions, read the relevant memory files:

| File | Purpose | When to Read |
|------|---------|-------------|
| `.devdna/state/team-memory.md` | Coding standards, tech stack, conventions | Before writing any code |
| `.devdna/state/team-habits.md` | PR rules, deploy process, test requirements | Before reviewing or suggesting processes |
| `.devdna/state/team-insights.md` | Lessons from past bugs and incidents | Before touching risky areas |
| `.devdna/state/decisions.md` | Architectural decisions with reasoning | Before proposing architecture changes |
| `.devdna/state/developers/<name>.md` | Developer strengths and patterns | When helping a specific developer |
| `.devdna/state/memory.md` | Personal user preferences | Always |
| `.devdna/state/insights.md` | Personal lessons learned | When relevant |
| `.devdna/state/habits.md` | Personal recurring patterns | Always |

## How to Use

### When Writing Code
1. Read `team-memory.md` for coding standards
2. Follow those standards (naming, linting, test requirements)
3. If standards conflict with the request, mention the conflict

### When Reviewing Code
1. Read `team-memory.md` + `team-habits.md` + `team-insights.md`
2. Check code against team standards
3. Flag violations with references to the specific rule
4. Warn about patterns that caused issues before (from insights)

### When Making Architecture Decisions
1. Read `decisions.md` for past decisions
2. Check if the new proposal contradicts existing decisions
3. If it does, explain the conflict and ask for confirmation

### When Onboarding
1. Read all memory files
2. Summarize: project structure, team rules, key decisions, watch-out areas
3. Tailor to the new developer's background

## Updating Memory

When the user teaches you something new about the team, update the appropriate file:

- Team coding standard → append to `team-memory.md`
- Team process/rule → append to `team-habits.md`
- Lesson from a bug → append to `team-insights.md`
- Architecture decision → append to `decisions.md` with reasoning
- Developer info → create/update `developers/<name>.md`
- Personal preference → append to `memory.md`

Format: `- [YYYY-MM-DD] <entry text>`

## Confluence & Jira Erişimi

### Adım 1: Önce Hafızayı Kontrol Et

Confluence/Jira isteği geldiğinde **her zaman önce `team-memory.md`'yi oku** ve şu bilgileri ara:
- `Confluence space key`
- `Confluence URL`
- `Jira project key`
- `Jira URL`

**Bu bilgiler varsa doğrudan kullan** — kullanıcıya tekrar sorma.

### Adım 2: Bilgiler Yoksa Sor

Hafızada yoksa kullanıcıya sor:

> "Confluence space key'iniz nedir? (URL'deki /display/XXXX/ kısmı)"
> "Jira project key'iniz nedir? (branch isimlerinden çıkarılabilir, örn: feat/CRMFE-1234 → CRMFE)"

Aldığın cevabı `team-memory.md`'ye kaydet:
```
- [YYYY-MM-DD] Confluence space key: XXXXX
- [YYYY-MM-DD] Jira project key: XXXXX
```

**İpucu:** Kullanıcı yanlış key verirse (örn: "CMP" yerine "CRMFE" olması gerekiyorsa), git branch isimlerinden veya Jira API'den doğru key'i bulmayı dene:
```bash
# Git branch'lerden proje key'i çıkar:
git branch -a | grep -oP '[A-Z]+-\d+' | head -5 | grep -oP '^[A-Z]+' | sort -u
```

### Adım 3: Env Var Kontrolü

İstek yapmadan önce env var'ları kontrol et:
```bash
echo "CONFLUENCE_URL: ${CONFLUENCE_URL:-NOT_SET}" && echo "CONFLUENCE_TOKEN: ${CONFLUENCE_TOKEN:+SET}"
echo "JIRA_URL: ${JIRA_URL:-NOT_SET}" && echo "JIRA_TOKEN: ${JIRA_TOKEN:+SET}"
```

### Adım 4: API İsteği

Env var'lar set ise, Bash ile doğrudan API isteği at. URL'de `https://` yoksa ekle, her zaman `-L` (follow redirect) kullan:

**Confluence arama:**
```bash
curl -s -L -H "Authorization: Bearer $CONFLUENCE_TOKEN" \
  "https://${CONFLUENCE_URL#https://}/rest/api/content/search" \
  --data-urlencode "cql=space=SPACE_KEY AND text~\"aranacak kelime\"" \
  --data-urlencode "limit=10" \
  | python3 -c "import sys,json; data=json.load(sys.stdin); [print(f'- [{r[\"type\"]}] {r[\"title\"]}') for r in data.get('results',[])]"
```

**Confluence sayfa oluşturma:**
```bash
curl -s -L -X POST -H "Authorization: Bearer $CONFLUENCE_TOKEN" \
  -H "Content-Type: application/json" \
  "https://${CONFLUENCE_URL#https://}/rest/api/content" \
  -d '{"type":"page","title":"Başlık","space":{"key":"SPACE_KEY"},"body":{"storage":{"value":"<p>İçerik</p>","representation":"storage"}}}'
```

**Jira issue arama (--data-urlencode ile JQL):**
```bash
curl -s -L -H "Authorization: Bearer $JIRA_TOKEN" \
  "https://${JIRA_URL#https://}/rest/api/2/search" \
  --data-urlencode "jql=project=PROJECT_KEY AND status not in (Done,Closed,Resolved) ORDER BY updated DESC" \
  --data-urlencode "maxResults=10" \
  --data-urlencode "fields=key,summary,status,assignee,priority" \
  | python3 -c "import sys,json; data=json.load(sys.stdin); [print(f'- [{i[\"key\"]}] {i[\"fields\"][\"summary\"]} ({i[\"fields\"][\"status\"][\"name\"]})') for i in data.get('issues',[])]"
```

**Jira issue oluşturma:**
```bash
curl -s -L -X POST -H "Authorization: Bearer $JIRA_TOKEN" \
  -H "Content-Type: application/json" \
  "https://${JIRA_URL#https://}/rest/api/2/issue" \
  -d '{"fields":{"project":{"key":"PROJECT_KEY"},"summary":"Başlık","description":"Açıklama","issuetype":{"name":"Task"}}}'
```

### Hata Yönetimi

- **HTTP 302**: URL'de `https://` eksik — ekle ve `-L` kullan
- **"does not exist for field 'project'"**: Yanlış project key — git branch'lerden doğru key'i bul
- **HTTP 401**: Token geçersiz veya süresi dolmuş — kullanıcıya yeni token oluşturmasını söyle
- **Timeout**: VPN bağlantısını kontrol ettir

### Env Var'lar Set Değilse

Kullanıcıya kurulum talimatı ver:
```
Confluence/Jira erişimi için environment variable'ları set edin:

export CONFLUENCE_URL="https://confluence.your-company.com"
export CONFLUENCE_TOKEN="personal-access-token"
export JIRA_URL="https://jira.your-company.com"
export JIRA_TOKEN="personal-access-token"

Token: Confluence/Jira → Profil → Settings → Personal Access Tokens → Create
```

Alternatif olarak içeriği doğrudan yapıştırmasını öner.

## Important Rules

- Never fabricate memory — only use what's in the files
- If a file doesn't exist yet, that's fine — create it when needed
- Always reference which memory informed your suggestion
- Keep entries concise and actionable
- Initialize `.devdna/state/` directory structure if it doesn't exist
