Ci4 logo

Ci4

Community
enlivenapp
ci4

Comprehensive CodeIgniter 4 framework skill. Use when working with any CodeIgniter 4 project — routing, controllers, models, views, query builder, migrations, filters, services, Spark CLI, and Shield auth. Activates on mentions of "CodeIgniter", "CI4", "spark", "CI4 model", "CI4 controller", "CI4 route", or any CI4-specific pattern.

Overview

Publisherenlivenapp
RepositoryCodeigniter4-App-and-API-Skills-for-Claude-Code
Skill nameci4
Stars
27
Forks
9
Bundled files
12
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 12 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by enlivenapp on GitHub. Read the source before you install it.

Installation

Install the Ci4 AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/enlivenapp/Codeigniter4-App-and-API-Skills-for-Claude-Code/tree/main/ci4
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/enlivenapp/Codeigniter4-App-and-API-Skills-for-Claude-Code.git /tmp/Codeigniter4-App-and-API-Skills-for-Claude-Code
mkdir -p .claude/skills
cp -r /tmp/Codeigniter4-App-and-API-Skills-for-Claude-Code/ci4 .claude/skills/ci4
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Ci4 in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Ci4 on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Ci4 is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

CodeIgniter 4 — Framework Reference

CodeIgniter 4 is a full-stack PHP 8+ MVC framework. It is not Laravel. Do not apply Laravel APIs, method names, or conventions here. When in doubt, check this skill and its references — not memory of another framework.

Related skills: ci4-api for REST API patterns, ci4-shield for authentication/authorization.

Reference Documents

For deep dives, read the relevant reference from references/:

ReferenceWhen to read
references/routing.mdRoute groups, placeholders, named routes, resource routes
references/controllers.mdResourceController, request data, validation, redirects, flash data
references/models.mdCRUD, soft deletes, timestamps, validation, pagination, scopes, callbacks, entities
references/query-builder.mdSELECT, WHERE, JOIN, GROUP BY, batch ops, subqueries, transactions, debugging
references/views.mdLayouts, sections, partials, escaping, view cells
references/filters.mdCreating, registering, applying, global filters, filter arguments
references/database.mdMigrations, seeds, forge, field types, adding/dropping columns
references/validation.mdAll validation rules, custom rules, file upload validation
references/services-helpers.mdServices, helpers, caching, email, sessions, encryption
references/spark-cli.mdAll spark commands, generators, custom commands
references/testing.mdPHPUnit, feature tests, database tests, mocking
references/gotchas.mdCritical pitfalls, CI4 vs Laravel comparison table

Directory Structure

app/
  Config/         # All configuration classes (Routes, Database, Filters, Auth, etc.)
  Controllers/    # HTTP controllers
  Database/
    Migrations/   # Migration files (timestamped)
    Seeds/        # Seeder classes
  Filters/        # Before/after request filters
  Libraries/      # Custom libraries
  Models/         # Model classes
  Services/       # Custom service classes
  Views/          # View templates (.php)
    layouts/      # Layout templates
    partials/     # Reusable partials
public/           # Web root — index.php entry point lives here
writable/         # Cache, logs, sessions (must be writable)
tests/
vendor/
.env              # Environment config (copy from `env`)
spark             # CLI entry point

MVC Conventions — Hard Rules

  1. Controllers handle HTTP — receive request, call model/service, return response. No business logic.
  2. Models handle data — all database interaction lives here. No HTTP concerns.
  3. Views handle display — no DB calls, no business logic. Only presentation.
  4. Never call models from views. Ever.
  5. Web controllers call models directly — that is standard CI4.
  6. One controller = one resource. Name them descriptively (UserController, EventController).

Configuration

All config lives in app/Config/ as PHP classes (not arrays, not .ini files).

php
// app/Config/Database.php — DB connection
// app/Config/Routes.php   — route definitions
// app/Config/Filters.php  — filter aliases + global filters
// app/Config/App.php      — base URL, timezone, etc.

.env overrides any config value using dot-notation:

database.default.hostname = localhost
database.default.database = mydb
app.baseURL = 'http://example.com/'
CI_ENVIRONMENT = development

Routing

Defined in app/Config/Routes.php. See references/routing.md for complete reference.

php
$routes->get('users', 'UserController::index');
$routes->post('users', 'UserController::create');
$routes->get('users/(:num)', 'UserController::show/$1');
$routes->put('users/(:num)', 'UserController::update/$1');
$routes->delete('users/(:num)', 'UserController::delete/$1');

// Route groups
$routes->group('admin', ['namespace' => 'App\Controllers\Admin'], function ($routes) {
    $routes->get('users', 'UsersController::index');
});

// Apply filter to a route
$routes->get('dashboard', 'DashboardController::index', ['filter' => 'session']);

// Resource routes — generates full CRUD
$routes->resource('photos');

Route Placeholders

PlaceholderMatches
(:num)Digits only
(:alpha)Alphabetic only
(:alphanum)Alphanumeric
(:segment)URL segment (no slashes)
(:any)Anything (use sparingly)

Controllers

See references/controllers.md for complete reference.

php
<?php
namespace App\Controllers;

use App\Controllers\BaseController;

class UserController extends BaseController
{
    public function index()
    {
        $model = new \App\Models\UserModel();
        return view('users/index', ['users' => $model->findAll()]);
    }
}

Request Data

php
$this->request->getGet('name');       // GET param
$this->request->getPost('email');     // POST param
$this->request->getJSON(true);        // JSON body as array
$this->request->getVar('key');        // GET + POST
$this->request->getFile('avatar');    // File upload

Validation

php
$rules = [
    'email' => 'required|valid_email',
    'name'  => 'required|min_length[2]|max_length[100]',
];

if (!$this->validate($rules)) {
    return redirect()->back()->withInput()->with('errors', $this->validator->getErrors());
}

Redirects

php
return redirect()->to('/dashboard');
return redirect()->back();
return redirect()->back()->withInput()->with('error', 'Something went wrong.');

GOTCHA: Never add PHP type hints (int $id) to overridden ResourceController methods like show($id = null). The parent signature uses $id = null — a type hint breaks the override.


Models

See references/models.md for complete reference.

php
<?php
namespace App\Models;

use CodeIgniter\Model;

class UserModel extends Model
{
    protected $table            = 'users';
    protected $primaryKey       = 'id';
    protected $useAutoIncrement = true;
    protected $returnType       = 'object';   // Always use 'object' (not 'array')
    protected $useSoftDeletes   = false;
    protected $protectFields    = true;
    protected $allowedFields    = ['name', 'email', 'role'];

    protected $useTimestamps = true;
    protected $createdField  = 'created_at';
    protected $updatedField  = 'updated_at';
}

CRUD

php
$model = new UserModel();
$user  = $model->find(1);                          // by ID
$users = $model->findAll();                         // all
$user  = $model->where('email', 'a@b.com')->first(); // where
$id    = $model->insert(['name' => 'Rob', 'email' => 'r@b.com']);
$model->update(1, ['name' => 'Robert']);
$model->delete(1);
$users = $model->paginate(20);                      // pagination
$pager = $model->pager;                             // pager for view

Query Builder

See references/query-builder.md for complete reference.

php
$db = \Config\Database::connect();
$builder = $db->table('users');

$builder->select('id, name, email')
    ->where('active', 1)
    ->orderBy('created_at', 'DESC')
    ->limit(10);

$rows = $builder->get()->getResult();     // array of objects
$row  = $builder->get()->getRow();        // single object

CRITICAL GOTCHAS:

  • whereNull() does not exist in CI4. Use ->where('col IS NULL').
  • ->select('DISTINCT col') returns wrong results. Use ->select('col')->distinct().

Views

See references/views.md for complete reference.

php
// Controller
return view('users/index', ['users' => $users, 'title' => 'Users']);
php
<!-- app/Views/users/index.php -->
<?= $this->extend('layouts/main') ?>

<?= $this->section('content') ?>
<h1><?= esc($title) ?></h1>
<?php foreach ($users as $user): ?>
    <p><?= esc($user->name) ?></p>
<?php endforeach; ?>
<?= $this->endSection() ?>

Always use esc() for output. Never use return inside a view that uses $this->extend().


Filters

See references/filters.md for complete reference.

php
<?php
namespace App\Filters;

use CodeIgniter\Filters\FilterInterface;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;

class AuthFilter implements FilterInterface
{
    public function before(RequestInterface $request, $arguments = null)
    {
        if (!auth()->loggedIn()) {
            return redirect()->to('/login');
        }
    }

    public function after(RequestInterface $request, ResponseInterface $response, $arguments = null) {}
}

Register in app/Config/Filters.php, apply via routes:

php
$routes->get('admin', 'AdminController::index', ['filter' => ['session', 'group:admin']]);

Migrations

See references/database.md for complete reference.

bash
php spark make:migration CreateUsersTable
php spark migrate
php
public function up(): void
{
    $this->forge->addField([
        'id'         => ['type' => 'INT', 'constraint' => 11, 'unsigned' => true, 'auto_increment' => true],
        'name'       => ['type' => 'VARCHAR', 'constraint' => 150],
        'email'      => ['type' => 'VARCHAR', 'constraint' => 255, 'unique' => true],
        'created_at' => ['type' => 'DATETIME', 'null' => true],
        'updated_at' => ['type' => 'DATETIME', 'null' => true],
    ]);
    $this->forge->addPrimaryKey('id');
    $this->forge->createTable('users');
}

Spark CLI Quick Reference

See references/spark-cli.md for complete reference.

bash
php spark serve                          # dev server
php spark routes                         # list routes
php spark migrate                        # run migrations
php spark migrate:rollback               # rollback last batch
php spark db:seed DatabaseSeeder         # run seeder
php spark make:controller UserController # scaffold
php spark make:model UserModel           # scaffold
php spark make:migration CreateUsersTable
php spark make:filter AuthFilter
php spark cache:clear

Key Gotchas

See references/gotchas.md for the complete list and CI4 vs Laravel comparison.

  1. whereNull() does not exist — use ->where('col IS NULL')
  2. ->select('DISTINCT col') fails silently — use ->select('col')->distinct()
  3. Never type-hint overridden ResourceController params
  4. redirect() must be returned — without return it does nothing
  5. insertBatch() bypasses $allowedFields — be deliberate about what you pass
  6. Never use return inside a view using $this->extend()
  7. View sections cannot be nested — close one before opening another
  8. orLike() after where() needs groupStart()/groupEnd()
  9. Model save() decides insert vs update by whether primary key is present
  10. $returnType should always be 'object' — 'array' is inconsistent

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Ci4 AI skill do?

Comprehensive CodeIgniter 4 framework skill. Use when working with any CodeIgniter 4 project — routing, controllers, models, views, query builder, migrations, filters, services, Spark CLI, and Shield auth. Activates on mentions of "CodeIgniter", "CI4", "spark", "CI4 model", "CI4 controller", "CI4 route", or any CI4-specific pattern.

Why use Ci4 on TypingMind?

Because you install it once and use it with any model. Ci4 is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Ci4 in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/enlivenapp/Codeigniter4-App-and-API-Skills-for-Claude-Code/tree/main/ci4. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Ci4?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Ci4?

As many as you like. As long as a model supports skills, you can use Ci4 with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Ci4 AI skill free?

Yes. It is published on GitHub by enlivenapp under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