long-agent
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLong Agent Sessions
长期Agent会话
Manage extended agent sessions with progress tracking and context management.
管理带有进度跟踪和上下文管理的扩展Agent会话。
Session Management
会话管理
Initialize Session
初始化会话
bash
undefinedbash
undefinedCreate session file
Create session file
SESSION_ID=$(date +%Y%m%d-%H%M%S)
SESSION_FILE=~/.claude/sessions/$SESSION_ID.md
mkdir -p ~/.claude/sessions
cat > $SESSION_FILE << EOF
SESSION_ID=$(date +%Y%m%d-%H%M%S)
SESSION_FILE=~/.claude/sessions/$SESSION_ID.md
mkdir -p ~/.claude/sessions
cat > $SESSION_FILE << EOF
Session: $SESSION_ID
Session: $SESSION_ID
Started: $(date)
Task: [Describe task]
Started: $(date)
Task: [Describe task]
Progress
Progress
- Step 1
- Step 2
- Step 3
- Step 1
- Step 2
- Step 3
Context
Context
[Important context to remember]
[Important context to remember]
Notes
Notes
[Running notes]
EOF
echo "Session: $SESSION_FILE"
undefined[Running notes]
EOF
echo "Session: $SESSION_FILE"
undefinedTrack Progress
跟踪进度
bash
undefinedbash
undefinedUpdate progress
Update progress
echo "- [x] Completed: [description]" >> $SESSION_FILE
echo "- [x] Completed: [description]" >> $SESSION_FILE
Add note
Add note
echo "### $(date +%H:%M) - [title]" >> $SESSION_FILE
echo "[notes]" >> $SESSION_FILE
undefinedecho "### $(date +%H:%M) - [title]" >> $SESSION_FILE
echo "[notes]" >> $SESSION_FILE
undefinedResume Session
恢复会话
bash
undefinedbash
undefinedList recent sessions
List recent sessions
ls -lt ~/.claude/sessions/ | head -10
ls -lt ~/.claude/sessions/ | head -10
View session
View session
cat ~/.claude/sessions/SESSION_ID.md
cat ~/.claude/sessions/SESSION_ID.md
Continue from last checkpoint
Continue from last checkpoint
tail -50 ~/.claude/sessions/SESSION_ID.md
undefinedtail -50 ~/.claude/sessions/SESSION_ID.md
undefinedProgress Patterns
进度模式
Checkpoint System
检查点系统
bash
#!/bin/bashbash
#!/bin/bashcheckpoint.sh SESSION_ID DESCRIPTION
checkpoint.sh SESSION_ID DESCRIPTION
SESSION_FILE=~/.claude/sessions/$1.md
CHECKPOINT=$2
echo "" >> $SESSION_FILE
echo "## Checkpoint: $(date +%H:%M)" >> $SESSION_FILE
echo "Status: $CHECKPOINT" >> $SESSION_FILE
echo "Can resume from here." >> $SESSION_FILE
undefinedSESSION_FILE=~/.claude/sessions/$1.md
CHECKPOINT=$2
echo "" >> $SESSION_FILE
echo "## Checkpoint: $(date +%H:%M)" >> $SESSION_FILE
echo "Status: $CHECKPOINT" >> $SESSION_FILE
echo "Can resume from here." >> $SESSION_FILE
undefinedMilestone Tracking
里程碑跟踪
markdown
undefinedmarkdown
undefinedSession Progress
Session Progress
Milestones
Milestones
- M1: Environment setup
- M2: Core implementation
- M3: Testing
- M4: Documentation
- M1: Environment setup
- M2: Core implementation
- M3: Testing
- M4: Documentation
Current: M3 - Testing
Current: M3 - Testing
Completed
Completed
- Unit tests for auth module
- Integration test setup
- Unit tests for auth module
- Integration test setup
In Progress
In Progress
- API endpoint tests
- API endpoint tests
Blocked
Blocked
- Need test fixtures for edge cases
undefined- Need test fixtures for edge cases
undefinedContext Management
上下文管理
Save Important Context
保存重要上下文
bash
#!/bin/bashbash
#!/bin/bashsave-context.sh SESSION_ID
save-context.sh SESSION_ID
SESSION_FILE=~/.claude/sessions/$1.md
cat >> $SESSION_FILE << 'CONTEXT'
SESSION_FILE=~/.claude/sessions/$1.md
cat >> $SESSION_FILE << 'CONTEXT'
Critical Context (Don't Lose)
Critical Context (Don't Lose)
File Locations
File Locations
- Main entry: src/index.ts
- Config: src/config.ts
- Tests: tests/
- Main entry: src/index.ts
- Config: src/config.ts
- Tests: tests/
Key Decisions
Key Decisions
- Using JWT for auth (not sessions)
- PostgreSQL for persistence
- Redis for caching
- Using JWT for auth (not sessions)
- PostgreSQL for persistence
- Redis for caching
Current State
Current State
- Auth module: complete
- API routes: 80% done
- Tests: 40% coverage CONTEXT
undefined- Auth module: complete
- API routes: 80% done
- Tests: 40% coverage CONTEXT
undefinedContext Recovery
上下文恢复
bash
undefinedbash
undefinedGet context for resumption
Get context for resumption
CONTEXT=$(grep -A 50 "## Critical Context" ~/.claude/sessions/$SESSION_ID.md)
gemini -m pro -o text -e "" "I'm resuming a long coding session. Here's the context:
$CONTEXT
Help me remember:
- Where was I?
- What's the next step?
- Any gotchas to remember?"
undefinedCONTEXT=$(grep -A 50 "## Critical Context" ~/.claude/sessions/$SESSION_ID.md)
gemini -m pro -o text -e "" "I'm resuming a long coding session. Here's the context:
$CONTEXT
Help me remember:
- Where was I?
- What's the next step?
- Any gotchas to remember?"
undefinedBearings Check
状态检查
Get Your Bearings
查看当前状态
bash
#!/bin/bashbash
#!/bin/bashbearings.sh - Where am I in this task?
bearings.sh - Where am I in this task?
echo "=== Current Session Status ==="
echo ""
echo "=== Current Session Status ==="
echo ""
Git status
Git status
echo "### Git Status"
git status --short
echo ""
echo "### Recent Commits"
git log --oneline -5
echo ""
echo "### Modified Files"
git diff --stat HEAD~3
echo ""
echo "### TODO Items"
grep -r "TODO|FIXME" src/ --include="*.ts" | head -10
undefinedecho "### Git Status"
git status --short
echo ""
echo "### Recent Commits"
git log --oneline -5
echo ""
echo "### Modified Files"
git diff --stat HEAD~3
echo ""
echo "### TODO Items"
grep -r "TODO|FIXME" src/ --include="*.ts" | head -10
undefinedProgress Summary
进度总结
bash
undefinedbash
undefinedGenerate progress summary
Generate progress summary
gemini -m pro -o text -e "" "Summarize progress on this session:
Session log:
$(tail -100 ~/.claude/sessions/$SESSION_ID.md)
Git activity:
$(git log --oneline -10)
Provide:
- What's been accomplished
- Current status
- Remaining work
- Estimated completion"
undefinedgemini -m pro -o text -e "" "Summarize progress on this session:
Session log:
$(tail -100 ~/.claude/sessions/$SESSION_ID.md)
Git activity:
$(git log --oneline -10)
Provide:
- What's been accomplished
- Current status
- Remaining work
- Estimated completion"
undefinedLong Task Patterns
长期任务模式
Multi-Day Task
多日任务
markdown
undefinedmarkdown
undefinedMulti-Day Task: [Name]
Multi-Day Task: [Name]
Day 1 - [Date]
Day 1 - [Date]
Accomplished
Accomplished
- [items]
- [items]
Blocked
Blocked
- [items]
- [items]
Tomorrow
Tomorrow
- [items]
- [items]
Day 2 - [Date]
Day 2 - [Date]
Context from Yesterday
Context from Yesterday
[summary]
[summary]
Accomplished
Accomplished
- [items]
undefined- [items]
undefinedHandoff Document
交接文档
When handing off to another session or agent:
markdown
undefined当交接给另一个会话或Agent时:
markdown
undefinedTask Handoff
Task Handoff
What This Is
What This Is
[Brief description]
[Brief description]
Current State
Current State
- [Bullet points of where things stand]
- [Bullet points of where things stand]
What's Working
What's Working
- [Completed items]
- [Completed items]
What's Not Working
What's Not Working
- [Issues/blockers]
- [Issues/blockers]
Next Steps
Next Steps
- [Specific step]
- [Specific step]
- [Specific step]
- [Specific step]
Key Files
Key Files
- - Entry point
src/main.ts - - Auth module (done)
src/auth/ - - API routes (in progress)
src/api/
- - Entry point
src/main.ts - - Auth module (done)
src/auth/ - - API routes (in progress)
src/api/
Commands to Know
Commands to Know
bash
npm run dev # Start development
npm test # Run tests
npm run build # Build for productionbash
npm run dev # Start development
npm test # Run tests
npm run build # Build for productionGotchas
Gotchas
- [Things that might trip you up]
undefined- [Things that might trip you up]
undefinedSession Templates
会话模板
Feature Development
功能开发
bash
cat > ~/.claude/sessions/feature-template.md << 'EOF'bash
cat > ~/.claude/sessions/feature-template.md << 'EOF'Feature: [Name]
Feature: [Name]
Requirements
Requirements
- Requirement 1
- Requirement 2
- Requirement 1
- Requirement 2
Design
Design
[Architecture notes]
[Architecture notes]
Implementation Progress
Implementation Progress
- Step 1
- Step 2
- Step 3
- Step 1
- Step 2
- Step 3
Testing
Testing
- Unit tests
- Integration tests
- Manual testing
- Unit tests
- Integration tests
- Manual testing
Documentation
Documentation
- Code comments
- README update
- API docs EOF
undefined- Code comments
- README update
- API docs EOF
undefinedBug Fix
Bug修复
bash
cat > ~/.claude/sessions/bugfix-template.md << 'EOF'bash
cat > ~/.claude/sessions/bugfix-template.md << 'EOF'Bug Fix: [Issue ID/Description]
Bug Fix: [Issue ID/Description]
Symptom
Symptom
[What's happening]
[What's happening]
Expected
Expected
[What should happen]
[What should happen]
Investigation
Investigation
- Reproduced locally
- Found root cause
- Identified fix
- Reproduced locally
- Found root cause
- Identified fix
Fix
Fix
[Description of fix]
[Description of fix]
Verification
Verification
- Fix works
- No regressions
- Tests added EOF
undefined- Fix works
- No regressions
- Tests added EOF
undefinedBest Practices
最佳实践
- Log frequently - Update progress often
- Save context - What would you need to resume?
- Create checkpoints - Mark safe resume points
- Summarize before breaks - Capture state of mind
- Use templates - Consistent structure helps
- Track blockers - Note what's waiting
- Handoff cleanly - Assume fresh context next time
- 频繁记录 - 经常更新进度
- 保存上下文 - 恢复会话时你需要什么信息?
- 创建检查点 - 标记安全的恢复点
- 休息前总结 - 记录当前的思路状态
- 使用模板 - 一致的结构更有帮助
- 跟踪阻塞问题 - 记录待处理的事项
- 清晰交接 - 假设下次会话是全新的上下文