Markdown Converter
Agent skill for markdown-converter
Fix a specific bug or problem in the codebase. Analyzes code to find and fix issues without creating plans. Use when user reports a bug, error, or something not working. Always suggests test coverage and adds logging.
Sign in to like and favorite skills
Fix a specific bug or problem by analyzing the codebase directly. No plans, no reports.
Read
if it exists to understand:.ai-factory/DESCRIPTION.md
Read all patches from
if the directory exists:.ai-factory/patches/
Glob to find all *.md files in .ai-factory/patches/From
$ARGUMENTS, identify:
If unclear, ask:
To fix this effectively, I need more context: 1. What is the expected behavior? 2. What actually happens? 3. Can you share the error message/stack trace? 4. When did this start happening?
Search for the problem:
Look for:
Apply the fix with logging:
// ✅ REQUIRED: Add logging around the fix console.log('[FIX] Processing user input', { userId, input }); try { // The actual fix const result = fixedLogic(input); console.log('[FIX] Success', { userId, result }); return result; } catch (error) { console.error('[FIX] Error in fixedLogic', { userId, input, error: error.message, stack: error.stack }); throw error; }
Logging is MANDATORY because:
ALWAYS suggest covering this case with a test:
## Fix Applied ✅ The issue was: [brief explanation] Fixed by: [what was changed] ### Logging Added The fix includes logging with prefix `[FIX]`. Please test and share any logs if issues persist. ### Recommended: Add a Test This bug should be covered by a test to prevent regression: \`\`\`typescript describe('functionName', () => { it('should handle [the edge case that caused the bug]', () => { // Arrange const input = /* the problematic input */; // Act const result = functionName(input); // Assert expect(result).toBe(/* expected */); }); }); \`\`\` Would you like me to create this test? - [ ] Yes, create the test - [ ] No, skip for now
All fixes MUST include logging:
[FIX] or [FIX:<issue-id>] for easy filtering// Pattern for fixes const LOG_FIX = process.env.LOG_LEVEL === 'debug' || process.env.DEBUG_FIX; function fixedFunction(input) { if (LOG_FIX) console.log('[FIX] Input:', input); // ... fix logic ... if (LOG_FIX) console.log('[FIX] Output:', result); return result; }
User:
/fix TypeError: Cannot read property 'name' of undefined in UserProfile
Actions:
.name is accessedUser:
/fix /api/orders returns empty array for authenticated users
Actions:
User:
/fix email validation accepts invalid emails
Actions:
## Fix Applied ✅ **Issue:** [what was broken] **Cause:** [why it was broken] **Fix:** [what was changed] **Files modified:** - path/to/file.ts (line X) **Logging added:** Yes, prefix `[FIX]` **Test suggested:** Yes Please test the fix and share logs if any issues. To add the suggested test: - [ ] Yes, create test - [ ] No, skip
ALWAYS create a patch after every fix. This builds a knowledge base for future fixes.
Create the patch:
Create directory if it doesn't exist:
mkdir -p .ai-factory/patches
Create a patch file with the current timestamp as filename. Format:
YYYY-MM-DD-HH.mm.md (e.g., 2026-02-07-14.30.md)
Use this template:
# [Brief title describing the fix] **Date:** YYYY-MM-DD HH:mm **Files:** list of modified files **Severity:** low | medium | high | critical ## Problem What was broken. How it manifested (error message, wrong behavior). Be specific — include the actual error or symptom. ## Root Cause WHY the problem occurred. This is the most valuable part. Not "what was wrong" but "why it was wrong": - Logic error? Why was the logic incorrect? - Missing check? Why was it missing? - Wrong assumption? What was assumed? - Race condition? What sequence caused it? ## Solution How the fix was implemented. Key code changes and reasoning. Include the approach, not just "changed line X". ## Prevention How to prevent this class of problems in the future: - What pattern/practice should be followed? - What should be checked during code review? - What test would catch this? ## Tags Space-separated tags for categorization, e.g.: `#null-check` `#async` `#validation` `#typescript` `#api` `#database`
Example patch:
# Null reference in UserProfile when user has no avatar **Date:** 2026-02-07 14:30 **Files:** src/components/UserProfile.tsx **Severity:** medium ## Problem TypeError: Cannot read property 'url' of undefined when rendering UserProfile for users without an uploaded avatar. ## Root Cause The `user.avatar` field is optional in the database schema but the component accessed `user.avatar.url` without a null check. This was introduced in commit abc123 when avatar display was added — the developer tested only with users that had avatars. ## Solution Added optional chaining: `user.avatar?.url` with a fallback to a default avatar URL. Also added a null check in the Avatar sub-component. ## Prevention - Always check if database fields marked as `nullable` / `optional` are handled with null checks in the UI layer - Add test cases for "empty state" — user with minimal data - Consider a lint rule for accessing nested optional properties ## Tags `#null-check` `#react` `#optional-field` `#typescript`
This is NOT optional. Every fix generates a patch. The patch is your learning.
DO NOT: