Create complete runnable companion projects for articles - scaffolded projects, not snippets
Create complete, executable companion projects that readers can clone and run immediately.
Companion projects must be COMPLETE and RUNNABLE, not snippets or partial code.
A Laravel companion project is a full Laravel installation. A Node companion project is a full Node project. A document companion project is a complete, usable document.
Every code companion project MUST be verified by actually running it before it is considered complete.
This is NOT optional. A companion project that hasn't been executed and tested is NOT complete.
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
ā COMPANION PROJECT CREATION FLOW ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
ā ā
ā 1. SCAFFOLD Create base project (composer/npm/etc) ā
ā ā ā
ā 2. CUSTOMIZE Add article-specific code ā
ā ā ā
ā 3. VERIFY ā ACTUALLY RUN THE CODE ā
ā ā ā
ā āāā Install dependencies ā Must succeed ā
ā āāā Run application ā Must start without errors ā
ā āāā Run tests ā All tests must pass ā
ā ā ā
ā āāā ā
All pass ā Companion project complete ā
ā āāā ā Any fail ā Fix code, return to step 3 ā
ā ā
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
| Type | Install | Run | Test |
|---|---|---|---|
| Laravel | composer install |
php artisan serve |
php artisan test |
| Node.js | npm install |
npm start or node src/index.js |
npm test |
| Python | pip install -r requirements.txt |
python src/main.py |
pytest |
| React | npm install |
npm start |
npm test |
| Vue | npm install |
npm run dev |
npm test |
| Go | go mod download |
go run . |
go test ./... |
You must actually execute these commands and confirm they succeed:
# Example: Laravel verification
cd code
# 1. Install - MUST SUCCEED
composer install
# ā Check: No errors, vendor/ folder created
# 2. Setup - MUST SUCCEED
cp .env.example .env
php artisan key:generate
touch database/database.sqlite
php artisan migrate
# ā Check: No errors, database has tables
# 3. Run - MUST START
php artisan serve &
# ā Check: Server starts on localhost:8000
# ā Check: Can access in browser (if web app)
# Then stop the server
# 4. Test - ALL MUST PASS
php artisan test
# ā Check: "Tests: X passed" with 0 failures
If ANY step fails:
Before marking a companion project complete, confirm:
install_command executed successfully (no errors)run_command starts the application without errorstest_command executed successfullyDO NOT proceed to the next phase until all boxes are checked.
code)Complete application installations that can be:
Creation Process:
# 1. Create full Laravel project
cd content/articles/YYYY_MM_DD_slug/
composer create-project laravel/laravel code --prefer-dist
# 2. Configure for SQLite (no external DB)
cd code
cp .env.example .env
sed -i 's/DB_CONNECTION=mysql/DB_CONNECTION=sqlite/' .env
touch database/database.sqlite
php artisan key:generate
# 3. Install Pest
composer require pestphp/pest --dev --with-all-dependencies
php artisan pest:install
# 4. Add article-specific code
# - Models, Controllers, Routes, Views
# - Migrations, Seeders
# - Tests
# 5. VERIFY - Run migrations and tests
php artisan migrate
php artisan test
# ā ļø DO NOT CONTINUE IF TESTS FAIL
Required Files (auto-generated by Laravel):
code/
āāā app/
ā āāā Http/Controllers/
ā āāā Models/
ā āāā Providers/
āāā bootstrap/
āāā config/
āāā database/
ā āāā migrations/
ā āāā seeders/
ā āāā database.sqlite
āāā public/
āāā resources/views/
āāā routes/
ā āāā web.php
ā āāā api.php
āāā storage/
āāā tests/
ā āāā Feature/
ā āāā Unit/
āāā .env
āāā .env.example
āāā artisan
āāā composer.json
āāā composer.lock
āāā package.json
āāā phpunit.xml
āāā README.md # Custom: explains the companion project
Article-Specific Additions:
app/Models/app/Http/Controllers/routes/web.php or routes/api.phpresources/views/database/migrations/database/seeders/tests/Feature/README.md Template:
# Companion Project: [Article Topic]
Complete Laravel application demonstrating [concept].
## Requirements
- PHP 8.2+
- Composer
## Installation
\`\`\`bash
cd code
composer install
cp .env.example .env
php artisan key:generate
touch database/database.sqlite
php artisan migrate --seed
\`\`\`
## Run the Application
\`\`\`bash
php artisan serve
\`\`\`
Visit http://localhost:8000 to see the example.
## Run Tests
\`\`\`bash
php artisan test
\`\`\`
## What This Demonstrates
1. [Concept 1] - See `app/Models/Example.php`
2. [Concept 2] - See `app/Http/Controllers/ExampleController.php`
3. [Concept 3] - See `tests/Feature/ExampleTest.php`
## Key Files
| File | Description |
|------|-------------|
| `app/Models/Post.php` | Demonstrates [concept] |
| `routes/web.php` | Routes for [feature] |
| `tests/Feature/PostTest.php` | Tests for [feature] |
## Article Reference
This companion project accompanies: "[Article Title]"
Creation Process:
# 1. Create project
cd content/articles/YYYY_MM_DD_slug/
mkdir code && cd code
npm init -y
# 2. Install dependencies
npm install express
npm install --save-dev jest
# 3. Configure package.json
# Add scripts: "start", "test", "dev"
# 4. Add article-specific code
# 5. Run tests
npm test
Structure:
code/
āāā src/
ā āāā index.js
ā āāā routes/
ā āāā controllers/
āāā tests/
ā āāā example.test.js
āāā package.json
āāā package-lock.json
āāā README.md
Creation Process:
# 1. Create project
cd content/articles/YYYY_MM_DD_slug/
mkdir code && cd code
python -m venv venv
# 2. Create requirements.txt
# 3. Add article-specific code
# 4. Add tests with pytest
Structure:
code/
āāā src/
ā āāā main.py
āāā tests/
ā āāā test_main.py
āāā requirements.txt
āāā setup.py
āāā README.md
document)Complete, usable documents that readers can adapt.
Types:
Structure:
code/
āāā templates/
ā āāā project-plan-template.md
ā āāā sprint-planning-template.md
āāā examples/
ā āāā project-plan-filled.md
ā āāā sprint-planning-filled.md
āāā README.md
Each template must be:
diagram)Complete Mermaid diagrams that render correctly.
Structure:
code/
āāā diagrams/
ā āāā architecture.mermaid
ā āāā sequence.mermaid
ā āāā flowchart.mermaid
āāā rendered/ # Optional: PNG exports
ā āāā architecture.png
āāā README.md
Each diagram must:
config)Complete, working configuration files.
Structure:
code/
āāā docker/
ā āāā Dockerfile
ā āāā nginx.conf
ā āāā php.ini
āāā docker-compose.yml
āāā .env.example
āāā README.md
Must be:
docker-compose up works)script)Complete, executable scripts.
Structure:
code/
āāā scripts/
ā āāā deploy.sh
ā āāā backup.sh
ā āāā setup.sh
āāā lib/
ā āāā helpers.sh
āāā README.md
Must be:
chmod +x)#!/bin/bash)dataset)Complete datasets with schema.
Structure:
code/
āāā data/
ā āāā sample-data.json
ā āāā sample-data.csv
ā āāā seed.sql
āāā schemas/
ā āāā schema.json
āāā README.md
template)Reusable file templates.
Structure:
code/
āāā templates/
ā āāā component.tsx.template
ā āāā controller.php.template
ā āāā model.php.template
āāā generated/ # Example outputs
ā āāā UserController.php
āāā README.md
spreadsheet)Complete spreadsheets with formulas.
Structure:
code/
āāā spreadsheets/
ā āāā budget-tracker.xlsx
ā āāā project-timeline.xlsx
āāā csv/
ā āāā raw-data.csv
āāā README.md
Based on article content:
| Article Topic | Companion Project Type | What to Create |
|---|---|---|
| Laravel feature | code |
Full Laravel app |
| API design | code |
Full API server |
| Architecture | diagram |
Mermaid diagrams |
| Project management | document |
Complete templates |
| DevOps | config |
Docker setup |
| Automation | script |
Executable scripts |
| Data analysis | dataset + code |
Data + analysis code |
For code companion projects, ALWAYS start with proper project scaffolding:
# Laravel
composer create-project laravel/laravel code
# Node.js
mkdir code && cd code && npm init -y
# Python
mkdir code && cd code && python -m venv venv
# React
npx create-react-app code
# Vue
npm create vue@latest code
After base project exists:
Code Companion Projects Checklist:
composer install / npm install worksDocument Companion Projects Checklist:
Every companion project needs a README.md with:
## Setting Up the Project
Clone the example and install dependencies:
\`\`\`bash
cd code
composer install
cp .env.example .env
php artisan key:generate
\`\`\`
See the complete working companion project in the `code/` folder.
When showing code in the article, reference actual files:
Here's our Post model (`code/app/Models/Post.php`):
\`\`\`php
// From: code/app/Models/Post.php
<?php
namespace App\Models;
class Post extends Model
{
// ... actual code from example
}
\`\`\`
ALWAYS load settings before creating companion projects.
# View settings for your example type
bun run "${CLAUDE_PLUGIN_ROOT}"/scripts/show.ts settings code
Or use article-stats.ts for programmatic access:
bun run "${CLAUDE_PLUGIN_ROOT}"/scripts/article-stats.ts --json
// Database settings ā companion_project_defaults.code
{
"technologies": ["Laravel 12", "Pest 4", "SQLite"],
"scaffold_command": "composer create-project laravel/laravel code --prefer-dist",
"post_scaffold": [
"cd code",
"composer require pestphp/pest pestphp/pest-plugin-laravel --dev --with-all-dependencies",
"php artisan pest:install",
"sed -i 's/DB_CONNECTION=.*/DB_CONNECTION=sqlite/' .env",
"touch database/database.sqlite"
],
"run_command": "php artisan serve",
"test_command": "php artisan test"
}
If the article task has a companion_project field, those values override settings:
settings defaults + article.companion_project = final config
āāāāāāāāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā āāāāāāāāāāāā
scaffold_command: X scaffold_command: Y Y (article wins)
technologies: [A, B] (not set) [A, B] (use default)
has_tests: true has_tests: false false (article wins)
# 1. Run scaffold_command
composer create-project laravel/laravel code --prefer-dist
# 2. Run each post_scaffold command
cd code
composer require pestphp/pest pestphp/pest-plugin-laravel --dev --with-all-dependencies
php artisan pest:install
# ... etc
# From settings.companion_project_defaults.code.test_command
php artisan test
Global defaults from database settings:
{
"companion_project_defaults": {
"code": {
"technologies": ["Laravel 12", "Pest 4", "SQLite"],
"scaffold_command": "composer create-project laravel/laravel code",
"post_scaffold": [
"cd code",
"composer require pestphp/pest --dev",
"php artisan pest:install"
]
}
}
}
Article can override:
{
"companion_project": {
"type": "code",
"technologies": ["Laravel 11", "PHPUnit", "MySQL"],
"scaffold_command": "composer create-project laravel/laravel:^11.0 code"
}
}
code/
āāā app/Models/Post.php # Just one file!
āāā README.md
code/
āāā app/ # Full Laravel structure
āāā bootstrap/
āāā config/
āāā database/
āāā public/
āāā resources/
āāā routes/
āāā storage/
āāā tests/
āāā .env.example
āāā artisan
āāā composer.json
āāā README.md
// Example that might not work
class PostController {
public function index() {
return Post::all(); // Is Post even defined?
}
}
// Tested with: php artisan test
class PostController extends Controller
{
public function index()
{
return Post::with('comments')->paginate(10);
}
}
// tests/Feature/PostTest.php exists and passes
After creating companion project, update the article record in the database:
{
"companion_project": {
"type": "code",
"path": "code/",
"description": "Complete Laravel app with rate limiting",
"technologies": ["Laravel 12", "Pest 4", "SQLite"],
"has_tests": true,
"scaffold_command": "composer create-project laravel/laravel code",
"files": [
"app/Http/Controllers/ApiController.php",
"app/Http/Middleware/RateLimitMiddleware.php",
"routes/api.php",
"tests/Feature/RateLimitTest.php"
],
"run_instructions": "composer install && php artisan serve",
"test_command": "php artisan test",
"verified": true,
"verified_at": "2025-01-15T14:00:00Z"
}
}