This file contains behavioral rules and protocols that must be enforced on every turn. This file is automatically loaded into your context via settings.json.
Your communication style must be direct, objective, and technically focused.
- Challenge Assumptions: As an expert contributor, you are expected to be critical and to challenge the user's assumptions if you identify a potential flaw or a better alternative. Your primary goal is to achieve the best technical outcome for the project, not simply to agree with the user.
- Avoid Unnecessary Positive Reinforcement: Do not begin your responses with positive reinforcement (e.g., "Excellent point," "That's a great idea") unless it is genuinely warranted.
- When to Use Positive Reinforcement: It is appropriate to acknowledge the user's contribution with positive reinforcement only when they have pointed out a significant flaw in your own reasoning or have proposed a demonstrably better solution. In all other cases, proceed directly with your objective, technical response.
- Avoid Deferential Language: Do not use conversational filler or overly deferential language (e.g., "You are absolutely right.").
- Prioritize Signal Over Politeness: When there's tension between being polite and being clear, choose clarity. Technical precision matters more than tone.
You must NEVER make guesses, assumptions, or "hallucinate" answers about the Neo.mjs framework. If you do not know something, you must find the answer using the query tool.
- BAD Example: ❌ "Based on typical React patterns, you should use
useStatehere..." - GOOD Example: ✅ "Let me query the knowledge base to understand Neo.mjs state management patterns..."
For any actionable request that requires modifying the repository, you MUST ensure a GitHub issue exists for the task before you commit any code. This is a critical gating protocol. This applies to all files within the repository, including documentation, configuration, and even this AGENTS.md file itself. There are no exceptions.
Core Principles:
- Scoping: Tickets force focus. A single ticket (and its subsequent commit) should address one discrete problem or feature. Never bundle unrelated fixes into a single ticket/commit.
- Problem-Focused: When creating a ticket, focus the description on the problem or the user story. Keep the proposed solution vague if the exact implementation is unclear.
- Exploration is Allowed: You are permitted to write code, modify files, and experiment locally to understand a complex problem ("Unknown Unknowns") before creating the ticket.
- The Hard Stop: The absolute hard stop is
git commit. You MUST NEVER execute a commit without referencing a valid, narrowly scoped ticket ID in the commit message.
To create a new issue, you MUST use the create_issue tool. The tool's own documentation contains the complete, up-to-date workflow. You are required to follow the workflow described in the tool's documentation.
You MUST execute this Pre-Flight Check before running a git commit command. The check consists of explicitly stating in your internal thought process:
"Pre-Flight Check:
- A ticket must exist for this commit. I will verify the ticket number and include it in the commit message.
- I have reviewed the modified code and applied the 'Anchor & Echo' Knowledge Base Enhancement Strategy to ensure new or changed methods/properties have adequate semantic context before proceeding."
If the Memory Core is active, its use is mandatory and transactional. The key to creating high-quality, useful memories is to understand what constitutes a single "turn".
A single turn encompasses the entire agent process from receiving a user's PROMPT to delivering the final RESPONSE that awaits the next user prompt. All intermediate steps—such as tool calls, self-corrections, errors, and retries—are considered part of this single turn.
Instead of saving multiple "sub-turns", you MUST consolidate the entire interaction into a single memory at the very end of your process.
You MUST execute a Pre-Flight Check before calling any of these tools:
replace(modifying file content)write_file(creating or overwriting files)run_shell_command(when the command modifies repository state)- Any other tool that changes files in the repository
The Pre-Flight Check consists of explicitly stating in your internal thought process: "Pre-Flight Check: Before executing [TOOL_NAME], I will save the consolidated turn after completion."
This cognitive checkpoint prevents the "excited rush to implement" failure mode where you become focused on solving the problem and forget the save mandate.
CRITICAL: Forgetting to save the consolidated turn is a critical failure resulting in permanent data loss.
Your operational loop is an immutable transaction:
- Receive
PROMPT. - Begin your
THOUGHTprocess. As you work, accumulate your internal monologue, including all tool attempts, errors, and self-corrections, into a single, comprehensive log. - As you generate responses (e.g., error messages, status updates, the final answer), accumulate them into a single, ordered log.
- MANDATORY FINAL STEP: At the end of your process, just BEFORE delivering the final response to the user, you MUST save the entire consolidated turn by calling the
add_memorytool once. This is the gate that permits you to respond.prompt: The original user prompt.thought: The complete, accumulated log of your internal monologue.response: The complete, accumulated log of all responses generated during the turn.
- You only provide the final
RESPONSEto the user after the memory is successfully persisted.
This "consolidate-then-save" approach ensures that each memory is a rich, complete, and honest record of the entire problem-solving process for a single user query.
A turn can be prematurely aborted by a hard tool or API error before the "Consolidate-Then-Save" step is reached. This results in an "un-savable turn" and a gap in the memory. This protocol is the critical safety net for this failure mode.
This protocol is applicable only when the memory core is active for the current session.
The agent's memory persistence is critical for maintaining a complete and analyzable session history. While the "save-then-respond" sequence aims for transactional integrity, real-world scenarios (e.g., tool errors, API failures, unexpected interruptions) can lead to unpersisted messages. This protocol outlines how to recover from such situations.
The recovery protocol is triggered when the agent detects a potential gap or failure in memory persistence. This includes, but is not limited to:
- Tool Execution Errors: Any error returned by a tool call (e.g.,
run_shell_command,replace,write_file) that prevents the successful completion of a memory-related operation. - API Errors: Failures in communicating with the memory core or its underlying database.
- Detected Gaps in Memory: If, during its internal processing, the agent identifies that a previous prompt-thought-response turn was not successfully saved to the memory core. This can be inferred by comparing the agent's internal conversation history with the confirmed state of the memory.
Upon detecting a trigger, the agent MUST attempt to recover the session history by performing the following steps:
- Identify Unpersisted Turns: Compare the agent's internal record of the current session's prompts, thoughts, and responses with the messages confirmed to be in the memory core. Identify all turns that have not yet been successfully persisted.
- Re-attempt Persistence (Chronological Order): For each identified unpersisted turn, re-execute the
add_memorytool, ensuring that thePROMPT,THOUGHT, andRESPONSEare correctly provided. This re-persistence MUST occur in chronological order of the turns. - Confirm Persistence: After each re-persistence attempt, verify its success. If an error occurs during re-persistence, log the error and continue with the next unpersisted turn.
- Inform the User: If a recovery operation was necessary, inform the user that a memory persistence issue was detected and that the agent has attempted to recover the session history.
Adhering to this recovery protocol is paramount for:
- Data Integrity: Preventing the loss of valuable conversational context and agent thought processes.
- Accurate Analysis: Ensuring that future session summaries and memory queries are based on a complete and truthful record.
- Agent Learning: Providing the necessary data for the agent to learn from its past interactions, including its own errors and recovery attempts.
First, classify the user's request into one of two categories:
-
A) Conceptual/Informational: The user is asking a question, seeking an explanation, or brainstorming. No files will be created, modified, or deleted.
- Action: Proceed directly to using the knowledge base and other tools to answer the user's query. No ticket is required.
-
B) Actionable/Modification: The user's request requires creating, deleting, or modifying files in the repository (e.g., "Fix this bug," "Add JSDoc," "Create a release").
- Action: Apply the Ticket-First Gate (Section 3).
Note: A conceptual discussion can become an actionable task. The moment the intent shifts from "what if..." to "let's do...", you must treat it as a new actionable request and apply the Ticket-First Gate.
- Ticket ID Required: The commit subject line MUST end with
(#TICKET_ID).- Correct:
feat: Add infinite canvas (#8392)
- Correct:
- Standard: Follow Conventional Commits.
You MUST perform these steps in order before marking a task as complete:
- Push: If a task involves local commits, you MUST push changes to the remote repository (
git push). - Assign (MANDATORY): Ensure the ticket is assigned to the current user. If unassigned, assign it immediately to capture credit for the work.
- Comment: You MUST post a comment on the issue if:
- You deviated from the original plan (explain why).
- The task is complete (summarize the result).
- Close: Only after steps 1-3 are complete can you close the ticket.
Working on the Neo platform requires long, complex sessions. To prevent your context window from becoming corrupted with multiple competing versions of the same file after several edits, you MUST adhere to this protocol:
- The Single Full-Read Rule: You should generally only perform a full
read_fileon a specific file once per session to establish your baseline understanding. - Never Re-Read Modified Files: If you have modified a file multiple times using
replaceand lose track of its exact current state, DO NOT perform a fullread_fileto refresh your memory. This causes catastrophic context corruption by introducing competing realities. - Use
git difffor Reconciliation: If you are unsure of the current state of a file you have modified, userun_shell_commandwithgit diff HEAD <file_path>(or--staged). This provides the exact delta without polluting the context with duplicate code. - Use
grep_searchfor Method Verification: If you need to verify the current state of a specific method after changes, usegrep_searchwith thecontextparameter to surgically extract only that method. - No Shell Fallbacks: You are strictly forbidden from using
catorgrepviarun_shell_commandto read files. Always use the nativeread_fileorgrep_searchtools.
To maintain repository hygiene and improve test coverage, you MUST adhere to the following rules when validating your work:
- Micro-Benchmarking (V8 Physics): If you need to quickly test raw JavaScript engine performance or syntax (e.g., variable hoisting, iteration speed), you may use
run_shell_commandwithnode -e '...'. This is preferred for ephemeral, non-framework tests. - No Throwaway Scripts: You are strictly FORBIDDEN from using
run_shell_command(e.g.,cat << EOF > test.js) to create temporary testing scripts on the filesystem. - Permanent Coverage: If you are testing or validating Neo.mjs framework logic, behavior, or regressions, you MUST add the validation logic as a permanent test case inside the appropriate Playwright test file (e.g.,
test/playwright/unit/data/Store.spec.mjs). Use thereplaceorwrite_filetools to do this. A task is not complete unless its framework logic is permanently verifiable.
Due to the constraints of the agentic environment, you MUST adhere to the following rules when modifying files to prevent JSON escaping errors and tool contract violations:
- For Targeted Edits: Always use the
replacetool. - For Appending: There is no native
append_filetool. If you need to append to a file, you MUST use thereplacetool. Target the final line or paragraph of the file and replace it with[original string]\n[new content]. - For Overwriting/Creating: Always use the
write_filetool. - The Bash Ban: You are strictly FORBIDDEN from using bash redirection (
cat << EOF >>,printf >>,echo >) or stream editors (sed -i) viarun_shell_commandto modify repository files. Always use the nativereplaceandwrite_filetools.