Old CLAUDE.md was 700 lines — exceeded Anthropic 200-line recommendation,
adherence degraded under context pressure.
Refactor per research findings:
- CLAUDE.md 700 -> 97 lines (essential only, pointers to rules)
- .claude/rules/{backend,frontend,sql,git-pr,deploy}.md (NEW, path-scoped)
- ~/.claude/CLAUDE.md (NEW, 21 lines) — personal cross-project prefs
- memory/ — deleted 12 feedback files promoted to proper layer (CLAUDE.md
rules table, .claude/rules/, ~/.claude/CLAUDE.md). 7 remaining = workflow
details.
- .gitignore: !.claude/agents/, !.claude/rules/ exceptions
Total auto-loaded per session: 97 (CLAUDE.md) + 21 (~/.claude) = 118 lines
vs prior 700. Rules in .claude/rules/ load only when matching paths touched.
Resolves conflict no_self_review vs pre_push_review: now single rule in
git-pr.md Review workflow section (pre-push = local lint; post-push =
external Claude window posting as lekss361).
Code-reviewer feedback applied:
- paths: frontmatter added to git-pr.md
- Auto-merge scope blocked-list now includes .claude/rules/*.md changes
to prevent self-extending rules without human approval.
Co-authored-by: lekss361 <claudestars@proton.me>
102 lines
4.7 KiB
Markdown
102 lines
4.7 KiB
Markdown
---
|
||
paths:
|
||
- .claude/**
|
||
- .github/**
|
||
---
|
||
|
||
# Git + PR workflow
|
||
|
||
> Этот файл — manual reference из CLAUDE.md (auto-loaded для `.claude/**` и `.github/**` файлов). Если работаешь с code в backend/frontend — также явно открой этот файл при PR-related операциях.
|
||
|
||
## Branch + PR (MANDATORY)
|
||
|
||
```
|
||
1. git checkout -b feat/<scope> # или fix/ refactor/ docs/ chore/ perf/
|
||
2. [worker делает код, staged]
|
||
3. code-reviewer subagent на staged changes (pre-push)
|
||
4. main session: git commit -m "feat(scope): ..."
|
||
5. git push -u origin feat/<scope>
|
||
6. gh pr create --title "..." --body "$(cat <<EOF...)"
|
||
7. Вернуть PR URL пользователю
|
||
8. СРАЗУ ScheduleWakeup polling (90-120s)
|
||
```
|
||
|
||
**Никаких direct push в main.** Только через PR merge.
|
||
|
||
## Commit messages
|
||
|
||
- **Conventional**: `feat(scope): ...` / `fix(scope): ...` / `refactor/docs/chore/perf`
|
||
- **Imperative**: "fix crash" не "fixed crash"
|
||
- **Body — почему**, не что (что видно в diff)
|
||
- **NO `Co-Authored-By: Claude ...`** — никогда (~/.claude/CLAUDE.md rule)
|
||
- Workers оставляют staged — main session коммитит
|
||
- **No auto-commit**: написать commit message в чат, user решает когда коммитить
|
||
|
||
## PR body template
|
||
|
||
```markdown
|
||
## Summary
|
||
- bullet
|
||
|
||
## Test plan
|
||
- [ ] smoke test
|
||
|
||
Closes #N
|
||
```
|
||
|
||
Всегда `Closes #N` если есть issue. Комментарий на issue при PR create: "Working on this in PR #M".
|
||
|
||
## Polling loop
|
||
|
||
После `gh pr create` — СРАЗУ `ScheduleWakeup` (90-120s):
|
||
|
||
1. `gh pr view <N> --json state,mergeable,comments,headRefOid`
|
||
2. `state == MERGED` → stop polling
|
||
3. Новый bot comment: распарси `<!-- gendesign-review-bot: sha=<sha7> verdict=<approve|changes> -->`
|
||
- **SHA guard**: `marker.sha7 == headRefOid[:7]` — иначе устаревший approval до fixup-push, игнорируй
|
||
- **Scope guard** (см. ниже): если blocked paths → ping user, не auto-merge
|
||
- `verdict=approve` + SHA match + scope OK → `gh pr merge <N> --squash --delete-branch`
|
||
- `verdict=changes` → fixup commits + push + re-poll
|
||
4. Нет новых comments → re-schedule 60s
|
||
5. **Cap**: 30 iter без resolution → stop, ping user. Blocked-scope cap = 5.
|
||
|
||
## Auto-merge scope
|
||
|
||
**✅ Разрешено** (PR diff целиком в этих путях — bot merge без human):
|
||
- `CLAUDE.md`, `README.md`, `docs/**`
|
||
- `frontend/src/app/**` UI-only без новых endpoints
|
||
- `frontend/public/**`
|
||
- `.claude/agents/**`, `.claude/rules/**`, `memory/feedback_*.md`
|
||
|
||
**❌ Блокировано** (любой файл из списка → human approval):
|
||
- `data/sql/**`, `backend/alembic/versions/**`
|
||
- `backend/app/api/v1/**`, `backend/app/services/**`, `backend/app/scrapers/**`
|
||
- `docker-compose*.yml`, `Caddyfile`, `.github/workflows/**`
|
||
- Любой файл с упоминанием secret / token / password / credential
|
||
- PR меняет `Critical workflow rules` или `Auto-merge scope` в CLAUDE.md
|
||
- PR меняет `Auto-merge scope` / blocked-list в любом `.claude/rules/*.md` (self-extending rules → нужен human)
|
||
|
||
Touches both → more restrictive (block).
|
||
|
||
## Sequential PRs
|
||
|
||
**Одна задача → один PR → merge → следующая.** Параллельно ТОЛЬКО если scope'ы строго orthogonal (разные файлы).
|
||
|
||
Опасные файлы для конфликтов: `backend/app/api/v1/parcels.py`, `frontend/src/types/site-finder.ts`, OverviewTab/LandTab/MarketTab.
|
||
|
||
## Split big issues
|
||
|
||
Issues ≥ 1.5 day → 3-4 sub-PRs: **Foundation → Schema → Workers → Integration**. Каждый ~200-500 lines. PR N+1 только после merge PR N.
|
||
|
||
## Review workflow (no conflict)
|
||
|
||
- **Pre-push** (локально): spawn `code-reviewer` subagent на staged changes → lint pass (security, correctness, conventions). Блокирует push при 🔴 критикал.
|
||
- **Post-push** (внешнее окно Claude): делает review после PR create, постит комменты от `lekss361`. Main session НЕ дублирует — только acting on review comments (fixup commits).
|
||
|
||
## Запреты
|
||
|
||
- ❌ `git push origin main` / direct push в main
|
||
- ❌ `gh pr merge` без approval (human "merge it" или bot verdict=approve + SHA match)
|
||
- ❌ `--no-verify` / `--amend` / `--no-edit` / `--force` без явного approval
|
||
- ❌ `@claude` в PR comments — plain text only (`feedback_no_claude_mentions`)
|
||
- ❌ Параллельные PR на одни файлы (`feedback_sequential_prs`)
|