Imported from ibrahimmaher2503-source/education_platform (
AGENTS.md). Install upstream withnpx skills add ibrahimmaher2503-source/education_platform. Copyright stays with the author.
AGENTS.md
1. Purpose
This file defines the mandatory rules that every AI coding agent must follow while working on the LMS project.
The project is an educational platform for primary and preparatory school students. A student subscribes to a package linked to a specific grade, academic year, and term. The subscription unlocks all included subjects for that academic context.
The AI must implement the system incrementally according to the documentation, milestones, acceptance criteria, security rules, and current project state.
2. Mandatory Reading Order
Before changing any code, read the following files in order:
AGENTS.mdREADME.md- All product and technical documentation inside
docs/ .ai/HANDOFF.md.ai/CURRENT_MILESTONE.md.ai/PROGRESS.md.ai/BLOCKERS.md.ai/DECISIONS.md.ai/TEST_RESULTS.md
After reading, inspect the existing codebase before assuming that any feature is missing.
3. Core Business Rules
The following rules are mandatory and must not be changed silently:
- A parent has an independent account.
- A parent can be linked to one or more students.
- A subscription is activated for a specific student.
- A subscription must not automatically unlock content for all children linked to the same parent.
- A student is linked to a grade, academic year, and term through an academic enrollment or equivalent academic context.
- A valid subscription unlocks the subjects included in the package for that student and academic context.
- Package, billing plan, order, payment, and subscription are separate concepts and entities.
- Package differences may be based on service level, follow-up, live classes, reports, and support—not necessarily subject availability.
- Teachers may only access assigned grades, subjects, classes, and students.
- Parents may only access students explicitly linked to their accounts.
- Students may only access content covered by an active subscription.
- Administrative staff access must be controlled by explicit permissions.
- Authorization must be enforced on the server, not only by hiding UI actions.
- Critical operations must be added to the audit log.
- Payment confirmation must be idempotent and must not create duplicate subscriptions or invoices.
4. Required Development Cycle
For every task, follow this exact cycle:
- Read the related requirement and acceptance criteria.
- Inspect the current implementation.
- Add or update the task in
.ai/CURRENT_MILESTONE.md. - Write a short implementation plan.
- Implement only the relevant change.
- Add validation.
- Add authorization.
- Handle failure and edge cases.
- Add or update tests.
- Run relevant tests and quality checks.
- Fix failures caused by the change.
- Review security and data access.
- Update the milestone checklist.
- Update
.ai/PROGRESS.md. - Update
.ai/TEST_RESULTS.md. - Update
.ai/HANDOFF.md. - Continue automatically to the next unblocked task.
Do not stop after writing a plan.
5. Continuation Rules
Continue working while there are executable, unblocked tasks.
Do not request confirmation after every task.
Do not stop merely to provide a progress summary.
When a missing external decision does not block the rest of the implementation:
- Record it in
.ai/BLOCKERS.md. - Create an interface, adapter, fake, stub, or mock implementation.
- Continue with all unblocked work.
Examples:
- Unknown payment provider:
create
PaymentGatewayInterfaceand a fake sandbox implementation. - Unknown live-class provider:
create
LiveClassProviderInterface. - Email or SMS credentials unavailable: use fake notification channels in development and tests.
6. Allowed Stop Conditions
The AI may stop only when one of the following is true:
- A required secret or credential cannot be replaced by a safe fake.
- A destructive, irreversible action requires explicit approval.
- A major business decision has multiple structurally different options.
- The development environment is completely unusable.
- Two authoritative project documents directly conflict and context cannot resolve the conflict.
- A required third-party service cannot be simulated and blocks all further work.
Before stopping:
- Finish every other unblocked task.
- Record the blocker in
.ai/BLOCKERS.md. - Update
.ai/HANDOFF.md. - List the available options and impact of each.
- Ask for one precise decision only.
7. Completion Rules
The words done, completed, or finished may only be used when:
- All applicable acceptance criteria are verified.
- Required validation exists.
- Server-side authorization exists.
- Relevant automated tests exist.
- Relevant tests pass.
- Failure states and edge cases are handled.
- Database constraints and indexes are reviewed.
- Documentation and checklists are updated.
.ai/PROGRESS.md,.ai/TEST_RESULTS.md, and.ai/HANDOFF.mdare updated.
Creating files without integrating or testing them is not completion.
A page that renders but does not enforce permissions is incomplete.
A feature using hardcoded production data is incomplete unless the requirement explicitly requests a prototype.
Blocked tasks must never be marked complete.
8. Architecture Rules
Follow the architecture documented in docs/.
Default rules unless the existing project defines stricter conventions:
- Controllers and UI resources should remain thin.
- Business logic belongs in services, actions, or domain classes.
- Validation belongs in dedicated request or form validation layers.
- Authorization belongs in policies, gates, permissions, and query scoping.
- Multi-step writes must use database transactions.
- Long-running work should use queued jobs.
- Side effects should use events/listeners when useful.
- External providers must be accessed through interfaces or adapters.
- Reuse existing patterns before introducing new abstractions.
- Do not install a package unless it provides clear value and is documented.
- Do not modify unrelated modules.
- Do not duplicate business logic.
9. Database Rules
- Use foreign keys where appropriate.
- Add indexes for common filters, joins, status fields, dates, and lookup columns.
- Use unique constraints to protect business invariants.
- Do not edit an already-shared migration; create a new migration.
- Never run destructive production commands.
- Use transactions for checkout, payment confirmation, enrollment, grading publication, and similar workflows.
- Preserve historical financial and academic records.
- Prefer status transitions over destructive deletion for financial records.
- Define clear handling for soft deletes and archived academic data.
- Prevent duplicate active subscriptions where business rules prohibit them.
10. Authorization Rules
At minimum, verify:
- A student cannot access another student’s records.
- A parent cannot access an unlinked student.
- A teacher cannot access unassigned subjects or students.
- A staff member cannot perform actions outside granted permissions.
- An expired subscription cannot unlock protected content.
- A subscription for one child cannot unlock another child.
- Hidden UI actions remain inaccessible through direct requests.
- Reports and file downloads enforce the same access rules as pages and APIs.
Every critical permission rule must have a negative test.
11. Testing Rules
For each feature, cover as applicable:
- Happy path.
- Validation failures.
- Authentication.
- Authorization and ownership.
- Edge cases.
- State transitions.
- Duplicate requests.
- Transaction rollback.
- File upload restrictions.
- Subscription expiry.
- Time-bound exam behavior.
- Calculation accuracy.
- Notifications.
- Audit logging.
After each task: run targeted tests.
After each module: run module tests.
After each milestone: run the full available test suite and quality checks.
Do not hide, delete, or skip failing tests to obtain a green result.
12. Git Rules
- Work on a dedicated branch.
- Keep commits small and meaningful.
- Do not commit secrets, local environment files, or generated sensitive data.
- Suggested commit formats:
feat(auth): add parent and student profiles
feat(academics): add academic terms and grade assignments
test(subscriptions): protect student-scoped access
fix(exams): prevent submission after deadline
docs(ai): update milestone handoff
13. Required AI State Files
The AI must keep the following files current:
.ai/CURRENT_MILESTONE.md.ai/PROGRESS.md.ai/BLOCKERS.md.ai/TEST_RESULTS.md.ai/DECISIONS.md.ai/HANDOFF.md
The codebase and test results are the source of truth. If a state file conflicts with the code, inspect the implementation, correct the state file, and document the correction.
14. Final Project Review
Before declaring the whole project ready, perform independent reviews for:
- PRD coverage.
- Database integrity.
- Authentication and authorization.
- Subscription and payment lifecycle.
- Exams, attempts, and grading.
- Parent/student data isolation.
- Teacher assignment scoping.
- Security.
- Performance.
- Accessibility and responsive UI.
- Backup and recovery.
- Deployment and production readiness.