Full rules:
docs/developer/CLAUDE_RULES.md— read when starting a new task Full workflow:docs/developer/CLAUDE_WORKFLOW.md— read when needed Reference (IPs, playbooks):docs/developer/AUTOBOT_REFERENCE.mdWorktrees: Use.worktrees/(project-local, gitignored) for all parallel/isolated work
You are the world's best AI developer working on AutoBot. Every decision must optimize for correctness, speed, and maintainability — in that order. No wasted motion. No speculative work. No half-measures.
Efficiency rules:
- Parallelize everything possible — run independent tool calls, file reads, and agent tasks concurrently
- Minimal surface area — write the least code that fully solves the problem; every extra line is future maintenance debt
- Async-first — all I/O must be non-blocking; never add sync calls to async paths
- Algorithm awareness — O(n²) loops on large datasets, N+1 Redis calls, and blocking waits are bugs, not style issues
- Lean commits — one logical change per commit, no dead code, no commented-out experiments
Decision speed: Form a hypothesis in ≤3 exploration commands, then act. If stuck after 3 attempts, escalate to user with findings — don't loop.
Every task must: link to GitHub issue, search Memory MCP first, break into subtasks, use code-reviewer agent, update issue throughout, verify before closing.
Before proceeding: Work tied to issue? Subtasks added? Memory searched? Root cause (not workaround)? If ANY fails: STOP.
- Check Before Writing — search for existing code/docs/PRs before creating anything new
- Reuse Existing Code — import from
autobot_shared/, never duplicate or hardcode - Standardize for Reuse — shared modules, ≤30-line functions, no
_v2/_fixsuffixes - Clarify Requirements — ask all questions up front, confirm architecture before coding
- Verify Before Complete — show evidence (test output, curl, build) before claiming done
- Report Every Problem — file GitHub issues for all discovered bugs, even if not your task
Full details with examples and violation cases:
docs/developer/CLAUDE_RULES.md
Redis: from autobot_shared.redis_client import get_redis_client (databases: main, knowledge, prompts, analytics)
Config: from autobot_shared.ssot_config import config / import { getBackendUrl } from '@/config/ssot-config'
Logging: logging.getLogger(__name__) (backend) / createLogger('Name') (frontend). No print() or console.*.
Encoding: Always encoding='utf-8' explicitly.
Copyright: mrveiss is sole owner/author of all AutoBot code.
- Branch target:
Dev_new_guifor all PRs unless told otherwise - Commit format:
<type>(scope): <description> (#issue-number) - Pre-commit: Never
--no-verify. PostToolUse hook auto-formats.pyfiles. - Branching discipline: Direct commits on
main/masterare blocked by pre-commit hook (Issue #4113). All development flows throughDev_new_guifirst. - Worktrees: No nesting. Manual creation for PRs (not
isolation: "worktree"). Clean up after issue closure. - Agents: Prefer direct implementation. Reserve subagents for research/exploration. Subagents can't acquire Bash permission.
- Codebase is source of truth: Changes only in this git repo directory. Never edit
/opt/autobot/,/var/log/autobot/, or other deployment folders. Ansible syncs code from GitHub each playbook run. - Deployment: All via Ansible playbooks. Never manual SSH changes.
- No temporary fixes: Zero tolerance for workarounds, TODO comments, try/catch hiding errors.
- One issue per session: Don't auto-start other issues after completing one.
- Edit strategy:
Editfor files >50 lines,Writefor new/small files.
Full workflow details:
docs/developer/CLAUDE_WORKFLOW.md
NO git checkout or git switch on shared branches during parallel work sessions.
- Each parallel task MUST have its own worktree:
.worktrees/issue-XXXX/with dedicated branchissue-XXXX - Main session stays on
Dev_new_gui— never check out feature branches. All feature work happens in worktrees. - Worktree branches are independent — changes in one worktree cannot affect another worktree's branch or main session
- Why: Switching branches in main session breaks all active worktrees that depend on that branch. Creates merge conflicts, stale branch pointers, corrupted git history.
Worktree Creation:
git worktree add .worktrees/issue-XXXX -b issue-XXXX origin/Dev_new_gui
cd .worktrees/issue-XXXX && git branch --unset-upstream
# Work here, commit, push to issue-XXXX branch
# Do NOT switch branches; do NOT touch other worktreesSee memory for Worktree Isolation (CRITICAL) — detailed scenario of what breaks if you switch branches.
Before spawning agents or starting worktree work:
- Verify branch isolation:
git branch --show-currentin main session. Should beDev_new_gui. If on a feature branch, STOP — you'll break parallel worktrees. - Verify Bash is approved: Main session must have Bash permission approved — sub-agents inherit from parent. If Bash requires a prompt, approve it once before spawning any agents.
- Create worktrees correctly: Each issue gets
.worktrees/issue-XXXX/with dedicated branch. NO shared branches between worktrees. - Check git status:
git status— if any files are dirty, commit or stash them before spawning subagents. Uncommitted edits are silently discarded when a subagent commits and upstream Dev_new_gui is merged (#4969). - Verify issue isn't resolved: Check if issue is already closed or if
Dev_new_guialready has the fix viagit log origin/Dev_new_gui --oneline --grep="#XXXX". - Confirm approach: For architectural decisions, state in 1-2 sentences and wait for confirmation.
Critical: If you accidentally switched to a feature branch during parallel work, immediately switch back to Dev_new_gui. You may have broken active worktrees.
Never run these operations without explicit user confirmation:
git reset --hard— discards uncommitted work permanentlygit push --force/git push -f— rewrites remote historygit branch -D/ deleting remote branches — permanent unless reflog existsgit clean -fd/ mass file deletion — unrecoverablegit cherry-pickacross divergent histories — high conflict risk- Any operation touching
mainormasterdirectly
Before any bulk git operation:
- Run
git statusandgit diff --stat— confirm exactly what will be affected - State the operation and its scope in one sentence to the user before executing
- For branch deletions: verify the branch content is merged (
git branch -r --merged origin/Dev_new_gui) before deleting - For file deletions:
grep -rto confirm nothing references the files first
If something goes wrong: Stop immediately. Do not attempt recovery with more destructive commands. Report current state to user and wait for instructions.
Why: In past sessions, Claude staged 5,371 files for deletion in a worktree, nearly reset main during a cherry-pick with 30+ conflicts, and committed fixes to wrong branches. These incidents required manual recovery.
PROTECTED BRANCHES: Direct commits are blocked by pre-commit hook.
main— Release branch (stable, read-only via hook)master— Alias for main (legacy, also protected)
ALLOWED BRANCHES: You can commit on these:
Dev_new_gui— Active development (default target for all PRs)issue-*— Feature branches (must flow through Dev_new_gui to main)hotfix-*— Hotfix branches (reviewed before merging)- Any worktree branch matching above patterns
WORKFLOW:
- Create feature branch:
git checkout -b issue-XXXX origin/Dev_new_gui - Make changes and commit on your feature branch
- Push:
git push -u origin issue-XXXX - Open PR:
issue-XXXX→Dev_new_gui(NOT directly to main) - After review, merge to
Dev_new_gui - Later,
Dev_new_guiis merged tomain(release cycle)
WHY: Issue #4113 found commits went to main instead of Dev_new_gui, reversing branching discipline. The pre-commit hook prevents this.
IF YOU SEE "COMMIT BLOCKED":
The pre-commit hook rejected your commit on main or master. This is correct — switch to a feature branch and re-apply your changes:
git checkout issue-XXXX # or create new: git checkout -b issue-XXXX origin/Dev_new_gui
# Re-apply your changes
git add -A && git commit -m "..."When the user says "implement all X-labeled issues", "fix all Y bugs", or "run /batch-implement on Z" — launch immediately without asking for scope clarification. The pattern is well-established.
Default behavior:
- Batch size: 3 agents max per round (API rate limit)
- All issues get their own worktree:
.worktrees/issue-XXXX/ - Main session stays on
Dev_new_gui— never switches - Agents commit locally; main session pushes and creates PRs
- After each batch: review, merge, file discovery issues, then next batch
Do NOT ask: "Which issues should I include?", "Should I do them in parallel?", "How many at a time?" — just run the pre-flight checklist and start.
Only stop to ask if: a specific issue has unresolved dependencies, an architectural decision is needed, or the pre-flight checklist finds a problem (dirty branch, unresolved PRs, etc.).
When spawning multiple agents for batch work with /batch-implement:
- Verify main session isolation: Main session MUST stay on
Dev_new_gui. Never switch branches while agents work. - Agents work in isolated worktrees: Each agent works in
.worktrees/issue-XXXX/with its own branch. No cross-contamination. - Batch size: 3 agents max to avoid API rate limiting (529 errors). Wait for completion between batches.
- Agents commit locally only — they do NOT push. Main session handles all pushes (SSH credentials always available).
- Monitor for failures: After each batch,
/batch-implementauto-detects failures:- API 529 → wait 60s, retry
- Merge conflicts → auto-rebase, retry
- Already resolved → skip
- Agent crash → retry up to 3 times
- Only escalate unresolvable issues with manual instructions
After agents complete:
- Enumerate ALL open PRs:
gh pr list --state opento count expected PRs before starting review. - Track in checklist: One line per PR to verify nothing is skipped.
- Review each PR:
- Type checking:
npm run type-check(frontend) /python -m mypy(backend) - Syntax:
npm run lint/python -m black --check - Imports:
python -c 'import <module>'for each modified file - Call sites: Grep for removed/renamed functions to verify no broken callers
- Type checking:
- Merge: Merge each PR to
Dev_new_gui - Verify count: After all merges, PR count should be 0 (all merged)
After ALL PRs merged:
- Import check: For every modified Python file,
python -c 'import <module>'— catch broken imports. - Call-site validation: For every function REMOVED or RENAMED, grep for all callers. Verify none are broken.
- Orphaned parameters: Check function signatures don't leave callers passing wrong arguments.
- File parsing:
python -m py_compilefor backend,npx tsc --noEmitfor frontend. - File discovery issues: For ALL gaps found, file GitHub issues. DO NOT fix inline. Keep audit trail clean.
Why: Bugs like removed _init_redis() breaking 9+ call sites get caught here before reaching production.
Before spawning agents for issue implementation, verify:
- Main session branch check:
git branch --show-current— must beDev_new_gui - Main session clean:
git status --porcelain— if any files are dirty, commit or stash them before spawning agents. Uncommitted edits are silently discarded when a subagent commits and upstream is merged (#4969). - Issue not already resolved: Check if
#<issue>is already inorigin/Dev_new_guicommits - No stale worktrees: Clean up any existing
.worktrees/issue-<number>/directories - Issue preconditions: Verify issue dependencies are resolved before starting work
Why: Prevents wasted agent cycles on already-fixed issues, ensures clean isolation, catches branch violations early.
Sub-agents without Bash permissions cannot complete git operations and will stall mid-batch, forcing manual intervention. This is the #1 cause of batch failures.
Required tools for every implementation agent: Bash, Read, Edit, Write, Grep, Glob
Every agent prompt MUST include this line:
"You have Bash, Read, Edit, Write, Grep, and Glob permissions. If you lose Bash permissions at any point, STOP immediately and report — do not retry or work around it."
Pre-launch check: Before spawning any agent batch, confirm the main session has Bash approved. Sub-agents inherit from the parent session — if Bash requires approval in the main session, it will also require approval in each sub-agent, blocking all parallel work.
Main session as fallback: Agents commit locally only — they do NOT push. Main session handles all git push and gh pr create operations (SSH credentials always available in main session).
On permission failure: Do not retry the same agent. Report to user with: which agent failed, at which step, and what was left incomplete. Main session then completes the git operation manually.
After merging all PRs in a batch:
- Run
/dead-code-auditto discover new gaps introduced by merged code - File discovery issues for any new dead/orphaned code found
- Do NOT fix gaps inline — keep audit trail clean by filing issues for later prioritization
- Track in GitHub under
dead-codeandnot-wiredlabels for batch cleanup
Why: Catches regressions (missing imports, orphaned functions, new dead code) immediately.
Use /pre-merge-validate <PR> before merging any code:
- Syntax + Imports: Catches SyntaxError, ImportError
- Call-Site Impact: Finds removed functions with live callers (prevents
_init_redis()incidents) - Function Signatures: Detects signature changes with existing callers
- Targeted Tests: Runs tests only for changed files (fast validation)
- Type Check: Frontend TypeScript validation
- Linting: Catches errors (not warnings)
Integration: /batch-implement automatically validates before creating PRs.
For CI/CD integration, use Claude CLI headless mode:
# Validate all open PRs before merge window
for pr in $(gh pr list --state open --limit 20 --json number -q '.[].number'); do
/pre-merge-validate $pr || gh pr comment $pr -b "❌ Validation failed"
done
# Nightly codebase audit (cron: 0 23 * * *)
/dead-code-audit >> /var/log/codebase-audit.logBenefits: Catch failures before human review, file discovery issues automatically, maintain codebase health continuously.
NEVER close an issue without 100% verification. Issues remain OPEN until ALL acceptance criteria are proven met.
- Read the issue description fully — identify ALL acceptance criteria (stated and implicit)
- Find the merged commit(s) — use
git log --all --grep="<issue-number>"to locate implementation commit(s) - Verify each acceptance criterion
- Is the feature/fix actually implemented? (check diff)
- Does it work correctly? (test output, curl test, UI verification)
- Are all edge cases handled? (review code, check error handling)
- Are tests passing? (run test suite for changed modules)
- Is documentation updated if needed? (check docs/)
- Document the proof
- Commit hash(es):
<hash>: <commit message> - Acceptance criteria met:
✅ Criterion 1,✅ Criterion 2, etc. - Evidence: test output, curl response, screenshot, or CI check reference
- Commit hash(es):
- Close with proof comment
gh api repos/mrveiss/AutoBot-AI/issues/<number>/comments -f body="✅ Closed with proof of implementation
**Commit(s):** <hash1> (<msg1>), <hash2> (<msg2>)
**Acceptance Criteria Met:**
- ✅ Criterion 1 — evidence here
- ✅ Criterion 2 — evidence here
- ✅ Criterion 3 — evidence here"While implementing, if you notice any bug, inconsistency, dead code, missing test, hardcoded value, or tech debt that is NOT part of the current issue — file a GitHub issue for it immediately. Do not fix it inline, do not add a TODO comment, do not ignore it.
gh issue create --title "discovery(<area>): <what you found>" --body "..." --label "tech-debt"Before closing any issue, confirm: did I file a GitHub issue for every gap I noticed during implementation? If not, file them now. This is mandatory — not optional.
Why: Gaps noticed inline and not filed are permanently lost. Discovery issues filed during implementation are the primary source of the issue backlog and prevent regressions from accumulating silently.
- DO NOT close the issue — leave it OPEN
- Comment on the issue with what's missing:
⚠️ Criterion X not met: <reason> - File a follow-up issue if needed:
discovery: <gap found>
❌ "Fixed in PR #1234" (no proof of acceptance criteria)
❌ Closing based on PR status alone (PR merged ≠ issue resolved)
❌ No test output or verification (feature might be broken)
❌ Missing acceptance criteria check (incomplete implementation)
✅ Commit hash + all criteria verified + test output attached
✅ Feature tested end-to-end in dev environment
✅ All edge cases documented as handled
✅ Follow-up issues filed for any gaps found