Best Practices
Guidelines for effective code assistance and documentation usage in Alex Sidebar
Writing Effective Prompts
Clear Objectives
- Be specific about your goals
- State what you want to achieve
- Provide clear success criteria
Contextual Details
- Share relevant code snippets
- Include error messages
- Mention project requirements
Using Think First Mode
When to Use
- Complex architectural decisions
- Bug investigation
- Performance optimization
- Security considerations
When to Skip
- Quick syntax questions
- Simple code completions
- Documentation lookups
- Basic refactoring
Tips for Think First Mode
- Allow extra time for the dual-model processing
- Provide detailed context for better analysis
- Use it for mission-critical code changes
- Consider disabling for rapid prototyping phases
Examples
❌ Ineffective: My code isn't working. Can you help?
✅ Effective: I'm getting a 'Thread 1: Fatal error: Unexpectedly found nil' when trying to unwrap an optional UIImage in my custom UICollectionViewCell. Here's my cellForItemAt implementation...
✅ Feature Request: I need to implement a custom tab bar in SwiftUI that shows a circular progress indicator around the selected tab icon. The progress should be animated. Here's my current TabView implementation...
Managing Context
File Context
- Use @ Files to add specific files
- Include related dependencies
- Share configuration files
Codebase Context
- Use @ Codebase for framework-level questions
- Reference specific components
- Share relevant modules
Examples
❌ Limited: How do I update this delegate method?
✅ Complete: I need to update this UITableViewDelegate method to handle custom swipe actions. Here's my current implementation (@Files TableViewController.swift) and the custom SwipeActionView (@Files Views/SwipeActionView.swift) I want to integrate.
✅ Framework: I'm building a custom networking layer (@Codebase Networking/*). Can you help me implement proper retry logic with exponential backoff?
Using Documentation
Apple Documentation
- Use @ Apple Docs for framework reference
- Reference specific APIs
- Include version information
Individual Docs
- Use @ Apple Docs (Individual) for specific methods
- Reference specific classes
- Include parameter details
Examples
❌ Vague: How do I use Core Data?
✅ Specific: I need help implementing NSFetchedResultsController (@Apple Docs NSFetchedResultsController) with multiple sections based on dates. Here's my current Core Data model (@Files Model.xcdatamodeld)...
✅ API Reference: Can you explain how to use URLSession's (@Apple Docs URLSession) background download tasks with proper delegate handling (@Apple Docs URLSessionDownloadDelegate)?
Platform-Specific Best Practices
Swift Best Practices
- Use Swift-specific terminology
- Reference Swift documentation
- Include Swift version
UIKit/AppKit
- Reference UI frameworks
- Include view hierarchy
- Share layout constraints
Examples
❌ Ambiguous: How do I create a button?
✅ SwiftUI: I'm using SwiftUI (iOS 16+) and need to create a custom button with a gradient background, dynamic shadow, and haptic feedback. Here's my current Button implementation...
✅ UIKit Integration: I need to embed this SwiftUI view (@Files CustomView.swift) into my existing UIKit navigation stack. Here's my current UIHostingController setup...
Common Scenarios
Debugging
- Share error messages
- Include stack traces
- Reference relevant code
Refactoring
- Explain current structure
- Describe desired outcome
- Share relevant files
Examples
❌ Unclear: The app crashes sometimes.
✅ Detailed: The app crashes when switching between tabs while a network request is in progress. Here's the crash log and relevant networking code (@Files NetworkManager.swift). The issue started after implementing async/await...
✅ Refactoring: I want to refactor this massive view controller (@Files ProfileViewController.swift) into smaller components using MVVM. Here's my planned architecture diagram...
Examples
❌ Too Much: Sharing entire project files for a simple UI fix
✅ Just Right: Continuing from our previous chat about the networking layer (see chat history), I need to add request caching. Here's the specific RequestCaching protocol I want to implement...
✅ Breaking Down: `I need to migrate this UIKit project to SwiftUI. Let’s break it down:
- First, let’s handle the navigation structure
- Then, convert each view controller individually
- Finally, implement the data flow with @StateObject and ObservableObject`
Working with Build Errors
Build & Fix Errors Button
- Use for automatic error resolution
- Alex handles the entire build-fix cycle by using Xcode’s build system
- No manual intervention needed
- Continues until build succeeds
When to Use Automatic Build & Fix
Examples
✅ Automatic Fix: Click "Build & Fix Errors" when you see multiple red errors in Xcode. Alex will handle missing imports, protocol conformance, and type issues automatically one by one until the build succeeds.
Build Error Best Practices
- Let Alex Work: Do not interrupt the build-fix loop unless necessary
- Review Changes: Always review the final working code
- Save Progress: Use checkpoints after successful builds
Community Resources
Need more help? Join the Discord community for support and tips from other developers.