Asks the AI to produce a structured context artifact capturing progress, decisions and project structure so another session, platform or agent can continue the work.
# Context Preservation & Migration Prompt
[ for AGENT.MD pass THE `## SECTION` if NOT APPLICABLE ]
Generate a comprehensive context artifact that preserves all conversational context, progress, decisions, and project structures for seamless continuation across AI sessions, platforms, or agents. This artifact serves as a "context USB" enabling any AI to immediately understand and continue work without repetition or context loss.
## Core Objectives
Capture and structure all contextual elements from current session to enable:
1. **Session Continuity** - Resume conversations across different AI platforms without re-explanation
2. **Agent Handoff** - Transfer incomplete tasks to new agents with full progress documentation
3. **Project Migration** - Replicate entire project cultures, workflows, and governance structures
## Content Categories to Preserve
### Conversational Context
- Initial requirements and evolving user stories
- Ideas generated during brainstorming sessions
- Decisions made with complete rationale chains
- Agreements reached and their validation status
- Suggestions and recommendations with supporting context
- Assumptions established and their current status
- Key insights and breakthrough moments
- Critical keypoints serving as structural foundations
### Progress Documentation
- Current state of all work streams
- Completed tasks and deliverables
- Pending items and next steps
- Blockers encountered with mitigation strategies
- Rate limits hit and workaround solutions
- Timeline of significant milestones
### Project Architecture (when applicable)
- SDLC methodology and phases
- Agent ecosystem (main agents, sub-agents, sibling agents, observer agents)
- Rules, governance policies, and strategies
- Repository structures (.github workflows, templates)
- Reusable prompt forms (epic breakdown, PRD, architectural plans, system design)
- Conventional patterns (commit formats, memory prompts, log structures)
- Instructions hierarchy (project-level, sprint-level, epic-level variations)
- CI/CD configurations (testing, formatting, commit extraction)
- Multi-agent orchestration (prompt chaining, parallelization, router agents)
- Output format standards and variations
### Rules & Protocols
- Established guidelines with scope definitions
- Additional instructions added during session
- Constraints and boundaries set
- Quality standards and acceptance criteria
- Alignment mechanisms for keeping work on track
# Steps
1. **Scan Conversational History** - Review entire thread/session for all interactions and context
2. **Extract Core Elements** - Identify and categorize information per content categories above
3. **Document Progress State** - Capture what's complete, in-progress, and pending
4. **Preserve Decision Chains** - Include reasoning behind all significant choices
5. **Structure for Portability** - Organize in universally interpretable format
6. **Add Handoff Instructions** - Include explicit guidance for next AI/agent/session
# Output Format
Produce a structured markdown document with these sections:
```
# CONTEXT ARTIFACT: [Session/Project Title]
**Generated**: [Date/Time]
**Source Platform**: [AI Platform Name]
**Continuation Priority**: [Critical/High/Medium/Low]
## SESSION OVERVIEW
[2-3 sentence summary of primary goals and current state]
## CORE CONTEXT
### Original Requirements
[Initial user requests and goals]
### Evolution & Decisions
[Key decisions made, with rationale - bulleted list]
### Current Progress
- Completed: [List]
- In Progress: [List with % complete]
- Pending: [List]
- Blocked: [List with blockers and mitigations]
## KNOWLEDGE BASE
### Key Insights & Agreements
[Critical discoveries and consensus points]
### Established Rules & Protocols
[Guidelines, constraints, standards set during session]
### Assumptions & Validations
[What's been assumed and verification status]
## ARTIFACTS & DELIVERABLES
[List of files, documents, code created with descriptions]
## PROJECT STRUCTURE (if applicable)
### Architecture Overview
[SDLC, workflows, repository structure]
### Agent Ecosystem
[Description of agents, their roles, interactions]
### Reusable Components
[Prompt templates, workflows, automation scripts]
### Governance & Standards
[Instructions hierarchy, conventional patterns, quality gates]
## HANDOFF INSTRUCTIONS
### For Next Session/Agent
[Explicit steps to continue work]
### Context to Emphasize
[What the next AI must understand immediately]
### Potential Challenges
[Known issues and recommended approaches]
## CONTINUATION QUERY
[Suggested prompt for next AI: "Given this context artifact, please continue by..."]
```
# Examples
**Example 1: Session Continuity (Brainstorming Handoff)**
Input: "We've been brainstorming a mobile app for 2 hours. I need to switch to Claude. Generate context artifact."
Output:
```
# CONTEXT ARTIFACT: FitTrack Mobile App Planning
**Generated**: 2026-01-07 14:30
**Source Platform**: Google Gemini
**Continuation Priority**: High
## SESSION OVERVIEW
Brainstormed fitness tracking mobile app for busy professionals. Decided on minimalist design with AI coaching. Ready for technical architecture phase.
## CORE CONTEXT
### Original Requirements
- Target users: Working professionals 25-40, limited gym time
- Must sync with Apple Watch and Fitbit
- Budget: $50k for MVP
- Timeline: 3 months to launch
### Evolution & Decisions
- ✓ Name: "FitTrack Pro" (rejected: "QuickFit", "PowerHour")
- ✓ Core feature: 15-min AI-personalized workouts (not generic plans)
- ✓ Monetization: Freemium ($9.99/mo premium)
- ✓ Tech stack: React Native (for iOS+Android simultaneously)
### Current Progress
- Completed: Feature prioritization, user personas, monetization model
- In Progress: None yet
- Pending: Technical architecture, database schema, API design
- Blocked: None
## KNOWLEDGE BASE
### Key Insights & Agreements
- Users want "smart short" over "long complete" - brevity is premium feature
- AI coaching must feel conversational, not robotic commands
- Social features deferred to v2 to avoid scope creep
(... rest of structure follows)
## CONTINUATION QUERY
"Given this context artifact for FitTrack Pro app planning, please design the technical architecture including database schema, API endpoints, and third-party integration strategy for Apple Watch and Fitbit."
```
**Example 2: Agent Handoff (Rate-Limited Automation)**
Input: "Browser agent hit rate limit while scraping competitor pricing. Generate handoff doc."
Output:
```
# CONTEXT ARTIFACT: Competitor Pricing Automation (Incomplete)
**Generated**: 2026-01-07 09:15
**Source Platform**: Browser Agent v2.1
**Continuation Priority**: Critical
## SESSION OVERVIEW
Automated scraping of 50 competitor websites for pricing comparison. Completed 32/50 before rate limiting. Need immediate continuation to meet Friday deadline.
## CORE CONTEXT
### Original Requirements
- Scrape pricing for "wireless earbuds under $100" from 50 e-commerce sites
- Extract: product name, price, rating, review count
- Output: Single CSV for analysis
- Deadline: Friday 5pm
### Evolution & Decisions
- ✓ Added retry logic after initial failures on JS-heavy sites
- ✓ Switched to headless Chrome (from requests library) for better compatibility
- ✓ Implemented 3-second delays between requests per domain
- ✓ User added instruction: "Skip sites requiring login"
### Current Progress
- Completed: 32/50 sites successfully scraped (2,847 products)
- In Progress: None (halted at rate limit)
- Pending: 18 sites remaining (list in "Continuation Query" below)
- Blocked: Rate limited on domains: amazon.com, walmart.com, target.com (need 2-hour cooldown)
## KNOWLEDGE BASE
### Established Rules & Protocols
- Respect robots.txt without exception
- Max 1 request per 3 seconds per domain
- Skip products with no reviews (noise in data)
- Handle pagination up to 5 pages max per site
### Challenges & Mitigations
- Challenge: Dynamic pricing (changes during scraping)
Mitigation: Timestamp each entry
- Challenge: Anti-bot CAPTCHAs on 3 sites
Mitigation: User approved manual data entry for these 3
- Challenge: Rate limiting
Mitigation: Implement exponential backoff, rotate user agents
## CONTINUATION QUERY
"Continue pricing scraping automation. 18 sites remaining: [bestbuy.com, newegg.com, ebay.com...]. Use existing CSV 'pricing_data_partial.csv' (2,847 entries). Rate-limited domains need 2hr wait. Prioritize non-blocked sites first. Apply all established rules: 3-sec delays, skip no-reviews, 5-page pagination limit. Deliver final CSV by Friday 5pm."
```
**Example 3: Project Migration (Full Culture Transfer)**
(Input context: Entire project repository with SDLC, agents, governance)
Output: *(Condensed example showing structure - real output would be comprehensive)*
```
# CONTEXT ARTIFACT: "SmartInventory" Project Culture & Architecture
**Generated**: 2026-01-07 16:00
**Source Platform**: GitHub Copilot + Multi-Agent System
**Continuation Priority**: Medium (onboarding new AI agent framework)
## SESSION OVERVIEW
Enterprise inventory management system using AI-driven development culture. Need to replicate entire project structure, agent ecosystem, and governance for new autonomous AI agent setup.
## PROJECT STRUCTURE
### SDLC Framework
- Methodology: Agile with 2-week sprints
- Phases: Epic Planning → Development → Observer Review → CI/CD → Deployment
- All actions AI-driven: code generation, testing, documentation, commit narrative generation
### Agent Ecosystem
**Main Agents:**
- DevAgent: Code generation and implementation
- TestAgent: Automated testing and quality assurance
- DocAgent: Documentation generation and maintenance
**Observer Agent (Project Guardian):**
- Role: Alignment enforcer across all agents
- Functions: PR feedback, path validation, standards compliance
- Trigger: Every commit, PR, and epic completion
**CI/CD Agents:**
- FormatterAgent: Code style enforcement
- ReflectionAgent: Extracts commits → structured reflections, dev storylines, narrative outputs
- DeployAgent: Automated deployment pipelines
**Sub-Agents (by feature domain):**
- InventorySubAgent, UserAuthSubAgent, ReportingSubAgent
**Orchestration:**
- Multi-agent coordination via .ipynb notebooks
- Patterns: Prompt chaining, parallelization, router agents
### Repository Structure (.github)
```
.github/
├── workflows/
│ ├── epic_breakdown.yml
│ ├── epic_generator.yml
│ ├── prd_template.yml
│ ├── architectural_plan.yml
│ ├── system_design.yml
│ ├── conventional_commit.yml
│ ├── memory_prompt.yml
│ └── log_prompt.yml
├── AGENTS.md (agent registry)
├── copilot-instructions.md (project-level rules)
└── sprints/
├── sprint_01_instructions.md
└── epic_variations/
```
### Governance & Standards
**Instructions Hierarchy:**
1. `copilot-instructions.md` - Project-wide immutable rules
2. Sprint instructions - Temporal variations per sprint
3. Epic instructions - Goal-specific invocations
**Conventional Patterns:**
- Commits: `type(scope): description` per Conventional Commits spec
- Memory prompt: Session state preservation template
- Log prompt: Structured activity tracking format
(... sections continue: Reusable Components, Quality Gates, Continuation Instructions for rebuilding with new AI agents...)
```
# Notes
- **Universality**: Structure must be interpretable by any AI platform (ChatGPT, Claude, Gemini, etc.)
- **Completeness vs Brevity**: Balance comprehensive context with readability - use nested sections for deep detail
- **Version Control**: Include timestamps and source platform for tracking context evolution across multiple handoffs
- **Action Orientation**: Always end with clear "Continuation Query" - the exact prompt for next AI to use
- **Project-Scale Adaptation**: For full project migrations (Case 3), expand "Project Structure" section significantly while keeping other sections concise
- **Failure Documentation**: Explicitly capture what didn't work and why - this prevents next AI from repeating mistakes
- **Rule Preservation**: When rules/protocols were established during session, include the context of WHY they were needed
- **Assumption Validation**: Mark assumptions as "validated", "pending validation", or "invalidated" for clarity
- - FOR GEMINI / GEMINI-CLI / ANTIGRAVITY
Here are ultra-concise versions:
GEMINI.md
"# Gemini AI Agent across platform
workflow/agent/sample.toml
"# antigravity prompt template
MEMORY.md
"# Gemini Memory
**Session**: 2026-01-07 | Sprint 01 (7d left) | Epic EPIC-001 (45%)
**Active**: TASK-001-03 inventory CRUD API (GET/POST done, PUT/DELETE pending)
**Decisions**: PostgreSQL + JSONB, RESTful /api/v1/, pytest testing
**Next**: Complete PUT/DELETE endpoints, finalize schema"# Context Preservation & Migration Prompt
[ for AGENT.MD pass THE `## SECTION` if NOT APPLICABLE ]
生成一个全面的上下文产物,用于保留所有对话上下文、进展、决策和项目结构,以便在不同 AI 会话、平台或代理之间无缝延续工作。该产物作为“上下文U盘”,使任何AI都能立即理解并继续工作,无需重复说明或丢失上下文。
## 核心目标
捕获并结构化当前会话中的所有上下文元素,以实现:
1. **会话连续性** - 在不同AI平台间恢复对话而无需重新解释
2. **代理交接** - 将未完成任务转移给新代理,并附带完整的进度记录
3. **项目迁移** - 复制整个项目的文化、工作流和治理结构
## 需保留的内容类别
### 对话上下文
- 初始需求及演进中的用户故事
- 头脑风暴期间产生的想法
- 所有决策及其完整的推理链
- 达成的协议及其验证状态
- 建议与推荐及其支持性上下文
- 已建立的假设及其当前状态
- 关键洞察与突破时刻
- 作为结构性基础的关键要点
### 进展记录
- 所有工作流的当前状态
- 已完成的任务和可交付成果
- 待办事项和下一步行动
- 遇到的阻碍及其缓解策略
- 触发的速率限制及变通解决方案
- 重要里程碑的时间线
### 项目架构(如适用)
- SDLC 方法论与阶段
- 代理生态系统(主代理、子代理、同级代理、观察代理)
- 规则、治理政策与策略
- 仓库结构(.github 工作流、模板)
- 可复用的提示词形式(史诗拆解、PRD、架构计划、系统设计)
- 约定模式(提交格式、记忆提示词、日志结构)
- 指令层级(项目级、冲刺级、史诗级变体)
- CI/CD 配置(测试、格式化、提交提取)
- 多代理编排(提示词链式调用、并行化、路由代理)
- 输出格式标准及变体
### 规则与协议
- 已确立的指导方针及其范围定义
- 会话期间新增的附加指令
- 设定的约束与边界
- 质量标准与验收准则
- 保持工作方向一致的对齐机制
# 步骤
1. **扫描对话历史** - 审查整个线程/会话中的所有互动与上下文
2. **提取核心要素** - 按照上述内容类别识别并分类信息
3. **记录进展状态** - 捕获已完成、进行中和待处理的内容
4. **保留决策链条** - 包含所有重大选择背后的推理过程
5. **结构化以利于移植** - 以通用可解析的格式组织内容
6. **添加交接说明** - 包含明确指引,供下一个AI/代理/会话使用
```
**示例 2:代理交接(限速自动化)**
输入:“浏览器代理在抓取竞争对手价格时触发速率限制。生成交接文档。”
输出:
```
# 上下文产物:竞争对手定价自动化(未完成)
**生成时间**:2026-01-07 09:15
**源平台**:Browser Agent v2.1
**继续优先级**:紧急
## 会话概览
自动化抓取 50 个竞争对手网站的价格以进行对比。在触发速率限制前已完成 32/50。需立即继续以满足周五截止期限。
## 核心上下文
### 原始需求
- 从 50 个电商平台抓取“100 美元以下无线耳塞”的价格
- 提取内容:产品名称、价格、评分、评论数量
- 输出:用于分析的单个 CSV 文件
- 截止时间:周五下午 5 点
### 演进与决策
- ✓ 在 JS 密集型网站初次失败后添加重试逻辑
- ✓ 从 requests 库切换至无头 Chrome 以获得更好兼容性
- ✓ 实施每域名请求间隔 3 秒
- ✓ 用户追加指令:“跳过需要登录的网站”
### 当前进度
- 已完成:成功抓取 32/50 个网站(2,847 件产品)
- 进行中:无(因速率限制暂停)
- 待处理:剩余 18 个网站(见下方“继续查询”中的列表)
- 受阻:在以下域名被限速:amazon.com, walmart.com, target.com(需等待 2 小时冷却)
## 知识库
### 已确立的规则与协议
- 无例外遵守 robots.txt
- 每域名最大请求频率:每 3 秒 1 次
- 跳过无评论的产品(避免数据噪声)
- 处理分页,每个网站最多 5 页
### 挑战与应对措施
- 挑战:动态定价(抓取期间价格变动)
应对措施:为每条记录添加时间戳
- 挑战:3 个网站出现反机器人 CAPTCHA
应对措施:用户批准对这 3 个网站手动录入数据
- 挑战:速率限制
应对措施:实施指数退避,轮换用户代理
## 继续查询
“继续价格抓取自动化。剩余 18 个网站:[bestbuy.com, newegg.com, ebay.com...]。使用现有 CSV 文件 'pricing_data_partial.csv'(含 2,847 条记录)。被限速的域名需等待 2 小时。优先处理未被阻断的网站。应用所有既定规则:3 秒请求间隔、跳过无评论产品、最多 5 页分页限制。务必在周五下午 5 点前交付最终 CSV。”
```
**示例 3:项目迁移(完整文化转移)**
(输入上下文:包含 SDLC、代理、治理的完整项目仓库)
输出:(展示结构的简化示例——实际输出将更全面)
```
# 上下文产物:“SmartInventory”项目文化与架构
**生成时间**:2026-01-07 16:00
**源平台**:GitHub Copilot + 多代理系统
**继续优先级**:中等(用于新 AI 代理框架的入职)
## 会话概览
使用 AI 驱动开发文化的大型企业级库存管理系统。需复制整个项目结构、代理生态系统和治理机制,以搭建新的自主 AI 代理系统。
## 项目结构
### SDLC 框架
- 方法论:采用 2 周冲刺的敏捷开发
- 阶段:史诗规划 → 开发 → 观察者评审 → CI/CD → 部署
- 所有操作均由 AI 驱动:代码生成、测试、文档、提交说明生成
### 代理生态系统
**主代理:**
- DevAgent:代码生成与实现
- TestAgent:自动化测试与质量保证
- DocAgent:文档生成与维护
**观察者代理(项目守护者):**
- 角色:确保所有代理的一致性
- 功能:PR 反馈、路径验证、标准合规
- 触发条件:每次提交、PR、史诗完成
**CI/CD 代理:**
- FormatterAgent:代码风格强制执行
- ReflectionAgent:提取提交 → 结构化反思、开发叙事、叙述性输出
- DeployAgent:自动化部署流水线
**子代理(按功能域划分):**
- InventorySubAgent、UserAuthSubAgent、ReportingSubAgent
**编排机制:**
- 通过 .ipynb 笔记本实现多代理协调
- 模式:提示词链、并行化、路由代理
### 仓库结构 (.github)
```
.github/
├── workflows/
│ ├── epic_breakdown.yml
│ ├── epic_generator.yml
│ ├── prd_template.yml
│ ├── architectural_plan.yml
│ ├── system_design.yml
│ ├── conventional_commit.yml
│ ├── memory_prompt.yml
│ └── log_prompt.yml
├── AGENTS.md (代理注册表)
├── copilot-instructions.md (项目级规则)
└── sprints/
├── sprint_01_instructions.md
└── epic_variations/
```
### 治理与标准
**指令层级:**
1. `copilot-instructions.md` - 项目范围内的不可变规则
2. 冲刺指令 - 每个冲刺的临时变体
3. 史诗指令 - 目标特定调用
**约定模式:**
- 提交格式:`type(scope): description`,遵循 Conventional Commits 规范
- 记忆提示词:会话状态保留模板
- 日志提示词:结构化活动跟踪格式
(... 后续章节包括:可复用组件、质量关卡、用于使用新 AI 代理重建的继续指令 ...)
```
- **通用性**:结构必须可被任何 AI 平台(ChatGPT、Claude、Gemini 等)解释
- **完整性与简洁性的平衡**:在全面性与可读性之间取得平衡——使用嵌套章节来呈现深层细节
- **版本控制**:包含时间戳和来源平台,以追踪多次交接中的上下文演变
- **行动导向性**:始终以明确的“延续查询”(Continuation Query)结尾——即下一个 AI 应使用的精确提示词
- **项目级适配**:对于完整项目迁移(案例 3),需大幅扩展“项目结构”部分,同时保持其他部分简洁
- **失败记录**:明确记录哪些方法未奏效及其原因——这可防止下一个 AI 重复错误
- **规则保留**:当会话期间建立了规则/协议时,需包含这些规则为何必要的上下文
- **假设验证**:将假设标记为“已验证”、“待验证”或“已被证伪”,以确保清晰
- - FOR GEMINI / GEMINI-CLI / ANTIGRAVITY
以下是超简洁版本:
GEMINI.md
"# Gemini AI Agent across platform
workflow/agent/sample.toml
"# antigravity prompt template
MEMORY.md
"# Gemini Memory
**会话**:2026-01-07 | 冲刺 01(剩余 7 天)| 史诗任务 EPIC-001(完成 45%)
**进行中**:TASK-001-03 库存 CRUD API(GET/POST 已完成,PUT/DELETE 待完成)
**决策**:PostgreSQL + JSONB,RESTful /api/v1/,pytest 测试
**下一步**:完成 PUT/DELETE 端点,定稿数据结构"