|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file provides instructions for AI coding agents working on the 0xfab1 MkDocs website project. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a personal website built with MkDocs Material theme, containing 449+ markdown files across tech documentation, making guides, and personal content. The site features: |
| 8 | + |
| 9 | +- **Static Site Generator**: MkDocs with Material theme |
| 10 | +- **Content**: Tech documentation, tutorials, personal projects, and making guides |
| 11 | +- **Optimization**: Automated image conversion to WebP, build optimization, statistics generation |
| 12 | +- **Deployment**: GitHub Pages with automated CI/CD |
| 13 | + |
| 14 | +## Dev Environment Setup |
| 15 | + |
| 16 | +- **Python Environment**: Use the virtual environment in `.venv/` |
| 17 | +- **Dependencies**: Install with `pip install -r requirements.txt` |
| 18 | +- **Activate venv**: |
| 19 | + - Windows: `.venv\Scripts\Activate.ps1` |
| 20 | + - Unix: `source .venv/bin/activate` |
| 21 | + |
| 22 | +## Build Commands |
| 23 | + |
| 24 | +- **Development Server**: `python serve.py` (recommended) or `mkdocs serve` |
| 25 | +- **Build Site**: `python build.py` or `mkdocs build` |
| 26 | +- **Build with Options**: |
| 27 | + - `python build.py --serve` - Build and serve |
| 28 | + - `python build.py --clean` - Clean build |
| 29 | + - `python build.py --no-optimize` - Skip image optimization |
| 30 | +- **Generate Statistics**: `python generate_stats.py` |
| 31 | +- **Optimize Images**: `python image_optimizer.py` |
| 32 | + |
| 33 | +## Testing |
| 34 | + |
| 35 | +- **Site Testing**: `python site_tester.py` - Tests built site for issues |
| 36 | +- **Media Path Check**: `python check_media_paths.py` - Validates media file references |
| 37 | +- **Build Validation**: Always test locally before deploying |
| 38 | + |
| 39 | +## File Structure |
| 40 | + |
| 41 | +```bash |
| 42 | +docs/ # Markdown content |
| 43 | +├── about/ # Personal content |
| 44 | +├── tech/ # Technical documentation |
| 45 | +├── make/ # Making/building guides |
| 46 | +└── index.md # Homepage |
| 47 | + |
| 48 | +site/ # Built output (auto-generated) |
| 49 | +overrides/ # Theme customizations |
| 50 | +scripts/ # Build automation scripts |
| 51 | +``` |
| 52 | + |
| 53 | +## Content Guidelines |
| 54 | + |
| 55 | +- **Images**: |
| 56 | + - Place images in same directory as referencing markdown |
| 57 | + - Use `_filename.ext` naming convention |
| 58 | + - Prefer WebP format (auto-converted during build) |
| 59 | +- **Audio/Video**: Place media files in same directory as markdown |
| 60 | +- **Links**: Use relative paths for internal content |
| 61 | + |
| 62 | +## Build Process Details |
| 63 | + |
| 64 | +1. **Image Optimization**: Converts JPG/PNG to WebP, maintains originals |
| 65 | +2. **Statistics Generation**: Updates `docs/about/0xfab1/stats.md` with site metrics |
| 66 | +3. **Site Building**: MkDocs processes markdown to HTML |
| 67 | +4. **Minification**: HTML/CSS/JS minified in production |
| 68 | + |
| 69 | +## Performance Configuration |
| 70 | + |
| 71 | +- **Disabled Plugins** (for speed): |
| 72 | + - RSS plugin (was processing all 449+ files) |
| 73 | + - Git revision date plugin (was running git commands on every file) |
| 74 | + - HTML proofer (for development) |
| 75 | +- **Navigation**: |
| 76 | + - `use_directory_urls: false` for flat URL structure |
| 77 | + - Collapsed navigation by default |
| 78 | + |
| 79 | +## MkDocs Configuration |
| 80 | + |
| 81 | +- **Config File**: `mkdocs.yml` |
| 82 | +- **Theme**: Material with dark/light mode toggle |
| 83 | +- **Features**: Instant navigation, search, code highlighting |
| 84 | +- **Plugins**: Search, minify, selective RSS (when enabled) |
| 85 | + |
| 86 | +## Deployment |
| 87 | + |
| 88 | +- **Platform**: GitHub Pages |
| 89 | +- **Automation**: GitHub Actions workflow |
| 90 | +- **Process**: Push to main → Auto build → Deploy to `https://0xfab1.net` |
| 91 | + |
| 92 | +## Code Style |
| 93 | + |
| 94 | +- **Python Scripts**: Follow PEP 8, use type hints where helpful |
| 95 | +- **Markdown**: Standard markdown with consistent heading structure |
| 96 | +- **YAML**: Consistent indentation (2 spaces) |
| 97 | +- **File Naming**: Use descriptive names, `_` prefix for assets |
| 98 | + |
| 99 | +## Common Tasks |
| 100 | + |
| 101 | +### Adding New Content |
| 102 | + |
| 103 | +1. Create markdown file in appropriate `docs/` subdirectory |
| 104 | +2. Add images/media in same directory |
| 105 | +3. Test locally with `python serve.py` |
| 106 | +4. Verify media paths work correctly |
| 107 | + |
| 108 | +### Optimizing Images |
| 109 | + |
| 110 | +- Run `python image_optimizer.py` to convert new images to WebP |
| 111 | +- Script automatically updates markdown references |
| 112 | +- Original files are removed after conversion |
| 113 | + |
| 114 | +### Updating Statistics |
| 115 | + |
| 116 | +- Run `python generate_stats.py` to update site metrics |
| 117 | +- Automatically adds timestamped entries to stats.md |
| 118 | +- Tracks word counts, file changes, reading time estimates |
| 119 | + |
| 120 | +### Troubleshooting Build Issues |
| 121 | + |
| 122 | +- Check `python site_tester.py` output for broken links/issues |
| 123 | +- Verify image paths with `python check_media_paths.py` |
| 124 | +- For slow builds, ensure heavy plugins are disabled |
| 125 | +- Clean build with `python build.py --clean` |
| 126 | + |
| 127 | +## Security Considerations |
| 128 | + |
| 129 | +- **Media Files**: Ensure uploaded media doesn't contain sensitive metadata |
| 130 | +- **External Links**: Validate external references regularly |
| 131 | +- **Dependencies**: Keep MkDocs and plugins updated |
| 132 | + |
| 133 | +## Performance Notes |
| 134 | + |
| 135 | +- Site has 449+ markdown files - expect initial builds to take 1-2 minutes |
| 136 | +- Image optimization processes ~544 images |
| 137 | +- Use `--no-optimize` flag for faster development iterations |
| 138 | +- Development server supports hot reloading for content changes |
| 139 | + |
| 140 | +## Commit Guidelines |
| 141 | + |
| 142 | +- **Format**: `<type>: <description>` |
| 143 | +- **Types**: `feat`, `fix`, `docs`, `style`, `refactor`, `perf`, `test` |
| 144 | +- **Examples**: |
| 145 | + - `docs: add new ansible guide` |
| 146 | + - `feat: improve image optimization script` |
| 147 | + - `fix: resolve broken audio file paths` |
| 148 | + |
| 149 | +## Before Committing |
| 150 | + |
| 151 | +1. Run `python site_tester.py` to check for issues |
| 152 | +2. Verify build with `python build.py` |
| 153 | +3. Test key pages in browser |
| 154 | +4. Check that new media files are accessible |
| 155 | + |
| 156 | +## Agent-Specific Notes |
| 157 | + |
| 158 | +- **Large Codebase**: 449+ content files, focus on specific sections when editing |
| 159 | +- **Image Handling**: Always run image optimizer after adding new images |
| 160 | +- **Path References**: Use relative paths, maintain flat directory structure |
| 161 | +- **Build Testing**: Always test builds locally - broken builds break deployment |
| 162 | +- **Statistics**: Re-generate stats after significant content changes |
0 commit comments