Communitygithub.com

자율 루프

Claude Code 자동 루프를 위한 패턴과 아키텍처 — 간단한 순차적 파이프라인부터 RFC 기반 다중 에이전트 DAG 시스템까지. 호환성 유지를 위해 유지됨: 새로운 자율 루프 지침이 필요하면 대신 continuous-agent-loop을 사용하세요.

자율 루프란 무엇인가요?

autonomous-loops 스킬은 Claude Code를 자율적으로 루프에서 실행하기 위한 패턴, 아키텍처 및 참조 구현을 제공합니다. 이 스킬은 단순한 `claude -p` 파이프라인부터 고급 RFC 기반 다중 에이전트 DAG 오케스트레이션까지 포괄합니다. 주요 사용 사례로는 인간의 개입 없이 실행되는 자율 개발 워크플로우 설정, 문제에 적합한 루프 아키텍처 선택, CI/CD 스타일의 지속적 개발 파이프라인 구축, 병렬 에이전트 실행 및 병합 조정, 루프 반복 간 컨텍스트 지속성 구현, 자율 워크플로우에 품질 게이트 및 정리 패스 추가 등이 있습니다. 이 스킬은 호환성 유지를 위해 v1.8.0까지 유지되며, 새 루프 지침이 필요하면 canonical skill인 continuous-agent-loop을 사용해야 합니다.

지원 대상✓Claude Code✓Codex CLI~Cursor✓Antigravity
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/autonomous-loops

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

Autonomous Loops Skill

호환성 참고 (v1.8.0): autonomous-loops는 한 번의 릴리스 동안 유지됩니다. 이제 표준 스킬 이름은 continuous-agent-loop입니다. 새로운 루프 가이드는 해당 이름으로 작성해야 하며, 이 스킬은 기존 워크플로우를 깨지 않도록 계속 사용할 수 있습니다.

Claude Code를 루프(loop)에서 자율적으로 실행하기 위한 패턴, 아키텍처 및 참조 구현입니다. 간단한 claude -p 파이프라인부터 전체 RFC 기반 다중 에이전트 DAG 오케스트레이션까지 다룹니다.

사용 시기

  • 사람의 개입 없이 실행되는 자율 개발 워크플로우 설정
  • 문제에 맞는 올바른 루프 아키텍처 선택 (단순 vs 복잡)
  • CI/CD 스타일의 지속적 개발 파이프라인 구축
  • 병합 조정이 필요한 병렬 에이전트 실행
  • 루프 반복 간 컨텍스트 지속성 구현
  • 자율 워크플로우에 품질 게이트 및 정리 패스 추가

루프 패턴 스펙트럼

가장 단순한 것부터 가장 정교한 것까지:

패턴복잡도가장 적합한 경우
순차 파이프라인낮음일일 개발 단계, 스크립트 워크플로우
NanoClaw REPL낮음대화형 지속 세션
무한 에이전트 루프중간병렬 콘텐츠 생성, 사양 기반 작업
지속적 Claude PR 루프중간CI 게이트가 있는 다일 반복 프로젝트
De-Sloppify 패턴추가 기능구현자 단계 이후 품질 정리
Ralphinho / RFC 기반 DAG높음대규모 기능, 병합 큐가 있는 다중 유닛 병렬 작업

1. 순차 파이프라인 (claude -p)

가장 단순한 루프. 일일 개발을 일련의 비대화형 claude -p 호출로 나눕니다. 각 호출은 명확한 프롬프트가 있는 집중된 단계입니다.

핵심 통찰력

만약 이런 루프를 구성할 수 없다면, 대화형 모드에서도 LLM이 코드를 수정하도록 유도할 수 없다는 뜻입니다.

claude -p 플래그는 Claude Code를 프롬프트와 함께 비대화형으로 실행하고 완료되면 종료합니다. 호출을 연결하여 파이프라인을 구축합니다:

#!/bin/bash
# daily-dev.sh — 기능 브랜치를 위한 순차 파이프라인

set -e

# 1단계: 기능 구현
claude -p "Read the spec in docs/auth-spec.md. Implement OAuth2 login in src/auth/. Write tests first (TDD). Do NOT create any new documentation files."

