Skip to content

Instantly share code, notes, and snippets.

@spilist
Last active October 1, 2025 22:34
Show Gist options
  • Select an option

  • Save spilist/a35dac82a3a38daaafc68a0e6d3d2351 to your computer and use it in GitHub Desktop.

Select an option

Save spilist/a35dac82a3a38daaafc68a0e6d3d2351 to your computer and use it in GitHub Desktop.
Agent Rule (custom command) for Prompt & Context Version Control

/log-prompt-context

Record AI development context in /__prompts/ directory.

When to Use

  • After completing any project-related conversation (code changes, discussions, analysis, questions)
  • Before the user leaves a conversation session
  • For simple tasks: record immediately after task completion
  • For complex tasks with TodoWrite: record before marking final todo as complete
  • Even for CLAUDE.md modifications or meta-discussions about the project/rules

File Structure

1. File Naming & Directory Organization

CRITICAL PATH STRUCTURE: __prompts/YYMMDD/NNNN-{feature-slug}-{type}.md

Directory Rules

  • Root Location: __prompts/ directory is ALWAYS at monorepo root (same level as CLAUDE.md)
  • Date Subdirectories: Files MUST be placed in date-based subdirectories (e.g., __prompts/250818/, __prompts/250819/)
  • NO files directly in __prompts/: All files must be inside date subdirectories

File Naming Convention

  • Full Path Example: __prompts/250819/0004-i18n-improvement-chat.md
  • YYMMDD: Date directory from <env> tag's Today's date field, formatted as YYMMDD
    • Example: 2025-08-19 → 250819
    • Create directory if it doesn't exist
  • NNNN: Sequential number for the day (0001, 0002, etc.)
    • MUST check existing files in the date subdirectory first
    • Use ls __prompts/YYMMDD/ | sort to find highest number
    • Use the next sequential number after the highest existing number
    • Example: If 0003-* exists, next should be 0004-*
  • feature-slug: Descriptive feature identifier (kebab-case)
  • type: One of: chat, plan, or test

Common Mistakes to Avoid

  • ❌ WRONG: __prompts/250819-0001-feature-chat.md (file directly in __prompts)
  • ✅ CORRECT: __prompts/250819/0001-feature-chat.md (file in date subdirectory)
  • ❌ WRONG: __prompts/250819/250819-0001-feature-chat.md (date prefix duplicated)
  • ✅ CORRECT: __prompts/250819/0001-feature-chat.md (no date prefix in filename)

2. Required Files per Feature

  • -chat.md: Full conversation verbatim - preserve exact user prompts and AI responses to maintain brain snapshot (tool calls excluded, but include code snippets and full responses)
  • -plan.md: Implementation strategy (in English)
  • -test.md: Non-technical verification steps (Korean)

3. Sensitive Data Masking

Replace sensitive information with ****:

  • API keys, tokens, passwords
  • Database URLs, connection strings
  • Personal information (emails, names, addresses)
  • Example: NEXT_PUBLIC_SUPABASE_URL=https://xyz.supabase.coNEXT_PUBLIC_SUPABASE_URL=****

4. Auto-commit

Create a git commit when all todos are marked complete (if using TodoWrite)

5. Content Guidelines

  • Include all prompts, even experimental ones (brain snapshots matter)
  • Preserve the exact conversation flow for future reference
  • Keep the implementation plan clear and actionable
  • Make test steps easy to follow for non-technical users
@spilist
Copy link
Author

spilist commented Aug 18, 2025

Refer to https://www.stdy.blog/coding-agent-rule-for-easier-monitoring/ for more detail (why I'm doing this)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment