-
-
Notifications
You must be signed in to change notification settings - Fork 536
AI Agent Workflow
Purpose
- Explain how contributors and maintainers can use AI coding agents to accelerate feature work, address PRs, and fix bugs while keeping ChurchCRM a modern, safe, and auditable project.
Principles (must follow)
- Agents are assistants, not automatic committers — a human reviews and approves all changes.
- Always run existing tests and CI locally before merging anything an agent produces.
- Keep the service layer as the source of business logic: agents should add or update services in
src/ChurchCRM/Service/whenever logic is non-trivial. - Use Perpl ORM Query classes — never raw SQL. Agents must follow TableMap and
addForeignValueCondition()rules. See/.github/skills/database-operations.md.
When to use an AI agent
- Prototyping new endpoints, extracting logic into services, writing tests, creating route skeletons, updating documentation, and writing localized UI text.
- Not for committing secrets, performing irreversible production changes, or replacing code reviews.
How to start (best practice)
- Identify the task and pick relevant skills (examples):
- Add API endpoint:
api-development.md,slim-4-best-practices.md,service-layer.md,php-best-practices.md. - Migrate admin page:
admin-mvc-migration.md,refactor.md,frontend-development.md. - Add i18n strings:
i18n-localization.mdand runnpm run locale:build.
- Add API endpoint:
- Provide the agent with: short goal, target files/areas, and constraints (PHP version, ORM rules, security). Example: "Create
src/groups/sundaySchool/routes/members.phpand aGroupServicemethod to add a member; include unit tests and Cypress scenario." - Let the agent produce a focused change (one logical change per run). Review and iterate.
Agent workflows (step-by-step)
Add a feature (API + UI)
- Step A — Plan: Ask the agent to draft a small plan (routes → service → view → tests). Confirm.
- Step B — Implement skeletons: Agent creates route file under
src/<area>/routes/, service stub insrc/ChurchCRM/Service/, and view template undersrc/<area>/views/if needed. - Step C — Tests: Agent generates unit tests for service and API integration tests (Cypress for UI flows). Run tests locally.
- Step D — Local verification: Run
npm run buildandcomposer install(insrc/) and run tests:npm run testornpx cypress runas appropriate. - Step E — Human review & commit: Reviewer inspects code, verifies style and security, then commits with a clear message and opens a PR.
Fix a bug / address a PR
- Step A — Reproduce: Ask the agent to create a minimal failing test reproducing the bug. This ensures regression coverage.
- Step B — Diagnose: Provide relevant logs, error messages, and the failing test; agent proposes a minimal fix following project rules (Perpl ORM, RedirectUtils, SlimUtils).
- Step C — Implement & test: Agent implements the fix, updates tests, and documents the change in the PR description.
- Step D — Review & merge: Human reviewer confirms tests pass and merges.
Security & Permissions
- Agents must not modify auth checks without explicit human approval. All permission checks should use the existing
Usermethods (e.g.,isAdmin(),canEditPerson()), and useRedirectUtils::securityRedirect()for redirects.
i18n & Frontend
- If the change adds UI strings, run
npm run locale:buildand commit updates tolocale/terms/messages.pobefore the code PR. Then runnpm run buildto regenerate frontend assets. - Frontend libraries & versions (from
package.json): Bootstrap 5, Tabler (admin theme), TypeScript, Webpack. React was removed in 7.1.2. Agents should not propose breaking frontend upgrades without an RFC. - For UI, use Tabler components and Bootstrap 5 class names (not Bootstrap 4). See Tabler-UI-Components for the reference guide.
Testing / CI
- Unit tests: put PHP tests under the appropriate test folder following existing project patterns.
- Cypress: Add UI scenarios under
cypress/e2e/ui/<feature>/and API tests undercypress/e2e/api/. Usenpm run testornode_modules/cypress/bin/cypress run --e2eto execute.
Commit / PR conventions
- Small, focused commits; use the project's commit message style, examples:
feat(groups): add sundaySchool group membership APIfix(api): validate person ID in people-groups endpoint
- Include a short description, testing steps, and any migrations or i18n checklist in the PR body.
Agent prompt templates (examples)
- Add feature:
"You are an expert ChurchCRM developer. Create a Slim route
POST /groups/sundaySchool/membersinsrc/groups/sundaySchool/routes/members.phpthat callsGroupService::addMember($groupId, $personId). AddGroupServicestub insrc/ChurchCRM/Service/GroupService.php, unit tests, and a Cypress UI test. Follow Perpl ORM and useSlimUtils::renderErrorJSON()for errors. Don't commit — show the diff." - Bug fix:
"Reproduce the bug by adding a unit test that fails for
src/api/routes/people/people-groups.phpwhen person id is non-numeric. Then implement a minimal fix that validates and returnsSlimUtils::renderErrorJSON()with status 400."
Best practices & warnings
- Always run
composer validateandcomposer install --no-devundersrc/if you change PHP dependencies. - Do not let agents change
composer.jsonorpackage.jsonversions without human review. - Keep database schema changes separate: open a migration PR with DB scripts and follow
db-schema-migration.md. - Keep a clear audit trail: reference JIRA/Issue numbers in commits and PRs for traceability.
Where to read more
- Skills directory (use the relevant skills for agent prompts):
.github/skills/— e.g.,slim-4-best-practices.md,api-development.md,service-layer.md,i18n-localization.md,testing.md.
Want me to create a pull request template or an agent-ready checklist file for PR authors? Reply and I'll add it.
Upgrade warning: Any file you modify directly inside the ChurchCRM source tree (
src/,public/,locale/, etc.) will be overwritten the next time you upgrade. There are no merge steps — the upgrade process replaces application files wholesale. If you want your customization to survive upgrades, it must live in a community plugin.
ChurchCRM's plugin system is specifically designed for this. A plugin:
- Lives in its own directory (
src/plugins/community/<your-plugin>/) - Is never touched by the upgrade process
- Can add pages, API routes, menu items, notification channels, and hooks into core events
- Can be enabled, disabled, or removed independently
If you are tempted to edit a core PHP file to add a custom field, a new page, or an integration — build a plugin instead.
See Creating-Community-Plugins for the full plugin development guide.
The AI agent workflow is especially powerful for building community plugins from scratch. Here is how to use it effectively.
The .github/skills/ directory (in the CRM repo) contains task-specific instruction sets for AI agents. For plugin development, load:
.github/skills/churchcrm/creating-community-plugins.md
.github/skills/churchcrm/api-development.md
.github/skills/churchcrm/slim-4-best-practices.md
.github/skills/churchcrm/service-layer.md
.github/skills/churchcrm/i18n-localization.md
In Claude Code, you can load these as context at the start of your session. Paste the content directly or reference them explicitly in your prompt.
Give the agent a short, specific goal. Example:
Goal: Create a community plugin called
mailchimp-syncthat adds a settings page under Admin, stores a Mailchimp API key in the plugin config table, and syncs the member email list to a Mailchimp audience on demand via a button on the settings page.Constraints: Use Slim 4 route handlers, Propel ORM for any DB access, Tabler/Bootstrap 5 UI, wrap all UI strings in gettext(). Do not modify any core files. Follow the plugin manifest format in Creating-Community-Plugins.md.
Ask the agent to generate:
-
plugin.json— manifest with name, version, author, hooks - Main plugin class — registers routes and menu items
- Route file — Slim 4 handlers for settings page and sync endpoint
- View template — Tabler-styled settings form
- Any service class needed (e.g.,
MailchimpService.php)
Review the scaffold, then iterate. The agent is excellent at filling in boilerplate; your job is to verify business logic and security.
Agents can generate Cypress tests for your plugin's UI and API routes. Ask for:
- A Cypress API test that POSTs to /plugins/mailchimp-sync/sync and asserts a 200 response
- A Cypress UI test that opens the plugin settings page and saves an API key
Run tests with npm run test before considering the plugin ready.
Quick reference — for each plugin task, ask the agent to:
| Task | Key skill(s) to reference |
|---|---|
| Plugin scaffold | creating-community-plugins.md |
| Settings/config page |
slim-4-best-practices.md, Tabler-UI-Components wiki page |
| External API integration |
service-layer.md, api-development.md
|
| Adding translations | i18n-localization.md |
| Writing tests | testing.md |
| Database changes (plugin tables) | db-schema-migration.md |
All skills are in .github/skills/ in the CRM repo. The most useful for new contributors:
| Skill file | Use it for |
|---|---|
churchcrm/creating-community-plugins.md |
Building any community plugin |
churchcrm/api-development.md |
Adding API endpoints |
churchcrm/slim-4-best-practices.md |
Slim 4 routing and middleware |
churchcrm/service-layer.md |
Business logic in service classes |
churchcrm/i18n-localization.md |
Making UI text translatable |
churchcrm/testing.md |
Cypress tests for UI and API |
churchcrm/db-schema-migration.md |
Schema changes and migrations |
churchcrm/frontend-development.md |
JavaScript and Tabler UI |
churchcrm/admin-mvc-migration.md |
Migrating legacy admin pages |
php-best-practices.md |
PHP type safety, PSR-12, SOLID |
interface-design.md |
Tabler UI design patterns |
- Home
- Wiki → Docs links — User & admin manuals moved to docs.churchcrm.io
→ docs.churchcrm.io for installation & setup
- Installation ← Start here!
- First Run Setup
- Features Overview
→ docs.churchcrm.io for user manuals
- User Guide (docs)
- People Management — docs
- Groups & Events
- Tools
- Finances
→ docs.churchcrm.io for admin manuals
- User Management
- System Maintenance
- Configuration
- Troubleshooting
- Localization
Contributing to ChurchCRM
- Quick Start
- Testing & CI/CD
- Code & Architecture
- Localization
- Release & Security