# 2단계: De-sloppify (정리 패스)
claude -p "Review all files changed by the previous commit. Remove any unnecessary type tests, overly defensive checks, or testing of language features (e.g., testing that TypeScript generics work). Keep real business logic tests. Run the test suite after cleanup."

# 3단계: 검증
claude -p "Run the full build, lint, type check, and test suite. Fix any failures. Do not add new features."

# 4단계: 커밋
claude -p "Create a conventional commit for all staged changes. Use 'feat: add OAuth2 login flow' as the message."

주요 설계 원칙

  1. 각 단계는 격리됨 — claude -p 호출마다 새로운 컨텍스트 창이 있어 단계 간 컨텍스트 오염이 없습니다.
  2. 순서가 중요함 — 단계는 순차적으로 실행됩니다. 각 단계는 이전 단계가 남긴 파일 시스템 상태를 기반으로 합니다.
  3. 부정 명령은 위험함 — "타입 시스템을 테스트하지 마세요"라고 말하지 마세요. 대신 별도의 정리 단계를 추가하세요 (De-Sloppify 패턴 참조).
  4. 종료 코드가 전파됨 — set -e는 실패 시 파이프라인을 중지합니다.

변형

모델 라우팅 사용:

# Opus로 연구 (깊은 추론)
claude -p --model opus "Analyze the codebase architecture and write a plan for adding caching..."

# Sonnet으로 구현 (빠르고 능력 있음)
claude -p "Implement the caching layer according to the plan in docs/caching-plan.md..."

# Opus로 검토 (철저함)
claude -p --model opus "Review all changes for security issues, race conditions, and edge cases..."

환경 컨텍스트 사용:

# 컨텍스트를 프롬프트 길이가 아닌 파일로 전달
echo "Focus areas: auth module, API rate limiting" > .claude-context.md
claude -p "Read .claude-context.md for priorities. Work through them in order."
rm .claude-context.md

--allowedTools 제한 사용:

# 읽기 전용 분석 패스
claude -p --allowedTools "Read,Grep,Glob" "Audit this codebase for security vulnerabilities..."

# 쓰기 전용 구현 패스
claude -p --allowedTools "Read,Write,Edit,Bash" "Implement the fixes from security-audit.md..."

2. NanoClaw REPL

ECC의 내장 지속 루프. 전체 대화 기록과 함께 claude -p를 동기식으로 호출하는 세션 인식 REPL입니다.

# 기본 세션 시작
node scripts/claw.js

# 스킬 컨텍스트가 있는 명명된 세션
CLAW_SESSION=my-project CLAW_SKILLS=tdd-workflow,security-review node scripts/claw.js

작동 방식

  1. ~/.claude/claw/{session}.md에서 대화 기록 로드
  2. 각 사용자 메시지는 전체 기록을 컨텍스트로 하여 claude -p로 전송됨
  3. 응답은 세션 파일에 추가됨 (데이터베이스로서의 마크다운)
  4. 세션은 재시작 후에도 유지됨

NanoClaw vs 순차 파이프라인

사용 사례NanoClaw순차 파이프라인
대화형 탐색예아니요
스크립트 자동화아니요예
세션 지속성내장수동
컨텍스트 누적턴마다 증가각 단계마다 새로워짐
CI/CD 통합나쁨우수

자세한 내용은 /claw 명령어 문서를 참조하세요.


3. 무한 에이전트 루프

두 개의 프롬프트 시스템으로, 사양 기반 생성을 위해 병렬 하위 에이전트를 조정합니다. disler 개발 (크레딧: @disler).

아키텍처: 두 개의 프롬프트 시스템

프롬프트 1 (오케스트레이터)              프롬프트 2 (하위 에이전트)
┌─────────────────────┐             ┌──────────────────────┐
│ 사양 파일 구문 분석  │             │ 전체 컨텍스트 수신    │
│ 출력 디렉토리 스캔    │  배포       │ 할당된 번호 읽기      │
│ 반복 계획 수립        │────────────│ 사양을 정확히 따르기   │
│ 창의적 방향 할당      │  N 에이전트  │ 고유한 출력 생성       │
│ 웨이브 관리           │             │ 출력 디렉토리 저장     │
└─────────────────────┘             └──────────────────────┘

