project-code-examples
Catalog of project code examples — what patterns exist and where to find them in .code-examples-for-ai/
- License 许可
- MIT
- 最近更新
- 2026-09-14
- Stars
- ★ 1
- Forks
- 0
01 前言 Front Matter
- name
- project-code-examples
- agents
- [ "coder", "sidekick-reviewer", "architect", "builder" ]
- description
- Catalog of project code examples — what patterns exist and where to find them in .code-examples-for-ai/
03 SKILL.md 正文
Scope
- In scope: indexing and maintaining repository code-pattern examples consumed by AI workflows.
- Out of scope: introducing production behavior changes unrelated to example coverage.
Invariants
- Example index MUST list each maintained pattern file with a one-line purpose.
- Each example file MUST represent one focused pattern.
- New patterns introduced in production code MUST be reflected in this index.
- Existing examples MUST NOT be silently removed without replacement rationale.
- Example snippets MUST stay concise and implementation-aligned.
Validation Checklist
- Verify
.code-examples-for-ai/contains the files listed in## Available Examples. - Verify any new coding pattern introduced by the change is documented with one dedicated
.mdexample file. - Verify this index section is updated in the same change when example files are added/renamed/removed.
Failure Handling
- If pattern coverage is unclear, add or update the nearest matching example before marking task done.
- If an example becomes stale after refactors, update it in the same change that introduced drift.
- If no new pattern was introduced, record that no example update was required.
These examples demonstrate the coding patterns used in this project. Reference them when adding new features to maintain consistency.
Available Examples
plugin-registration.md— How the main Plugin function merges agents, skills, and commands into the opencode Configfrontmatter-parsing.md— Safe YAML frontmatter parsing from .md files using theyamllibraryhook-creation.md— Creating tool.execute.after and event hooks with output truncation logiccli-command.md— Setting up a Commander.js CLI command with JSONC config editingsafe-dir-read.md— Defensive directory reading with try-catch and undefined fallbackzod-config-schema.md— Zod v4 config schema with two-argz.record, security.refine()constraints, andz.toJSONSchema()exportmodel-sections.md— Parsing model-family sections from agent body text and injecting them at runtime viaexperimental.chat.system.transformglobal-prompts-loader.md— Loading shared global prompt content from a directory, keyed by lowercased filename stem, with per-file error resilienceskill-embedded-mcp.md— Declaring local/remote MCP servers in SKILL.md frontmatter, including{env:VAR_NAME}token resolution and command-injection guard, plus skill-derivedpermission.external_directoryand non-MCPpermission.bashdeclarationsagent-permissions.md— Agent permission allow/ask/deny visibility model withpermission.skillgating and the skill-sideagents:opt-in counterpartcontent-override-merge.md— Priority-based merge of layered content directories — builtin < opencode global < global user < opencode project < project user — usingcollectFiles()/collectDirs()load-content-helper.md— SharedloadContentFiles()wrapper that centralizes collectFiles + warn-and-skip parsinglogger-notifier.md— Logger singleton with two-phase init and notifier toast fallback integrationskill-access-gating.md— Session-aware skill tool gating usingchat.params,tool.execute.before, andsession.deletedcleanupauto-inject-prompt-wrapping.md— Auto-inject prompt merge behavior: wrapped append for existing non-whitespace prompts, raw first-skill body when prompt is empty/whitespace-onlybounded-skill-loader.md— Rejecting oversized auto-inject skill content before it enters memory or promptspersistent-sidekick-tool.md— Persistent CLI-backed review and documentation-sync tool with isolated per-type session reuse, bounded output, and cancellation
Location
.code-examples-for-ai/
Maintenance
This index is maintained by the AI. Developers may add entries manually. One file per pattern.
When a new coding pattern is introduced that is not yet represented here:
- Create a new
.mdfile in.code-examples-for-ai/with the pattern name as filename - Add an entry to the
## Available Exampleslist above - Each file must include a
<!-- Pattern: name — description -->comment at the top followed by a single TypeScript code block with inline annotations
04 同仓库更多 Skills
unslop
Perform sequential slop-cleanup edits in bounded changed-file scope with behavior-preserving rules; do not use for read-only scanning.
unslop-reviewer
Run a read-only, pass-ordered slop scan covering abstraction and locally fixable boundary findings; never edit files.
unslop-coder
Apply unslop-reviewer findings as targeted in-scope code edits in pass order; do not run discovery/scanning in this skill.
serena
Semantic code retrieval, editing, refactoring and debugging tools using LSP servers
read-image
guidance to read images in a lightweight fashion using cwebp
playwright-cli
Drive browser UI checks with playwright-cli commands, snapshots, and test/debug workflows; do not use for backend-only or non-browser tasks.