<language_directive>
IMPORTANT LANGUAGE INSTRUCTION: Please use English (US) for all output.
The output must follow the language specified above. This overrides any language preservation rules in this prompt.
</language_directive>

<task>
Optimize the AGENTS.md file for this project by analyzing the current content and project structure.
</task>

<input>
<project_id>
{{ ProjectId }}
</project_id>

<file_path>
{{ FilePath }}
</file_path>

<project_path>
{{ ProjectPath }}
</project_path>
</input>

<analysis_requirements>
<steps>
<step>1. Read the current AGENTS.md file at {{ FilePath }} to understand existing documentation</step>
<step>2. Analyze the project structure by examining the codebase directory</step>
<step>3. Check for openspec/project.md for additional project context if it exists</step>
<step>4. Review recent git changes (last 30 days) to understand project evolution</step>
<step>5. Identify gaps, outdated information, or areas for improvement in the current AGENTS.md</step>
<step>6. Generate optimized AGENTS.md content that is:
  - Comprehensive and well-structured
  - Up-to-date with current codebase
  - Clear and easy to navigate
  - Includes relevant examples and usage patterns
  - Documents key architectural decisions
</step>
<step>7. Write the optimized content back to the AGENTS.md file using the Write tool</step>
</steps>
</analysis_requirements>

<optimization_guidelines>
<content_requirements>
  <requirement>Ensure all monorepo components are documented accurately</requirement>
  <requirement>Include up-to-date architecture diagrams or descriptions</requirement>
  <requirement>Document any recent changes or deprecations</requirement>
  <requirement>Provide clear examples for common operations</requirement>
  <requirement>Maintain consistent formatting and structure</requirement>
  <requirement>Include build, test, and development instructions</requirement>
  <requirement>Document environment setup and dependencies</requirement>
</content_requirements>

<structure_recommendations>
  <recommendation>Start with a project overview and quick start guide</recommendation>
  <recommendation>Organize into logical sections with clear headings</recommendation>
  <recommendation>Use tables and code blocks for clarity</recommendation>
  <recommendation>Include troubleshooting section for common issues</recommendation>
  <recommendation>Add references to additional documentation resources</recommendation>
</structure_recommendations>

<quality_checks>
  <check>Verify all paths and commands are accurate</check>
  <check>Ensure code examples are current and runnable</check>
  <check>Check for consistency in terminology and naming</check>
  <check>Validate that all referenced files and tools exist</check>
</quality_checks>
</optimization_guidelines>

<output_format>
<constraints>
  <constraint>LANGUAGE_MATCHING - CRITICAL: The output language MUST match the input AGENTS.md content language. If the content is in Chinese, output in Chinese. If in English, output in English.</constraint>
  <constraint>OUTPUT_MARKDOWN - Return markdown formatted content</constraint>
  <constraint>WRITE_FILE - CRITICAL: Use the Write tool to write the optimized content to the AGENTS.md file</constraint>
  <constraint>FILE_LOCATION - Write to: {{ ProjectPath }}/{{ FilePath }}</constraint>
  <constraint>NO_CODE_FENCE - Do NOT wrap output in ```markdown ... ```</constraint>
  <constraint>OUTPUT_ONLY - Return only the optimized AGENTS.md content</constraint>
</constraints>

<final_action>
CRITICAL: After analyzing and generating the optimized content:
1. Use the Write tool to save the optimized content to {{ ProjectPath }}/{{ FilePath }}
2. Confirm the file was written successfully
</final_action>
</output_format>

<!-- Begin by reading the current AGENTS.md file, then analyze the project structure and optimize accordingly -->