패턴

  1. 사양 분석 — 오케스트레이터가 생성할 항목을 정의하는 사양 파일(마크다운)을 읽음
  2. 디렉토리 정찰 — 기존 출력을 스캔하여 가장 높은 반복 번호를 찾음
  3. 병렬 배포 — N개의 하위 에이전트를 시작하며, 각각 다음을 받음:
    • 전체 사양
    • 고유한 창의적 방향
    • 특정 반복 번호 (충돌 없음)
    • 기존 반복의 스냅샷 (고유성 보장)
  4. 웨이브 관리 — 무한 모드의 경우 컨텍스트가 소진될 때까지 3-5개의 에이전트 웨이브를 배포

Claude Code 명령어를 통한 구현

.claude/commands/infinite.md 생성:

Parse the following arguments from $ARGUMENTS:
1. spec_file — path to the specification markdown
2. output_dir — where iterations are saved
3. count — integer 1-N or "infinite"

PHASE 1: Read and deeply understand the specification.
PHASE 2: List output_dir, find highest iteration number. Start at N+1.
PHASE 3: Plan creative directions — each agent gets a DIFFERENT theme/approach.
PHASE 4: Deploy sub-agents in parallel (Task tool). Each receives:
  - Full spec text
  - Current directory snapshot
  - Their assigned iteration number
  - Their unique creative direction
PHASE 5 (infinite mode): Loop in waves of 3-5 until context is low.

호출:

/project:infinite specs/component-spec.md src/ 5
/project:infinite specs/component-spec.md src/ infinite

배치 전략

개수전략
1-5모든 에이전트 동시에
6-205개씩 배치
infinite3-5개 웨이브, 점진적 정교화

핵심 통찰력: 할당을 통한 고유성

에이전트가 스스로 차별화하도록 의존하지 마세요. 오케스트레이터가 각 에이전트에 특정 창의적 방향과 반복 번호를 할당합니다. 이는 병렬 에이전트 간 중복 개념을 방지합니다.


4. 지속적 Claude PR 루프

프로덕션 등급 셸 스크립트로, Claude Code를 지속적 루프로 실행하여 PR을 생성하고 CI를 기다린 후 자동으로 병합합니다. AnandChowdhary 개발 (크레딧: @AnandChowdhary).

핵심 루프

┌─────────────────────────────────────────────────────┐
│  지속적 CLAUDE 반복                                 │
│                                                     │
│  1. 브랜치 생성 (continuous-claude/iteration-N)      │
│  2. 향상된 프롬프트로 claude -p 실행                 │
│  3. (선택 사항) 검토자 패스 — 별도의 claude -p       │
│  4. 변경 사항 커밋 (claude가 메시지 생성)             │
│  5. 푸시 + PR 생성 (gh pr create)                    │
│  6. CI 검사 대기 (gh pr checks 폴링)                 │
│  7. CI 실패? → 자동 수정 패스 (claude -p)             │
│  8. PR 병합 (squash/merge/rebase)                    │
│  9. main으로 돌아가기 → 반복                          │
│                                                     │
│  제한: --max-runs N | --max-cost $X                  │
│            --max-duration 2h | 완료 신호               │
└─────────────────────────────────────────────────────┘

설치

경고: 코드 검토 후 저장소에서 continuous-claude를 설치하세요. 외부 스크립트를 bash로 직접 파이프하지 마세요.

사용법

# 기본: 10회 반복
continuous-claude --prompt "Add unit tests for all untested functions" --max-runs 10

# 비용 제한
continuous-claude --prompt "Fix all linter errors" --max-cost 5.00

# 시간 제한
continuous-claude --prompt "Improve test coverage" --max-duration 8h

# 코드 검토 패스 포함
continuous-claude \
  --prompt "Add authentication feature" \
  --max-runs 10 \
  --review-prompt "Run npm test && npm run lint, fix any failures"

# 워크트리를 통한 병렬 실행
continuous-claude --prompt "Add tests" --max-runs 5 --worktree tests-worker &
continuous-claude --prompt "Refactor code" --max-runs 5 --worktree refactor-worker &
wait

반복 간 컨텍스트: SHARED_TASK_NOTES.md

핵심 혁신: 반복 간에 유지되는 SHARED_TASK_NOTES.md 파일:

## Progress
- [x] Added tests for auth module (iteration 1)
- [x] Fixed edge case in token refresh (iteration 2)
- [ ] Still need: rate limiting tests, error boundary tests

