Export your ProcessWire site structure as AI-optimized context for ChatGPT, Claude, and other AI assistants.
Context automatically generates comprehensive documentation of your ProcessWire site in formats optimized for AI assistants. Instead of manually explaining your site structure every time, upload the exported files and AI immediately understands your templates, fields, page hierarchy, and code patterns.
Perfect for:
- π€ Working with AI coding assistants (Claude, ChatGPT, Copilot)
- π Onboarding new developers
- π Site migrations and documentation
- π Rapid development with AI pair programming
- π Maintaining consistent code standards
- π Site Structure - JSON and ASCII tree visualization of entire page hierarchy
- π Templates & Fields - Complete template definitions with field types, options, and configurations
- π§ Configuration - ProcessWire version, PHP settings, installed modules
- π¦ Custom Classes - Automatic detection of custom Page classes from
/site/classes/ - π¨ Frontend Stack - Auto-detects Alpine.js, Tailwind CSS, UIkit, and other frameworks
- π Content Samples - Export real page examples for each template
- π API Documentation - Generate JSON schemas for REST API development
- πΎ Code Snippets - Customized selector patterns and helper functions
- π€ AI Prompts - Ready-to-use context prompts for AI assistants
- π Performance Metrics - Site statistics and performance data
- π οΈ IDE Integration - Generate
.cursorrulesand.claudecode.jsonfiles
Code snippets are automatically customized for your site type:
- Generic / Mixed Content - General purpose patterns
- Blog / News / Magazine - Posts, authors, categories, archives
- E-commerce / Online Store - Products, cart, orders, inventory
- Business / Portfolio / Agency - Services, team, projects, testimonials
- Catalog / Directory / Listings - Brands, categories, hierarchical data
cd /site/modules/
git clone https://github.com/mxmsmnv/Context.gitThen refresh modules in admin and install.
- Download the module from the ProcessWire Modules Directory
- Place files in
/site/modules/Context/ - In ProcessWire admin: Modules β Refresh
- Click Install next to "Context"
Setup β Modules β Context β Configure
- Choose your site type (Blog, E-commerce, Business, Catalog, or Generic)
- Enable optional features you need:
- β Export Content Samples
- β Generate API Documentation
- β Create Code Snippets
- β Create AI Prompts
- Set samples per template (1-10)
- Enable auto-update if you want automatic exports on template/field changes
Click "Re-Export Context for AI" or visit:
/processwire/module/?name=Context
Files are generated in: /site/assets/context/
Upload these files to your AI assistant:
Essential files:
prompts/project-context.md- Complete site overviewtemplates.json- All templates and fieldsstructure.txt- Page hierarchy
For development:
snippets/selectors.php- Customized code examplessnippets/helpers.php- Utility functionsclasses.json- Custom Page classes
Example prompt:
I've uploaded my ProcessWire site context. Please help me create
a new template for blog posts with title, body, author, and
categories fields. Follow the existing patterns in templates.json.
/site/assets/context/
βββ README.md # Documentation
βββ structure.json # Complete page tree (JSON)
βββ structure.txt # ASCII tree visualization
βββ templates.json # Templates with fields
βββ templates.csv # Templates in CSV
βββ config.json # Site configuration
βββ modules.json # Installed modules
βββ classes.json # Custom page classes
β
βββ samples/ # Content examples (optional)
βββ api/ # API schemas (optional)
βββ snippets/ # Code library (optional)
βββ prompts/ # AI prompts (optional)
βββ metadata/ # Technical data (optional)
| File | Contains | Use For |
|---|---|---|
structure.json |
Complete page hierarchy with IDs, URLs | Navigation, finding pages |
structure.txt |
ASCII tree visualization | Quick overview |
templates.json |
All templates with field definitions | Template development |
config.json |
PW version, PHP, modules, frontend stack | Environment setup |
classes.json |
Custom Page classes from /site/classes/ |
OOP development |
snippets/selectors.php |
Site-type customized code examples | Learning patterns |
prompts/project-context.md |
Complete AI system prompt | AI onboarding |
Code snippets are generated from templates in ContextSnippets.php. To add your own patterns:
- Open
/site/modules/Context/ContextSnippets.php - Edit the appropriate method:
getBlogSelectors()- Blog-specific examplesgetEcommerceSelectors()- E-commerce examplesgetBusinessSelectors()- Business examplesgetCatalogSelectors()- Catalog examplesgetUniversalSelectors()- Always included
- Re-export context
Example - Adding a custom pattern:
protected static function getBlogSelectors($t1) {
return '// ... existing code ...
// YOUR CUSTOM PATTERN
// Get trending posts from last 7 days
$trending = $pages->find("template=post, created>=-7 days, views>50, sort=-views");
';
}Choose your site type to get customized code snippets:
- Generic / Mixed Content
- Blog / News / Magazine
- E-commerce / Online Store
- Business / Portfolio / Agency
- Catalog / Directory / Listings
- Export Content Samples - Include real page examples
- Samples Per Template - How many examples (1-10)
- Generate API Documentation - Create JSON schemas
- Export URL Routes - URL segment configurations
- Export Performance Metrics - Site statistics
- Create Code Snippets - PHP examples customized for site type
- Create AI Prompts - Ready-to-use prompts
- Maximum Tree Depth - Page tree depth limit (3-20)
- JSON Children Limit - Max children per page (5-100)
- Compact Mode - Collapse large lists
- Auto-Update on Changes - Auto-export on template/field save
- Create IDE Integration Files -
.cursorrules,.claudecode.json - Custom AI Instructions - Project-specific AI instructions
# Upload to Claude/ChatGPT:
- prompts/project-context.md
- templates.json
- snippets/selectors.php
# Then ask:
"Create a product filter with price range, category, and brand using
the patterns from selectors.php"
Share the /site/assets/context/ folder with new team members. They get:
- Complete site structure overview
- All templates and field definitions
- Code examples and patterns
- Custom Page classes documentation
# Upload:
- api/schemas/product-schema.json
- snippets/api-examples.php
# Ask:
"Create a REST API endpoint for products with search and filtering"
Export generates human-readable documentation:
structure.txt- Visual page hierarchytemplates.csv- Spreadsheet of all templatesREADME.md- Complete documentation
# Upload:
- classes.json
- templates.json
- snippets/selectors.php
# Ask:
"Review my custom Page classes and suggest improvements following
ProcessWire best practices"
Enable Auto-Update on Changes to automatically regenerate context when you:
- Create or modify templates
- Add or modify fields
- Change template-field assignments
Hooks into:
Templates::savedFields::savedFieldgroups::saveReady
- Always include
prompts/project-context.md- contains system instructions - For field questions - include
templates.json - For site structure - include
structure.txt - For coding - include
snippets/selectors.php - For debugging - include relevant
samples/[template]-samples.json
- Small tasks (1-3 files): Upload to chat directly
- Medium tasks (3-10 files): Core files + specific sections
- Large projects: Use Claude Projects with entire
/context/folder
- After adding/modifying templates
- After adding/modifying fields
- After changing site structure
- After changing Site Type setting
- Before major development sessions
- ProcessWire 3.x
- PHP 8.1 or higher
- Write permissions for
/site/assets/context/
- Export typically takes 1-3 seconds
- Uses ProcessWire's caching where possible
- Auto-update hooks are lightweight (< 50ms)
- Exports are stored in
/site/assets/(protected by ProcessWire) - No sensitive data (passwords, API keys) is exported
- Only accessible to logged-in superusers by default
- Module:
/site/modules/Context/ - Exports:
/site/assets/context/ - Snippets Library:
/site/modules/Context/ContextSnippets.php
Contributions are welcome! Areas for improvement:
- Additional site type templates
- More code snippet examples
- Translations
- Integration with other AI tools
- Documentation improvements
MIT License - see LICENSE file for details
Maxim Alex
- Website: smnv.org
- Email: maxim@smnv.org
- GitHub: @mxmsmnv