McBopomofo
Copilot instructions858 starsChanged 20 months agoMITView on GitHub
When reviewing code: This file provides GitHub Copilot-specific coding instructions. For comprehensive project documentation: Note: GitHub Copilot does not automatically read AGENTS.md files. Essential guidelines are included below.
We split this copilot-instructions.md into the rules it gives an agent
25 rules. About 1 is common, 15 are distinctive, and 9 are very specific to this project.
≈1
Common · estimate
Many files like this have a rule of this kind.
≈15
Distinctive · estimate
This author's own choices. Worth a look.
9
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 3
Do NOT generate pull request overviews.
- Distinctive: line 4
Do NOT generate explainers.
- Distinctive: line 5
Do NOT summarize what a diff chunk does.
- Distinctive: line 6
Only point out issues that are of medium severity or higher.
- Common: line 7
Do point out spelling errors in symbol names such as those of variables, classes, methods, and functions.
- Distinctive: line 8
Do point out spelling or grammar errors in comments.
- Very specific: line 9
Do point out style issues such as extraneous spaces (for example a = b;).
- Distinctive: line 10
Do point out spelling errors in commit messages.
- Distinctive: line 28
Language restriction: Use only English or Traditional Chinese.
- Very specific: line 39
Keep AppKit and IMKit work in Swift classes (InputMethodController, PreferencesWindowController, etc.) and limit scope with …
- Very specific: line 40
Use the Preferences static properties and property wrappers in Source/Preferences.swift instead of accessing UserDefaults directly.
- Very specific: line 42
Follow the established flow: InputMethodController drives menu actions, KeyHandler mediates IM events, and InputState models state …
- Very specific: line 47
Treat InputState subclasses as immutable snapshots.
- Distinctive: line 49
Keep UI and engine in sync by deriving candidate lists, composing buffers, and menu options from the state object rather than scattered …
- Distinctive: line 56
Keep bridge methods small: forward inputs to the engine and return plain values or Foundation types that Swift can consume.
- Very specific: line 60
Place new engine code inside the current namespaces (McBopomofo, Formosa::Gramambular2, Formosa::Mandarin) and reuse helper classes from …
- Distinctive: line 62
Keep algorithms deterministic and side-effect free.
- Very specific: line 65
Add Swift tests under McBopomofoTests using the Testing module with @Suite, @Test, and #expect macros.
- Very specific: line 67
When dictionary data changes, regenerate artifacts via the make targets in Source/Data and check updated binaries into Source/Data/bin.
- Very specific: line 68
Keep shell scripts such as Source/add-phrase-hook.sh POSIX-compliant and aligned with the existing shebang and style.
- Distinctive: line 72
Use Conventional Commits format for all commits and pull requests.
- Distinctive: line 76
Keep descriptions concise, present tense, lowercase.
- Distinctive: line 80
Avoid replacing AppKit windows with SwiftUI or Combine.
- Distinctive: line 81
Do not bypass the bridge to talk to the engine directly from Swift.
- Distinctive: line 83
Keep large dictionary blobs or generated files untouched unless the change specifically targets them.
≈ “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
When reviewing code:
- Do NOT generate pull request overviews.
- Do NOT generate explainers.
- Do NOT summarize what a diff chunk does.
- Only point out issues that are of medium severity or higher.
- Do point out spelling errors in symbol names such as those of variables, classes, methods, and functions.
- Do point out spelling or grammar errors in comments.
- Do point out style issues such as extraneous spaces (for example
a = b;). - Do point out spelling errors in commit messages.
- Pay attention when strings cross language boundaries, especially if code point counts are involved.
Documentation Structure
This file provides GitHub Copilot-specific coding instructions. For comprehensive project documentation:
- AGENTS.md: Master documentation for all AI coding assistants (architecture, build process, workflows)
- algorithm.md: Technical algorithm documentation (Chinese)
- Source/Data/AGENTS.md: Dictionary data development guide
Note: GitHub Copilot does not automatically read AGENTS.md files. Essential guidelines are included below.
General Guidelines
- Never use emoji in code, comments, documentation, or generated content outside
Source/Data/. Emoji are permitted only within dictionary data files inSource/Datawhere mappings include emoji. - Language restriction: Use only English or Traditional Chinese. Simplified Chinese is prohibited in all documentation, comments, and reviews.
Project Context
- Input method for macOS built with AppKit/IMKit in Swift and bridged Objective-C++, backed by the C++ language model in
Source/Engine. - The app supports two Taiwanese Braille formats: Unicode and ASCII.
- Build and run with Xcode target
McBopomofo Installer; Swift front end pulls helper frameworks from the localPackages/directory. - Dictionary assets and generation scripts live in
Source/Data; compiled blobs are stored inSource/Data/bin. - Tests cover both layers: Swift XCTest-style suites in
McBopomofoTestsand GoogleTest cases inSource/Engine/*Test.cppvia CMake. - Preserve the existing MIT license banner on any new source file.
Swift & AppKit Guidelines
- Keep AppKit and IMKit work in Swift classes (
InputMethodController,PreferencesWindowController, etc.) and limit scope withprivate/fileprivatehelpers. - Use the
Preferencesstatic properties and property wrappers inSource/Preferences.swiftinstead of accessingUserDefaultsdirectly; add new keys beside the existing constants. - Localize UI strings through
NSLocalizedString("…", comment: "")and update the.stringsfiles underBase.lproj,en.lproj, andzh-Hant.lprojwhen text changes. - Follow the established flow:
InputMethodControllerdrives menu actions,KeyHandlermediates IM events, andInputStatemodels state transitions. - Perform UI work on the main thread; reuse existing helper methods or notifications rather than introducing ad-hoc dispatch queues.
- Interact with the engine through
KeyHandler/LanguageModelManagerbridges instead of duplicating C++ logic in Swift.
State Machine Design
- Treat
InputStatesubclasses as immutable snapshots; always create a new state object when the IM transitions instead of mutating existing instances. - Funnel key handling through
KeyHandlerso state transitions originate from one place and UI updates flow from the current state. - Keep UI and engine in sync by deriving candidate lists, composing buffers, and menu options from the state object rather than scattered flags.
- Extend the state machine by adding new
InputStatesubclasses plus explicit transitions; avoid adding booleans that bypass the existing states.
Objective-C++ Bridge Guidelines
- Manage engine lifetimes in
.mmfiles by allocating ininit, cleaning up indealloc, and wrapping pointers instd::shared_ptrwhen passing to C++ APIs. - Surface new engine capabilities by extending bridge classes (
KeyHandler,LanguageModelManager) and declaring them inMcBopomofo-Bridging-Header.h. - Convert between
NSStringandstd::stringwithUTF8Helper/NSStringUtils; avoid hand-written UTF conversions or raw buffers. - Keep bridge methods small: forward inputs to the engine and return plain values or Foundation types that Swift can consume.
C++ Engine Guidelines
- Stick to the existing C++17 style that uses
std::vector,std::unordered_map,std::optional, andstd::string_viewas inMcBopomofoLM.cpp. - Place new engine code inside the current namespaces (
McBopomofo,Formosa::Gramambular2,Formosa::Mandarin) and reuse helper classes fromgramambular2. - Reuse the blob readers (
KeyValueBlobReader,ParselessPhraseDB,PhraseReplacementMap) when touching serialized resources; prefer augmenting them over inventing new formats. - Keep algorithms deterministic and side-effect free; logging and macOS-specific behavior should stay in the Objective-C++ layer.
Tests and Tooling
- Add Swift tests under
McBopomofoTestsusing theTestingmodule with@Suite,@Test, and#expectmacros; snapshot and restoreUserDefaultslikePreferencesTests. - Register new engine tests in
Source/Engine/CMakeLists.txt, include them in theMcBopomofoLMLibTesttarget, and use GoogleTest assertions. - When dictionary data changes, regenerate artifacts via the make targets in
Source/Dataand check updated binaries intoSource/Data/bin. - Keep shell scripts such as
Source/add-phrase-hook.shPOSIX-compliant and aligned with the existing shebang and style.
Git Commit Convention
- Use Conventional Commits format for all commits and pull requests.
- Format:
type(scope): description - Types: feat, fix, docs, style, refactor, test, chore
- Example:
feat(keyboard): add support for custom layout - Keep descriptions concise, present tense, lowercase.
- Reference: https://www.conventionalcommits.org/
Things to Avoid
- Avoid replacing AppKit windows with SwiftUI or Combine; the runtime depends on NSWindow/XIB assets.
- Do not bypass the bridge to talk to the engine directly from Swift; IMKit lifecycle assumptions require the Objective-C++ layer.
- Refrain from hardcoding paths to user data; use the preference APIs and helper lookups.
- Keep large dictionary blobs or generated files untouched unless the change specifically targets them.
Reference Files
Source/InputMethodController.swift: IMK entry point coordinating candidate menus and preferences.Source/KeyHandler.mm: Objective-C++ bridge between Swift events and the engine.Source/Engine/McBopomofoLM.cpp: Core language model logic and unigram handling.McBopomofoTests/PreferencesTests.swift: Example of the SwiftTestingsuite setup and patterns.Source/Engine/CMakeLists.txt: Engine build configuration and test registration.
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.