## Next Steps
- Focus on rate limiting module next
- The mock setup in tests/helpers.ts can be reused

Claude는 반복 시작 시 이 파일을 읽고 반복 종료 시 업데이트합니다. 이는 독립적인 claude -p 호출 간의 컨텍스트 격차를 해소합니다.

CI 실패 복구

PR 검사가 실패하면 Continuous Claude는 자동으로:

  1. gh run list를 통해 실패한 실행 ID를 가져옴
  2. CI 수정 컨텍스트로 새로운 claude -p를 실행
  3. Claude가 gh run view를 통해 로그를 검사하고 코드를 수정, 커밋, 푸시
  4. 검사를 다시 기다림 (최대 --ci-retry-max회 시도)

완료 신호

Claude는 마법 문구를 출력하여 "완료" 신호를 보낼 수 있습니다:

continuous-claude \
  --prompt "Fix all bugs in the issue tracker" \
  --completion-signal "CONTINUOUS_CLAUDE_PROJECT_COMPLETE" \
  --completion-threshold 3  # 연속 3회 신호 후 중지

연속 3회 반복에서 완료 신호가 오면 루프가 중지되어 완료된 작업에 대한 불필요한 실행을 방지합니다.

주요 설정

플래그목적
--max-runs NN번의 성공적인 반복 후 중지
--max-cost $X$X 지출 후 중지
--max-duration 2h경과 시간 후 중지
--merge-strategy squashsquash, merge, 또는 rebase
--worktree <name>git 워크트리를 통한 병렬 실행
--disable-commits드라이 런 모드 (git 작업 없음)
--review-prompt "..."반복당 검토자 패스 추가
--ci-retry-max NCI 실패 자동 수정 (기본값: 1)

5. De-Sloppify 패턴

모든 루프에 대한 추가 패턴. 각 구현자 단계 후에 전용 정리/리팩토링 단계를 추가합니다.

문제

LLM에게 TDD로 구현하라고 요청하면 "테스트 작성"을 너무 문자 그대로 받아들입니다:

  • TypeScript의 타입 시스템이 작동하는지 확인하는 테스트 (typeof x === 'string' 테스트)
  • 타입 시스템이 이미 보장하는 것에 대한 지나치게 방어적인 런타임 검사
  • 비즈니스 로직보다 프레임워크 동작에 대한 테스트
  • 실제 코드를 모호하게 만드는 과도한 오류 처리

부정 명령이 안 좋은 이유?

구현자 프롬프트에 "타입 시스템을 테스트하지 마세요" 또는 "불필요한 검사를 추가하지 마세요"를 추가하면 부작용이 있습니다:

  • 모델이 모든 테스트에 대해 주저하게 됨
  • 합법적인 엣지 케이스 테스트를 건너뜀
  • 품질이 예측 불가능하게 저하됨

해결책: 별도 패스

구현자를 제한하는 대신 철저하게 작업하도록 둡니다. 그런 다음 집중된 정리 에이전트를 추가합니다:

# 1단계: 구현 (철저하게 작업하도록 함)
claude -p "Implement the feature with full TDD. Be thorough with tests."

# 2단계: De-sloppify (별도 컨텍스트, 집중 정리)
claude -p "Review all changes in the working tree. Remove:
- Tests that verify language/framework behavior rather than business logic
- Redundant type checks that the type system already enforces
- Over-defensive error handling for impossible states
- Console.log statements
- Commented-out code

Keep all business logic tests. Run the test suite after cleanup to ensure nothing breaks."

루프 컨텍스트에서

for feature in "${features[@]}"; do
  # 구현
  claude -p "Implement $feature with TDD."

  # De-sloppify
  claude -p "Cleanup pass: review changes, remove test/code slop, run tests."

  # 검증
  claude -p "Run build + lint + tests. Fix any failures."

  # 커밋
  claude -p "Commit with message: feat: add $feature"
done

핵심 통찰력

하류 품질에 부정적 영향을 미치는 부정 명령을 추가하는 대신 별도의 de-sloppify 패스를 추가하세요. 두 개의 집중된 에이전트가 하나의 제한된 에이전트보다 더 나은 성능을 발휘합니다.


6. Ralphinho / RFC 기반 DAG 오케스트레이션

가장 정교한 패턴. RFC 기반, 다중 에이전트 파이프라인입니

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

관련 스킬