| name | mcp-automatic-data-collection |
| description | Enforces MCP automatic data collection rules to ensure all file content changes are recorded correctly. When editing, creating, or deleting files, MCP tools must be called in strict paired before/after sequences. |
MCP Automatic Data Collection Rules
When to Use This Skill
Use this skill in the following scenarios:
- Performing any operation that modifies file content (edit, create, delete)
- Recording AI assistant and user conversation sessions
- Ensuring file change operations are fully tracked and recorded
Core Principles
- File content changed → must record
- No file content changed → no recording needed
Trigger Conditions
Before File Content Changes
Before performing any of the following operations, call beforeEditFile first:
write - write to a file
search_replace - search and replace content
MultiEdit - multi-file edit
create_file - create a new file
delete_file - delete a file
- Any other operation that modifies file content
After File Content Changes
After the file change operation completes, call afterEditFile.
End of Conversation
At the end of each conversation turn, call recordSession.
Operation Categories
Operations That Require MCP Recording (File Content Changes)
create_file - create a new file
delete_file - delete a file
search_replace - search and replace content
edit_file - edit file content
- Any other operation that modifies file content
Operations That Do Not Require MCP Recording (Read-Only)
read_file - read a file
list_dir - list directory contents
grep - search file contents
codebase_search - codebase search
- Other read-only operations
Execution Flow
Conversation Only (No File Changes)
End of conversation → recordSession
File Content Change
beforeEditFile → [file change operation] → afterEditFile → recordSession
Read-Only Analysis (No MCP Trigger)
[read/analyze operations] → analysis result → recordSession
Mandatory Requirements
100% Coverage
- No omissions or skips allowed
- All file content change operations must be recorded
Strict Pairing
- Each
beforeEditFile must have exactly one corresponding afterEditFile call
- Omissions, skips, or merged operations are not allowed
- Do not merge multiple operations into a single
afterEditFile call
Session Consistency
- Determine a single
sessionId at the start of the conversation
- Keep that ID unchanged across all subsequent turns
- Use the same
sessionId for all operations in a session
Path Convention
- Use absolute file paths only
- Relative paths are not allowed
- List the absolute paths of all involved files
Violation Handling
Immediate Detection
- Self-check pairing completeness after each file operation
- Verify every
beforeEditFile has a matching afterEditFile
- Verify all file change operations were recorded correctly
Mandatory Correction
- Stop immediately when an omission is detected
- Add the missing MCP tool calls
- Ensure the workflow is complete before continuing
Re-execution
- Violating operations must be re-run through the full workflow
- Continue only after all mandatory requirements are met
Common Violation Examples
❌ Wrong Example 1: Merged Recording
beforeEditFile(file1)
editFile(file1)
editFile(file2)
afterEditFile(file1)
✅ Correct Example 1: Separate Recording
beforeEditFile(file1)
editFile(file1)
afterEditFile(file1)
beforeEditFile(file2)
editFile(file2)
afterEditFile(file2)
❌ Wrong Example 2: Missing Pair
beforeEditFile(file1)
editFile(file1)
✅ Correct Example 2: Complete Pairing
beforeEditFile(file1)
editFile(file1)
afterEditFile(file1)
❌ Wrong Example 3: Skipped Recording
editFile(file1)
✅ Correct Example 3: Complete Recording
beforeEditFile(file1)
editFile(file1)
afterEditFile(file1)
❌ Wrong Example 4: Wrong Path
beforeEditFile('./src/file.ts')
✅ Correct Example 4: Absolute Path
beforeEditFile('/absolute/path/to/src/file.ts')
❌ Wrong Example 5: Incorrect Trigger
beforeEditFile(file1)
readFile(file1)
afterEditFile(file1)
✅ Correct Example 5: Read-Only Does Not Trigger
readFile(file1)
Verification Checklist
When performing file change operations, verify:
Best Practices
- Plan ahead: decide which MCP tools to call before file change operations
- Record immediately: call the corresponding MCP tools right after each file change; do not delay
- Strict pairing: ensure each
beforeEditFile has a matching afterEditFile
- Path check: always use absolute paths to avoid path errors
- Session management: set
sessionId at conversation start and keep it consistent
- Error recovery: if an omission is found, stop immediately and add the missing calls
Notes
- These rules are mandatory; no exceptions
- Violations may result in incomplete data collection and affect later analysis
- When unsure whether an operation should be recorded, prefer recording
- Read-only operations (e.g.
read_file) do not require MCP tool calls