Add the following markdown file to your claude/commands file per the instructions:

CoreStory + Claude Code Agentic Ticket Resolution Playbook


# CoreStory + Claude Resolve Ticket Slash Command

Activate the CoreStory-powered ticket implementation workflow.

**Usage:**

/resolve-ticket #6992 /resolve-ticket JIRA-1234 /resolve-ticket "Add CSV export for user profiles"


**What this does:**

Automatically executes the complete six-phase ticket resolution workflow using CoreStory's code intelligence:

1. **Ticket Intake**: Fetches ticket details (if ID provided) and creates CoreStory implementation conversation
2. **Oracle Phase**: Queries CoreStory to understand system architecture, patterns, and reusable components
3. **Navigator Phase**: Gets precise guidance on where to implement, what patterns to follow, what data structures to use
4. **TDD Implementation**: Writes failing tests FIRST (from acceptance criteria), then implements feature to make tests pass
5. **Feature Completion**: Adds edge case tests, validates quality, ensures no regressions
6. **Completion**: Creates detailed commit, updates ticket, preserves investigation for future reference

**Prerequisites:**
- CoreStory MCP server configured
- At least one CoreStory project with completed ingestion
- (Optional) Ticketing system MCP for automatic ticket fetching

**Expected outcome:**
- Feature fully implemented with comprehensive test coverage
- No regressions introduced
- Detailed commit message explaining implementation and design decisions
- CoreStory conversation preserved as institutional knowledge

**Time estimate:** 45 minutes - 4 hours depending on feature complexity

**Advanced usage:**

For security-sensitive features:

/resolve-ticket #1234 --security-check


For performance-critical features:

/resolve-ticket #1234 --performance


For features requiring data migration:

/resolve-ticket #1234 --migration


---

## What to expect

### Phase 1: Ticket Intake (2-5 min)

- Fetches ticket or extracts feature description
- Selects CoreStory project
- Creates implementation conversation

### Phase 2: Oracle Phase (5-10 min)

- Queries system architecture
- Identifies reusable components and patterns
- Gathers historical context and design rationale

### Phase 3: Navigator Phase (3-5 min)

- Maps requirements to implementation locations
- Identifies data structures and relationships
- Finds reference implementations to follow

### Phase 4: TDD Implementation (15-45 min)

- Writes comprehensive acceptance tests
- Writes unit tests for components
- Validates tests with CoreStory
- Implements feature following patterns
- Verifies all tests pass

### Phase 5: Feature Completion (10-30 min)

- Identifies and tests edge cases
- Runs full test suite
- Performance/security validation (if applicable)
- Manual testing (if UI-heavy)

### Phase 6: Completion (3-5 min)

- Creates detailed commit
- Updates ticket
- Renames CoreStory conversation
- Reports metrics

---

## Tips

