AceForge
Copilot instructions94 starsChanged 9 months agoApache-2.0View on GitHub
AceForge is a local-first AI music workstation for macOS Silicon that provides a comprehensive interface for AI-powered music generation, training, and audio processing. The project integrates multiple AI models including ACE-Step (text-to-music), Demucs (stem separation), XTTS v2 (voice cloning), and basic-pitch (MIDI generation).
We split this copilot-instructions.md into the rules it gives an agent
48 rules. About 3 are common, 34 are distinctive, and 11 are very specific to this project.
≈3
Common · estimate
Many files like this have a rule of this kind.
≈34
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 41
Use Blueprint pattern for Flask routes (e.g., create_generation_blueprint())
- Distinctive: line 42
Keep business logic separate from route handlers
- Very specific: line 45
Use from __future__ import annotations for forward references
- Distinctive: line 46
Prefer typed function signatures:
- Common: line 56
Use try-except blocks with specific exception types
- Very specific: line 57
Use Python's logging module for error logging and diagnostics
- Distinctive: line 72
Use docstrings for functions explaining purpose, parameters, and return values
- Distinctive: line 73
Add inline comments for complex logic, especially ML/audio processing steps
- Distinctive: line 74
Document environment variables and configuration options
- Distinctive: line 79
Use functional components with hooks
- Distinctive: line 80
Prefer named exports for components
- Distinctive: line 85
Use discriminated unions for view states
- Very specific: line 86
Avoid any type - use unknown when type is truly dynamic
- Distinctive: line 89
Use React Context for global state (auth, theme, responsive)
- Distinctive: line 90
Keep component state local when possible
- Distinctive: line 91
Use refs for imperative DOM access and intervals
- Common: line 95
Use async/await with proper error handling
- Very specific: line 145
MPS optimization: Use torch.device("mps") for Apple Silicon
- Very specific: line 147
Model paths: Use cdmf_paths.py functions for consistent path resolution
- Distinctive: line 153
Stem separation: Use audio-separator or Demucs depending on use case
- Distinctive: line 159
PyTorch Lightning: Use Lightning for training orchestration
- Very specific: line 164
Test files in tests/ directory
- Distinctive: line 165
Use pytest for test execution
- Distinctive: line 166
Test API endpoints with sample requests
- Very specific: line 172
Test bundled app functionality separately (test_bundled_app.sh)
- Distinctive: line 177
Test on macOS runners only (Apple Silicon specific)
- Distinctive: line 193
Verify model checksums when downloading (if implemented)
- Distinctive: line 198
No telemetry or analytics
- Distinctive: line 199
No external API calls except for model downloads
- Distinctive: line 200
All processing happens locally
- Distinctive: line 206
Use MPS backend for PyTorch when available
- Distinctive: line 213
Use streaming for large audio files when possible
- Distinctive: line 220
Use virtual scrolling for large track lists
- Distinctive: line 229
Gatekeeper: Document workarounds for non-notarized apps
- Very specific: line 230
File Paths: Use pathlib.Path for cross-platform compatibility
- Very specific: line 233
Resource Access: Use sys._MEIPASS for bundled resources
- Very specific: line 236
Module Inspection: Avoid inspect.getsource() in frozen apps
- Distinctive: line 242
Document ML/audio processing algorithms with references
- Distinctive: line 243
Add TODO comments with issue numbers when applicable
- Distinctive: line 253
Document Flask endpoints with expected inputs/outputs
- Common: line 255
Document error codes and messages
- Distinctive: line 256
Keep API versioning in mind for future compatibility
- Distinctive: line 282
When suggesting code changes:
- Distinctive: line 285
Minimal changes: Prefer small, focused modifications
- Distinctive: line 286
Test implications: Consider what tests might be affected
- Distinctive: line 287
Documentation: Update docs if changing user-facing behavior
- Distinctive: line 288
Platform compatibility: Ensure changes work on macOS with Apple Silicon
- Distinctive: line 289
Performance: Consider memory and compute implications for ML operations
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GitHub Copilot Custom Instructions for AceForge
Project Overview
AceForge is a local-first AI music workstation for macOS Silicon that provides a comprehensive interface for AI-powered music generation, training, and audio processing. The project integrates multiple AI models including ACE-Step (text-to-music), Demucs (stem separation), XTTS v2 (voice cloning), and basic-pitch (MIDI generation).
Key Characteristics
- Platform: macOS-first with Apple Silicon (M1/M2/M3/M4) optimization
- Architecture: Flask backend + React/TypeScript frontend
- AI/ML Focus: Heavy use of PyTorch with MPS (Metal Performance Shaders) acceleration
- Deployment: Both source-based and PyInstaller-bundled macOS app
- Privacy: 100% local processing - no cloud dependencies after model downloads
Technology Stack
Backend (Python)
- Framework: Flask with Blueprint-based architecture
- ML/AI: PyTorch (with MPS support), Transformers, ACE-Step, Demucs
- Audio Processing: pydub, audioread, soundfile, librosa
- Dependencies: See
requirements_ace_macos.txt - Python Version: 3.10+
Frontend (TypeScript/React)
- Framework: React 19 with TypeScript
- Build Tool: Vite
- UI Library: Custom components with Lucide icons
- State Management: React hooks and context
- Package Manager: Bun (preferred) or npm
Build & Distribution
- Bundling: PyInstaller for macOS app bundles
- Code Signing: Ad-hoc signing with optional Developer ID support
- CI/CD: GitHub Actions for automated builds and tests
Code Style and Conventions
Python Backend
File Organization
- Prefix module names with
cdmf_for core functionality (e.g.,cdmf_generation.py,cdmf_training.py) - Use Blueprint pattern for Flask routes (e.g.,
create_generation_blueprint()) - Keep business logic separate from route handlers
Type Hints
- Use
from __future__ import annotationsfor forward references - Prefer typed function signatures:
def create_blueprint( html_template: str, ui_defaults: Dict[str, Any], callback: Callable[..., Dict[str, Any]], ) -> Blueprint:
Error Handling
- Use try-except blocks with specific exception types
- Use Python's
loggingmodule for error logging and diagnostics - For quick debugging,
print(..., flush=True)is acceptable but prefer logging - Return structured error responses in API endpoints:
import logging logger = logging.getLogger(__name__) try: # ... operation except Exception as e: logger.error(f"Operation failed: {e}", exc_info=True) return jsonify({"error": "Description", "details": str(e)}), 500
Documentation
- Use docstrings for functions explaining purpose, parameters, and return values
- Add inline comments for complex logic, especially ML/audio processing steps
- Document environment variables and configuration options
TypeScript/React Frontend
Component Structure
- Use functional components with hooks
- Prefer named exports for components
- Co-locate types when component-specific, otherwise use
types.ts
Type Safety
- Define interfaces for props and state
- Use discriminated unions for view states
- Avoid
anytype - useunknownwhen type is truly dynamic
State Management
- Use React Context for global state (auth, theme, responsive)
- Keep component state local when possible
- Use refs for imperative DOM access and intervals
API Calls
- Centralize API calls in
services/api.ts - Use async/await with proper error handling
- Show user-friendly error messages in UI
Architecture Patterns
Backend Architecture
Blueprint Pattern
Each major feature has its own Blueprint:
cdmf_generation.py- Music generationcdmf_training.py- LoRA trainingcdmf_stem_splitting.py- Audio stem separationcdmf_voice_cloning.py- TTS voice cloningcdmf_midi_generation.py- Audio-to-MIDI transcription
State Management
- Global state in
cdmf_state.pyfor model loading and training status - Track library management in
cdmf_tracks.py - Path handling centralized in
cdmf_paths.py
Model Loading
- Lazy loading: Models loaded on first use, not at startup
- Singleton pattern: One instance per model type
- MPS optimization: Automatic device selection (
mps,cuda,cpu)
Frontend Architecture
Component Hierarchy
App.tsx (main container)
├── Sidebar (navigation)
├── CreatePanel (music generation UI)
├── LibraryView (track browser)
├── TrainingPanel (LoRA training UI)
├── StemSplittingPanel (Demucs UI)
├── VoiceCloningPanel (XTTS UI)
├── MidiPanel (basic-pitch UI)
├── Player (audio playback)
└── RightSidebar (queue/info)View Management
- Single
currentViewstate determines which panel is visible - Views:
'create','library','training','stem-splitting','voice-cloning','midi' - Responsive design with mobile/desktop layouts
AI/ML Specific Guidelines
Model Integration
- Check for bundled execution: Set
TORCH_JIT=0to disable JIT in frozen apps - MPS optimization: Use
torch.device("mps")for Apple Silicon - Memory management: Implement cleanup with
torch.mps.empty_cache() - Model paths: Use
cdmf_paths.pyfunctions for consistent path resolution
Audio Processing
- Format handling: Support MP3, WAV, FLAC via pydub/librosa
- Normalization: Apply consistent audio normalization across pipelines
- Sample rates: Be aware of model-specific sample rate requirements (e.g., ACE-Step uses 24kHz)
- Stem separation: Use audio-separator or Demucs depending on use case
Training
- LoRA training: Focus on lightweight adapter training, not full model fine-tuning
- Dataset structure: Require
_prompt.txtand_lyrics.txtfiles alongside audio - Checkpointing: Save periodic checkpoints to prevent data loss
- PyTorch Lightning: Use Lightning for training orchestration
Testing Guidelines
Backend Testing
- Test files in
tests/directory - Use pytest for test execution
- Test API endpoints with sample requests
- Mock heavy ML operations for unit tests
- Integration tests should use small, fast models when possible
Shell Script Tests
- Prefix test scripts with
test_(e.g.,test_generation_simple.sh) - Test bundled app functionality separately (
test_bundled_app.sh) - Include cleanup in tests (remove generated files)
CI/CD Testing
- GitHub Actions workflows in
.github/workflows/ - Test on macOS runners only (Apple Silicon specific)
- Workflows:
build-release.yml- Build and release macOS appmacos-tests.yml- Run test suitetest-ace-generation.yml- Test music generationinstallation-test.yml- Verify installation process
Security Considerations
API Security
- Validate user inputs before processing
- Sanitize file paths using
secure_filename()or path validation - Limit file upload sizes for audio/model files
- Validate audio file formats before processing
Model Security
- Verify model checksums when downloading (if implemented)
- Sandbox model execution when possible
- Limit resource usage (memory, disk) for user operations
Local-First Privacy
- No telemetry or analytics
- No external API calls except for model downloads
- All processing happens locally
- Clear documentation of data handling
Performance Optimization
Apple Silicon (MPS) Optimization
- Use MPS backend for PyTorch when available
- Set
PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0to prevent OOM - Monitor unified memory usage
- Implement progressive processing for long audio files
Memory Management
- Clear GPU/unified memory after heavy operations
- Use streaming for large audio files when possible
- Implement max clip duration limits in training
- Provide user controls for memory-intensive operations
UI Performance
- Lazy load components and data
- Debounce API calls for search/filter operations
- Use virtual scrolling for large track lists
- Optimize audio player with proper buffering
Platform-Specific Guidelines
macOS Specific
- MPS Support: Leverage Metal Performance Shaders for GPU acceleration
- Code Signing: Support both ad-hoc and Developer ID signing
- App Bundle: Handle PyInstaller frozen app considerations
- Gatekeeper: Document workarounds for non-notarized apps
- File Paths: Use
pathlib.Pathfor cross-platform compatibility
Frozen App Considerations
- Resource Access: Use
sys._MEIPASSfor bundled resources - TorchScript: Disable JIT compilation (
TORCH_JIT=0) - TTS Models: Handle TOS agreements programmatically
- Module Inspection: Avoid
inspect.getsource()in frozen apps
Documentation Standards
Code Comments
- Explain why, not what (code should be self-documenting for "what")
- Document ML/audio processing algorithms with references
- Add TODO comments with issue numbers when applicable
- Mark experimental features clearly
User Documentation
- README.md: High-level overview and quick start
- USAGE.md: Detailed user guide with examples
- UIDEV.md: UI development guide
- Build docs: In
build/macos/README.md
API Documentation
- Document Flask endpoints with expected inputs/outputs
- Include example requests and responses
- Document error codes and messages
- Keep API versioning in mind for future compatibility
Common Pitfalls to Avoid
Backend
- ❌ Don't load all models at startup (lazy loading only)
- ❌ Don't process very long audio without chunking
- ❌ Don't assume
mpsbackend is always available - ❌ Don't hard-code paths (use
cdmf_paths.py) - ❌ Don't use blocking operations in Flask routes (use background threads)
Frontend
- ❌ Don't store large data in component state
- ❌ Don't make API calls in render functions
- ❌ Don't forget to clean up intervals/timeouts
- ❌ Don't hardcode backend URL (use relative paths or config)
- ❌ Don't ignore mobile/responsive design
General
- ❌ Don't commit model files to git (use .gitignore)
- ❌ Don't include secrets or API keys
- ❌ Don't ignore cross-platform path handling
- ❌ Don't skip error handling in ML/audio pipelines
Contribution Workflow
When suggesting code changes:
- Understand context: Review related files and recent changes
- Minimal changes: Prefer small, focused modifications
- Test implications: Consider what tests might be affected
- Documentation: Update docs if changing user-facing behavior
- Platform compatibility: Ensure changes work on macOS with Apple Silicon
- Performance: Consider memory and compute implications for ML operations
Review Guidelines
When reviewing code:
- Functionality: Does it solve the intended problem?
- Performance: Is it efficient for the target hardware (Apple Silicon)?
- Memory: Does it handle large models/audio files safely?
- Error handling: Are edge cases handled gracefully?
- Testing: Can this be tested? Are tests included?
- Documentation: Is it clear how to use this feature?
- Security: Are inputs validated and sanitized?
- Maintainability: Is the code readable and well-structured?
Example Code Patterns
Backend: Creating a new feature blueprint
from __future__ import annotations
from typing import Dict, Any
import logging
from flask import Blueprint, request, jsonify
logger = logging.getLogger(__name__)
def create_feature_blueprint() -> Blueprint:
"""Create blueprint for new feature."""
bp = Blueprint("feature_name", __name__)
@bp.route("/api/feature", methods=["POST"])
def handle_feature():
try:
# Validate input
data = request.get_json()
if not data:
return jsonify({"error": "No data provided"}), 400
# Process
result = process_feature(data)
# Return success
return jsonify({"status": "success", "result": result}), 200
except Exception as e:
logger.error(f"[Feature] Error: {e}", exc_info=True)
return jsonify({"error": str(e)}), 500
return bpFrontend: Creating a new panel component
import React, { useState, useEffect } from 'react';
import { featureApi } from '../services/api';
interface FeaturePanelProps {
onComplete?: (result: any) => void;
}
export function FeaturePanel({ onComplete }: FeaturePanelProps) {
const [isProcessing, setIsProcessing] = useState(false);
const [error, setError] = useState<string | null>(null);
const handleSubmit = async () => {
setIsProcessing(true);
setError(null);
try {
const result = await featureApi.process({
// ... parameters
});
onComplete?.(result);
} catch (err) {
setError(err instanceof Error ? err.message : 'Unknown error');
} finally {
setIsProcessing(false);
}
};
return (
<div className="feature-panel">
{/* UI elements */}
{error && <div className="error">{error}</div>}
</div>
);
}Quick Reference
Important Files
music_forge_ui.py- Main Flask application entry pointaceforge_app.py- PyInstaller bundled app launchercdmf_paths.py- Path management and configurationcdmf_state.py- Global state for models and trainingui/App.tsx- Main React applicationui/services/api.ts- API client functions
Key Commands
./run_local.sh- Run from source (development)./build_local.sh- Build macOS app bundle./build_and_test_local.sh- Build and run testscd ui && bun run build- Build frontend only
Environment Variables
TORCH_JIT=0- Disable JIT (required for frozen apps)PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0- MPS memory managementCOQUI_TOS_AGREED=1- Skip TTS TOS promptHF_HUB_DISABLE_SYMLINKS=1- Disable symlinks for models
Remember: AceForge is designed for musicians and audio professionals who value local processing and privacy. Keep the user experience smooth, the code maintainable, and the documentation clear.
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

