{"id":50055998,"url":"https://github.com/code-yeongyu/codex-rules","last_synced_at":"2026-05-21T13:14:44.350Z","repository":{"id":358282349,"uuid":"1239591653","full_name":"code-yeongyu/codex-rules","owner":"code-yeongyu","description":"Codex plugin that injects project rule files into model context through lifecycle hooks.","archived":false,"fork":false,"pushed_at":"2026-05-16T16:29:25.000Z","size":144,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-16T17:31:06.707Z","etag":null,"topics":["agents-md","codex","codex-plugin","context-injection","hooks","rules","typescript"],"latest_commit_sha":null,"homepage":"https://github.com/code-yeongyu/codex-rules","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/code-yeongyu.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE","maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2026-05-15T08:39:33.000Z","updated_at":"2026-05-16T15:28:43.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/code-yeongyu/codex-rules","commit_stats":null,"previous_names":["code-yeongyu/codex-rules"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/code-yeongyu/codex-rules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fcodex-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fcodex-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fcodex-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fcodex-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/code-yeongyu","download_url":"https://codeload.github.com/code-yeongyu/codex-rules/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/code-yeongyu%2Fcodex-rules/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33301847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-21T12:23:38.849Z","status":"ssl_error","status_checked_at":"2026-05-21T12:22:11.673Z","response_time":62,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agents-md","codex","codex-plugin","context-injection","hooks","rules","typescript"],"created_at":"2026-05-21T13:14:39.300Z","updated_at":"2026-05-21T13:14:44.338Z","avatar_url":"https://github.com/code-yeongyu.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# codex-rules\n\nCodex plugin that injects local project rule files into model context through lifecycle hooks.\n\nIt ports the `pi-rules` rule injector to Codex:\n\n- `SessionStart` and `UserPromptSubmit` load static project instructions once per session.\n- `PostToolUse` watches Codex `apply_patch` by default, then injects matching file-specific rules as additional context.\n- `PostCompact` clears the per-session injection cache after manual or automatic compaction so relevant rules can be reintroduced into the compacted conversation.\n- Session-level deduplication prevents the same rule from being repeated after it has been injected.\n\n`PostToolUse` output is context-only: it emits `hookSpecificOutput.additionalContext` and does not rewrite tool output.\n\nThe runtime has no npm production dependencies, so a clean Codex marketplace copy can run without a follow-up `npm install`.\n\n## Rule Sources\n\nProject-level sources:\n\n- `AGENTS.md`\n- `CLAUDE.md`\n- `CONTEXT.md`\n- `.omo/rules/**/*.md`\n- `.claude/rules/**/*.md`\n- `.cursor/rules/**/*.md`\n- `.github/instructions/**/*.md`\n- `.github/copilot-instructions.md`\n\nUser-home sources are also supported by the ported engine when available.\n\nMarkdown rule files may use frontmatter such as:\n\n```md\n---\ndescription: TypeScript defaults\nglobs: [\"**/*.ts\", \"**/*.tsx\"]\nalwaysApply: false\n---\n\nPrefer strict TypeScript and keep runtime imports ESM-compatible.\n```\n\n## Install Locally\n\nFrom the marketplace workspace:\n\n```bash\ncodex plugin marketplace add /Users/yeongyu/local-workspaces/codex-plugins\nnode /Users/yeongyu/local-workspaces/codex-plugins/scripts/install-local.mjs /Users/yeongyu/local-workspaces/codex-plugins\n```\n\nThe local installer builds the plugin and copies a clean cache entry to:\n\n```text\n~/.codex/plugins/cache/code-yeongyu-codex-plugins/codex-rules/0.1.0\n```\n\nIt also enables:\n\n```toml\n[features]\nplugins = true\nplugin_hooks = true\n\n[plugins.\"codex-rules@code-yeongyu-codex-plugins\"]\nenabled = true\n```\n\n## Configuration\n\nUse `CODEX_RULES_*` environment variables:\n\n| Variable | Values | Default |\n| --- | --- | --- |\n| `CODEX_RULES_DISABLED` | `1`, `true`, `yes`, `on` | unset |\n| `CODEX_RULES_MODE` | `both`, `static`, `dynamic`, `off` | `both` |\n| `CODEX_RULES_MAX_RULE_CHARS` | positive integer | `12000` |\n| `CODEX_RULES_MAX_RESULT_CHARS` | positive integer | `40000` |\n| `CODEX_RULES_ENABLED_SOURCES` | comma-separated source names | `auto` |\n\nFor migration from `pi-rules`, equivalent `PI_RULES_*` variables are accepted as fallbacks.\n\n## Debugging\n\nEnable hook phase timing with `NODE_DEBUG=codex-rules`:\n\n```bash\nNODE_DEBUG=codex-rules node dist/cli.js hook post-tool-use \u003c fixture.json\n```\n\nDebug lines go to stderr and hook JSON stays on stdout. The log includes `PostToolUse` phases such as `extract`, `fingerprint`, `load`, `persist`, elapsed `ms`, target counts, pending counts, rule counts, and output bytes. It does not log rule bodies or tool response contents.\n\nThe default `PostToolUse` hook matcher is intentionally strict: it matches only Codex's canonical `apply_patch` hook tool name. Read tools, MCP filesystem tools, shell commands, and Claude-style `Write`/`Edit` aliases are not registered by default.\n\n## Development\n\n```bash\nnpm install\nnpm test\nnpm run check\nnpm run typecheck\nnpm pack --dry-run\n```\n\nPerformance smoke test:\n\n```bash\nnpm run bench\n```\n\nBenchmark timings depend on the local machine. Use the relative counters and repeat-output checks when comparing runs.\n\nHook smoke test:\n\n```bash\nnpm run build\nprintf '%s\\n' '{\"session_id\":\"s\",\"transcript_path\":null,\"cwd\":\"/path/to/project\",\"hook_event_name\":\"SessionStart\",\"model\":\"gpt-5.5\",\"permission_mode\":\"default\",\"source\":\"startup\"}' \\\n  | PLUGIN_DATA=/tmp/codex-rules-data node dist/cli.js hook session-start\n```\n\n## Privacy\n\n`codex-rules` runs locally. It reads local rule files and Codex hook payloads, writes per-session deduplication state under the Codex plugin data directory, and does not make network requests.\n\n## License\n\nMIT. See [LICENSE](LICENSE) and [NOTICE](NOTICE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-yeongyu%2Fcodex-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcode-yeongyu%2Fcodex-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcode-yeongyu%2Fcodex-rules/lists"}