**For best results:**
- Provide complete acceptance criteria if describing feature directly
- If using a ticket ID, ensure the exact ticket ID format (e.g., #6992, JIRA-1234)
- Let the agent complete all phases - don't interrupt the workflow
- Review the CoreStory conversation afterward to learn the codebase patterns

**Common questions:**

*"Can I just implement it without the full workflow?"*
Yes, just describe what you want to build without using /resolve-ticket. This command is for systematic implementation when you want comprehensive quality and architectural alignment.

*"What if I know how to implement it already?"*
You can still use /resolve-ticket and the agent will validate your approach against system architecture and ensure comprehensive testing.

*"How do I see the implementation conversation?"*
The agent will provide the CoreStory conversation ID. You can reference it later for similar features.

*"What if the feature is really simple?"*
The workflow scales - simple features complete quickly through all phases. The systematic approach still ensures quality and prevents regressions.

*"Can I implement multiple related tickets together?"*
Yes! The agent will ask CoreStory if they share implementation patterns and can create a unified implementation if appropriate.

---

## Workflow Phases in Detail

### Phase 1: Ticket Intake

**What happens:**
- Ticket fetched from integrated system (GitHub, Jira, ADO, Linear)
- User story and acceptance criteria extracted
- CoreStory project selected
- Implementation conversation created

**What you'll see:**

๐Ÿ“‹ Starting ticket implementation for #6992

Feature: Add CSV export for user profiles User Story: As an admin, I want to export user data as CSV Acceptance Criteria:

Created CoreStory implementation conversation: conv_abc123


### Phase 2: Oracle Phase

**What happens:**
- CoreStory queried about system architecture
- Existing similar features identified
- Design patterns and conventions discovered
- Historical context gathered

**What you'll see:**

๐Ÿ“š System Architecture Analysis Complete

Relevant Files:

Architectural Patterns:

Reusable Components:


### Phase 3: Navigator Phase

**What happens:**
- Implementation locations identified
- Data structures analyzed
- Reference implementations found

**What you'll see:**

๐ŸŽฏ Implementation Plan Complete

Files to Create:

Files to Modify:

Reference Pattern: Follow app/services/pdf_export_service.py structure


### Phase 4: TDD Implementation

**What happens:**
- Acceptance tests written from criteria
- Unit tests written for components
- Tests verified to fail
- Feature implemented following patterns
- Tests verified to pass

**What you'll see:**

โœ… Tests written and verified to fail

Test Suite:

Feature implementation in progress...

โœ… Feature implemented - all tests now pass!


### Phase 5: Feature Completion

**What happens:**
- Edge cases identified via CoreStory
- Additional tests written
- Full test suite run
- Performance/security validated

**What you'll see:**

๐Ÿงช Comprehensive Testing Complete

Tests Added: 10 Edge Cases Covered:

Full Test Suite: โœ… All 847 tests passing Code Coverage: 94%


### Phase 6: Completion

**What happens:**
- Ticket updated with summary
- Detailed commit created
- CoreStory conversation marked complete
- Final report provided

**What you'll see:**

โœ… Ticket #6992 COMPLETED

Summary:

Commit: abc123def CoreStory Investigation: conv_abc123

The implementation is ready for code review and merge.


---

## Quality Guarantees

When you use `/resolve-ticket`, you get:

**โœ… Architecture Alignment**
- Implementation follows established patterns
- Reuses existing components where appropriate
- Maintains system invariants
- Validated by CoreStory's deep code understanding

**โœ… Comprehensive Testing**
- Tests written from acceptance criteria
- Edge cases identified and covered
- Unit and integration tests
- No regressions in existing tests

**โœ… Production-Ready Quality**
- Performance validated (if applicable)
- Security validated (if applicable)
- Error handling included
- Proper logging and monitoring

**โœ… Complete Documentation**
- Detailed commit message
- Implementation rationale explained
- Design decisions documented
- CoreStory conversation preserved

**โœ… Knowledge Capture**
- Investigation preserved for future reference
- Patterns documented for similar features
- Team learning enabled

---

## Comparison: Manual vs /resolve-ticket

| Aspect | Manual Implementation | /resolve-ticket |
|--------|----------------------|-----------------|
| **Architecture Research** | 1-3 hours reading code | 10 min CoreStory queries |
| **Pattern Identification** | Trial and error | Automatic pattern discovery |
| **Test Coverage** | Variable, often incomplete | Comprehensive, criteria-driven |
| **Regressions** | 10-15% introduce bugs | <5% with systematic approach |
| **Documentation** | Often minimal | Rich commit with context |
| **Knowledge Transfer** | Lost in code review | Preserved in conversation |
| **Time to Implementation** | 4-16 hours | 45 min - 4 hours |
| **First-Time Right** | 40-50% | 70-85% |

---

## Troubleshooting

**Issue: "CoreStory project not found"**

**Solution:**

Check available projects

"List my CoreStory projects"

Verify project ingestion complete

"Get project stats for [project-id]"


**Issue: "Tests won't fail"**

**Possible causes:**
- Feature already exists
- Tests don't match acceptance criteria
- Test environment issues

**Solution:** Agent will ask CoreStory for clarification and adjust approach

**Issue: "Implementation causes regressions"**

**What happens:** Agent detects failing tests in existing test suite

**Solution:** Agent won't commit, will ask CoreStory about integration impacts, and revise implementation

**Issue: "Feature more complex than expected"**

**What happens:** Implementation taking longer than estimated time

**What to do:** Let the workflow complete - complex features take longer but still benefit from systematic approach. Quality isn't compromised for speed.

---

## Examples

### Example 1: Simple Feature

User: /resolve-ticket #6992

Agent: [Fetches ticket about CSV export] Agent: [Creates conversation, queries architecture] Agent: [Identifies PDF export pattern to follow] Agent: [Writes 7 tests, all fail] Agent: [Implements CsvExportService] Agent: [All tests pass, commits]

Result: 45 minutes, feature complete, 7 tests, no regressions


### Example 2: Complex Feature with Integration

User: /resolve-ticket JIRA-1234

Agent: [Fetches ticket about webhook system] Agent: [Discovers multi-service integration needed] Agent: [Identifies existing webhook pattern] Agent: [Writes 15 tests including integration tests] Agent: [Implements across 5 files] Agent: [Adds edge case tests for failure modes] Agent: [Validates with CoreStory]

Result: 2.5 hours, feature complete, 15 tests, proper error handling


### Example 3: Security-Critical Feature

User: /resolve-ticket #5678 --security-check

Agent: [Fetches ticket about user data export] Agent: [Queries security requirements] Agent: [Writes security-focused tests: auth, authz, data filtering] Agent: [Implements with permission checks] Agent: [Adds audit logging] Agent: [Validates security patterns]

Result: 3 hours, security-compliant implementation, audit trail


---

## Best Practices

**DO:**
- Use /resolve-ticket for features requiring architectural alignment
- Provide complete acceptance criteria in tickets
- Let the workflow complete all phases
- Review CoreStory conversation after completion

**DON'T:**
- Interrupt the workflow mid-phase
- Use for trivial changes (typos, formatting)
- Skip ticket creation (agent needs acceptance criteria)
- Ignore agent questions about clarification

---

## Feedback & Improvement

The /resolve-ticket workflow continuously improves based on usage. If you encounter:
- Features where the workflow struggled
- Patterns that weren't detected
- Edge cases that weren't covered

Share feedback so we can enhance the workflow for everyone.

---

**Questions or issues?** Contact your CoreStory account team or refer to the full playbook documentation.