moodleapp
Copilot instructions1k starsChanged 9 months agoApache-2.0View on GitHub
Import from @singletons for platform APIs, only import directly from @angular/core or Ionic when necessary. Main routing modules: - CoreMainMenuRoutingModule - Top-level tabs (calendar, messages, etc.) - CoreMainMenuTabRoutingModule - Child routes within tabs - CoreCourseContentsRoutingModule - Module used to register routes in the course contents page. These are routes that will only be used on single activity courses where the activity uses split-view navigation in tablets, such as forum or glossary. - CoreCourseIndexRoutingModule - Course tab pages - CoreMainMenuHomeRoutingModule -…
We split this copilot-instructions.md into the rules it gives an agent
14 rules. About 0 are common, 2 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Import from @singletons for platform APIs, only import directly from @angular/core or Ionic when necessary.
- Distinctive: line 33
Use barrel exports for cleaner imports:
- Very specific: line 59
Use buildTabMainRoutes() helper for consistent tab navigation
- Very specific: line 79
Use CoreSyncCronHandler for background sync
- Very specific: line 90
Before serving, Gulp tasks auto-run: lang, env, icons, optionally behat
- Very specific: line 99
Test files: /*.test.ts with setup in src/testing/setup.ts
- Very specific: line 130
Avoid creating separate -lazy.module.ts files.
- Very specific: line 157
Always use singletons via @singletons instead of injecting Angular services directly
- Very specific: line 158
Use standalone components for new modules instead of @NgModule({ declarations: [] })
- Very specific: line 159
Always register handlers in provideAppInitializer
- Very specific: line 160
Import only from barrel files that are configured in tsconfig.json paths
- Very specific: line 161
Do run gulp before testing to ensure lang files are built
- Very specific: line 162
Do use CoreSitesReadingStrategy when fetching data to control cache vs network behavior
- Distinctive: line 166
When performing a code review, check that the language is in British English.
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Moodle Mobile App - AI Agent Guidelines
Project Overview
This is the official Moodle Mobile App - an Ionic/Angular hybrid application that runs on Android and iOS via Cordova. The app provides offline-first access to Moodle LMS functionality.
Architecture Patterns
Singleton Services via makeSingleton
Services are NOT Angular-managed singletons. Use the makeSingleton pattern:
@Injectable({ providedIn: 'root' })
export class MyService { }
export const My = makeSingleton(MyService);Import from @singletons for platform APIs, only import directly from @angular/core or Ionic when necessary.
Delegate Pattern for Extensibility
The codebase uses delegates extensively to allow addons to register handlers:
- CoreDelegate base class in
src/core/classes/delegate.ts - Handlers register in module providers using
provideAppInitializer:
@NgModule({
providers: [
provideAppInitializer(() => {
CoreCourseModuleDelegate.registerHandler(AddonModPageModuleHandler.instance);
}),
],
})- Delegate examples:
CoreCourseModuleDelegate,CoreContentLinksDelegate,CoreCourseModulePrefetchDelegate,CoreMainMenuDelegate
Path Aliases (TypeScript)
Use barrel exports for cleaner imports:
@/- Project root@singletons/@singletons/*- Core singletons@services/*- Core services@features/*- Core features@components/*,@directives/*,@pipes/*- UI elements@addons/*- Addon modules@classes/*- Shared classes
Lazy Loading with Dynamic Routes
Routes use Angular's ROUTES injection token with factory functions:
@NgModule({
providers: [
{ provide: ROUTES, multi: true, useFactory: buildRoutes, deps: [Injector] },
],
})
export default class MyLazyModule {}Main routing modules:
CoreMainMenuRoutingModule- Top-level tabs (calendar, messages, etc.)CoreMainMenuTabRoutingModule- Child routes within tabsCoreCourseContentsRoutingModule- Module used to register routes in the course contents page. These are routes that will only be used on single activity courses where the activity uses split-view navigation in tablets, such as forum or glossary.CoreCourseIndexRoutingModule- Course tab pagesCoreMainMenuHomeRoutingModule- Home page tabsCoreSitePreferencesRoutingModule- Site preferences pages- Use
buildTabMainRoutes()helper for consistent tab navigation
Cache Data Layer
SQLite Database: Site-specific tables via CORE_SITE_SCHEMAS token:
providers: [
{ provide: CORE_SITE_SCHEMAS, useValue: [MY_SCHEMA], multi: true }
]File Management:
CoreFilepool- Downloads/caches files with queue managementCoreCourseModulePrefetchDelegate- Handles module prefetching for offlineCoreCourseHelper- Manages course and section downloads for offline accessCoreFileProvider- Manages file operations (read, write, delete) across device storage- Files stored in filepool with metadata tracking (stale detection, external file flags)
Sync Pattern:
- Offline actions stored in local DB tables
- Sync services (extend
CoreSyncBaseProvider) process on connection - Use
CoreSyncCronHandlerfor background sync
Development Workflows
Build & Serve
npm start # Dev server with SSL at localhost:8100
npm run build # Development build
npm run build:prod # Production build
npm run build:test # Testing build with NODE_ENV=testingBefore serving, Gulp tasks auto-run: lang, env, icons, optionally behat
Testing
Unit Tests (Jest):
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # With coverageTest files: **/*.test.ts with setup in src/testing/setup.ts
E2E Tests (Behat):
- Feature files in
src/**/tests/behat/*.feature - PHP-based Behat communicates with app via
window.behatAPI - Build plugin:
gulp behat(requiresMOODLE_APP_BEHAT_PLUGIN_PATHorMOODLE_DOCKER_WWWROOT) - Behat runtime in
src/testing/services/behat-runtime.ts
Mobile Development
npm run dev:android # Run on Android with livereload
npm run dev:ios # Run on iOS
npm run prod:android # Production Android build
npm run prod:ios # Production iOS buildCustom Cordova plugin in cordova-plugin-moodleapp/ with TypeScript source compiled to www/index.js
Language Files
Distributed lang files compiled into src/assets/lang/{lang}.json:
npm run lang:update-langpacks # Pull from Moodle language packs
npm run lang:create-langindex # Generate language indexWatch for changes: gulp watch
Project-Specific Conventions
Module Structure
- Core modules:
src/core/features/{feature}/ - Addon modules:
src/addons/{type}/{name}/ - Each feature has
{name}.module.ts(eager) and{name}-lazy.module.ts(lazy-loaded routes) when needed - Avoid creating separate
-lazy.module.tsfiles; instead useloadComponentwith dynamic imports for lazy loading - Services in
services/, components incomponents/, pages inpages/
Handler Pattern
Handlers are singletons with .instance property added by makeSingleton:
@Injectable({ providedIn: 'root' })
export class MyHandler extends CoreContentLinksHandler {
name = 'AddonMyHandler';
// ...implementation
}
export const MyHandler = makeSingleton(MyHandler);Shared Module Usage
Components import CoreSharedModule which re-exports:
CoreBaseModule(CommonModule, FormsModule, IonicModule, TranslateModule)CoreComponentsModule,CoreDirectivesModule,CorePipesModule
Database Schema Versioning
Define tables with columns, indexes in site schemas. Version increments trigger migrations.
Environment Configuration
moodle.config.json (gitignored) extends moodle.config.example.json. Access via CoreConstants.CONFIG service. Test config overrides via TestingBehatRuntime.init().
Common Pitfalls
- Always use singletons via
@singletonsinstead of injecting Angular services directly - Use standalone components for new modules instead of
@NgModule({ declarations: [] }) - Always register handlers in
provideAppInitializer - Import only from barrel files that are configured in
tsconfig.jsonpaths - Do run
gulpbefore testing to ensure lang files are built - Do use
CoreSitesReadingStrategywhen fetching data to control cache vs network behavior
Code reviews
- When performing a code review, check that the language is in British English.
Trending
Quiet this year.thin dataabout the whole repository
Who's talking about moodlehq/moodleapp
- Stack Overflow“How to resolve: error: failed processing manifest”Stack Overflow · Mar 3, 2020 · 3 votes
- catthehacker/docker_images“Containers not behaving the same as GH runners”GitHub · Jul 15, 2024
- havesource/cordova-plugin-push“Notification icon not seen after applying getCircleBitmap”GitHub · Aug 26, 2022
- moodlehq/moodle-local_moodlemobileapp“WIP: MOBILE-3934: Test competency and grades navigation”GitHub · Jan 13, 2022
- moodlehq/moodle-local_moodlemobileapp“WIP: MOBILE-3939 feedback: Test navigation”GitHub · Dec 9, 2021
The biggest 5 of 13 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 13
Talked about on GitHub and Stack Overflow (13 times).
On GitHub · 10
- Jul 15, 2024Containers not behaving the same as GH runners — catthehacker/docker_images0 reactions · 1 comment
- Aug 26, 2022Notification icon not seen after applying getCircleBitmap — havesource/cordova-plugin-push0 reactions · 1 comment
- Jan 13, 2022WIP: MOBILE-3934: Test competency and grades navigation — moodlehq/moodle-local_moodlemobileapp0 reactions · 3 comments
- Dec 9, 2021WIP: MOBILE-3939 feedback: Test navigation — moodlehq/moodle-local_moodlemobileapp0 reactions · 3 comments
- Dec 1, 2021MOBILE-3926: Test assignment, glossary & forum navigation — moodlehq/moodle-local_moodlemobileapp0 reactions
5 more on GitHub
- Oct 4, 2021MOBILE-3833 behat: use ngZone — moodlehq/moodle-local_moodlemobileapp0 reactions
- Jun 10, 2021MOBILE-3320: Navigation tests — moodlehq/moodle-local_moodlemobileapp0 reactions · 1 comment
- Jun 9, 2021MOBILE-3320: Update login, assignment & quiz tests — moodlehq/moodle-local_moodlemobileapp0 reactions
- Jun 8, 2021MOBILE-3320: Update forum & courses tests — moodlehq/moodle-local_moodlemobileapp0 reactions
- Jun 3, 2021MOBILE-3320: Update messages, chat & course tests — moodlehq/moodle-local_moodlemobileapp0 reactions
On Stack Overflow · 3
- Mar 3, 2020How to resolve: error: failed processing manifest3 votes · 1 answer
- Apr 1, 2021ionic does not reflect the changes done in src folder0 votes
- Jan 17, 2020how to run moodle mobile app on android studio0 votes · 1 answer
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

