Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .codex-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"name": "archipy",
"version": "0.24.0",
"description": "Codex plugin: skills and hooks for building apps with ArchiPy",
"author": {
"name": "SyntaxArc"
},
"repository": "https://github.com/SyntaxArc/archipy-plugin",
"license": "MIT",
"keywords": [
"archipy",
"python",
"clean-architecture",
"codex"
],
"skills": "./skills",
"hooks": {
"SessionStart": [
{
"matcher": "startup|resume|clear|compact|fork",
"hooks": [
{
"type": "command",
"command": "python3 \"${PLUGIN_ROOT}/scripts/scaffold_hygiene.py\" SessionStart",
"statusMessage": "Loading ArchiPy guidance"
}
]
}
],
"PreToolUse": [
{
"matcher": "apply_patch|Write|Edit",
"hooks": [
{
"type": "command",
"command": "python3 \"${PLUGIN_ROOT}/scripts/scaffold_hygiene.py\" PreToolUse",
"statusMessage": "Checking ArchiPy adapter paths"
}
]
}
],
"PostToolUse": [
{
"matcher": "apply_patch|Write|Edit",
"hooks": [
{
"type": "command",
"command": "python3 \"${PLUGIN_ROOT}/scripts/scaffold_hygiene.py\" PostToolUse",
"statusMessage": "Loading ArchiPy file guidance"
}
]
}
]
}
}
8 changes: 5 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# ArchiPy Plugin — Agent Instructions

Works in **Cursor** and **Claude Code**.
Works in **Codex**, **Cursor**, and **Claude Code**.

Consumer plugin for **apps that depend on** PyPI [`archipy`](https://pypi.org/project/archipy/).

Expand All @@ -14,7 +14,7 @@ Consumer plugin for **apps that depend on** PyPI [`archipy`](https://pypi.org/pr

## Prefer plugin entry points

| Need | Skill (slash command) |
| Need | Skill (Codex `$name`; Cursor / Claude slash command) |
|---------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------|
| New app tree | `/scaffold-app` |
| Full domain slice | `/scaffold-domain` |
Expand All @@ -29,11 +29,13 @@ Consumer plugin for **apps that depend on** PyPI [`archipy`](https://pypi.org/pr
Issues, branches, PRs, checklists and merges: use the `pr-steward` plugin skills (`new-issue`, `split-issue`, `open-pr`,
`tick-checklist`, `merge-pr`; https://github.com/SyntaxArc/pr-steward). This plugin no longer ships a contributing rule.

In Codex, invoke a skill as `$skill-name` (for example, `$scaffold-app`). Cursor and Claude Code use slash commands.

Bundled cheat sheet: `skills/archipy-docs/reference.md`.

When a skill runs, read its `SKILL.md` in full before generating files. Resolve
`skills/*/reference/` templates from the plugin installation (Cursor: `$CURSOR_PLUGIN_ROOT`; Claude Code substitutes
`${CLAUDE_SKILL_DIR}` in skills, alongside `${CLAUDE_PLUGIN_ROOT}`), copy
`${CLAUDE_SKILL_DIR}` in skills, alongside `${CLAUDE_PLUGIN_ROOT}`; Codex provides `${PLUGIN_ROOT}`), copy
them into the app, and never edit plugin templates in place.

Live docs: https://syntaxarc.github.io/ArchiPy/
Expand Down
34 changes: 20 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ ln -sfn "$(pwd)" ~/.cursor/plugins/local/archipy
# Claude Code
mkdir -p ~/.claude/plugins/local
ln -sfn "$(pwd)" ~/.claude/plugins/local/archipy

# Codex
codex plugin marketplace add SyntaxArc/archipy-plugin
codex plugin add archipy@archipy
```

Reload the editor after edits.
Expand All @@ -38,25 +42,27 @@ python3 scripts/check_catalog.py
python3 -m unittest discover -s tests -v
```

## Dual IDE parity
## Client manifest parity

Keep Cursor and Claude manifests in sync:
Keep all client manifests in sync:

| File | Field |
|-----------------------------------|----------------------|
| `.cursor-plugin/plugin.json` | `version` |
| `.claude-plugin/plugin.json` | `version` |
| `.codex-plugin/plugin.json` | `version` |
| `.cursor-plugin/marketplace.json` | `plugins[0].version` |
| `.claude-plugin/marketplace.json` | `plugins[0].version` |

All four must share the same SemVer string.
All five must share the same SemVer string.

`hooks` paths **must differ**: Cursor `./hooks/hooks.json`, Claude Code `./hooks/claude-hooks.json`.
Hook formats are client-specific: Cursor uses `./hooks/hooks.json`, Claude Code uses `./hooks/claude-hooks.json`, and
Codex declares its hooks in `.codex-plugin/plugin.json`.

## Release checklist

1. Update `CHANGELOG.md` (Keep a Changelog).
2. Bump all four JSON versions together.
2. Bump all five JSON versions together.
3. Run `python3 scripts/check_catalog.py` and `python3 -m unittest discover -s tests -v`.
4. Open a focused PR; conventional commits (`feat`, `fix`, `docs`, `chore`, …). Merge after CI is green.
5. Tag the merge commit `vX.Y.Z` and push the tag. `.github/workflows/release.yml` re-runs the checks, verifies the
Expand All @@ -65,22 +71,22 @@ All four must share the same SemVer string.

## Hooks

Plugin hooks (both run `scripts/scaffold_hygiene.py`; keep Cursor and Claude Code behavior in parity):
Plugin hooks run `scripts/scaffold_hygiene.py` for all three clients:

| Event | Cursor (`hooks/hooks.json`) | Claude Code (`hooks/claude-hooks.json`) |
|---|---|---|
| Session start | `sessionStart` → `additional_context`: reminder + ArchiPy version | `SessionStart` → `hookSpecificOutput.additionalContext`: reminder + version + always-on rule bodies |
| Before Write | `preToolUse` → `permission: "deny"` for a **new** file under a top-level `adapters/` | `PreToolUse` → `permissionDecision: "deny"`, same condition |
| After edits | `postToolUse` → adapter-path warning | `PostToolUse` → warning + glob-matched rule bodies |
| Event | Cursor (`hooks/hooks.json`) | Claude Code (`hooks/claude-hooks.json`) | Codex (`.codex-plugin/plugin.json`) |
|---|---|---|---|
| Session start | `sessionStart` → `additional_context`: reminder + ArchiPy version | `SessionStart` → `hookSpecificOutput.additionalContext`: reminder + version + always-on rule bodies | `SessionStart` → same context and always-on rules |
| Before file edits | `preToolUse` → deny a **new** file under top-level `adapters/` | `PreToolUse` → deny, same condition | `PreToolUse` on `apply_patch` → deny the same misplaced new file |
| After edits | `postToolUse` → adapter-path warning | `PostToolUse` → warning + glob-matched rule bodies | `PostToolUse` on `apply_patch` → warning + glob-matched rule bodies |

- All hooks run only when the project's `pyproject.toml`, `uv.lock`, or `requirements.txt` depends on `archipy`
(Claude sends `cwd`; Cursor sends `cwd` on tool events and `workspace_roots` everywhere).
- Cursor loads `.mdc` rules natively, so only Claude gets rule bodies. Claude ignores Cursor's top-level
`additional_context`, and Cursor ignores `hookSpecificOutput`.
- Cursor loads `.mdc` rules natively. Claude Code and Codex receive rule bodies through hooks; Cursor ignores
`hookSpecificOutput`.
- Claude path-scoped rules inject once per session (and subagent), reset on each `SessionStart`
(startup/resume/clear/compact).
- The adapter guard only blocks creating new files; existing top-level `adapters/` files in legacy apps stay editable.
- Do not point both manifests at the same hooks file — schemas differ.
- Keep hook configurations client-specific — their schemas and edit tool events differ.

## Evals

Expand Down
46 changes: 29 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
[![ArchiPy Docs](https://img.shields.io/badge/docs-ArchiPy-blue.svg)](https://syntaxarc.github.io/ArchiPy/)
[![ArchiPy](https://img.shields.io/badge/library-SyntaxArc%2FArchiPy-0F172A.svg)](https://github.com/SyntaxArc/ArchiPy)

Rules, skills, and slash commands for **application teams that build
with [ArchiPy](https://github.com/SyntaxArc/ArchiPy)**. Works with both **Cursor** and **Claude Code**.
Rules and skills for **application teams that build
with [ArchiPy](https://github.com/SyntaxArc/ArchiPy)**. Works with **Codex**, **Cursor**, and **Claude Code**.

## What this is

Expand All @@ -16,13 +16,13 @@ It ships:

- **Rules** — persistent guidance while editing matching files
- **Agents** — `archipy-reviewer` for architecture reviews of app diffs
- **Skills** — scaffolding and docs workflows, also invocable as slash commands (`/scaffold-app`, `/docs-helpers`, …)
- **Skills** — scaffolding and docs workflows, invocable as Codex `$skill-name` or Cursor / Claude slash commands

It is **not** for maintaining the ArchiPy library itself (no library changelog or core BDD internals).

## Requirements

- [Cursor](https://cursor.com/) with plugin support, **or** [Claude Code](https://code.claude.com/) with plugin support
- [Codex](https://developers.openai.com/plugins/build/plugins), [Cursor](https://cursor.com/) with plugin support, or [Claude Code](https://code.claude.com/) with plugin support
- Apps targeting **Python 3.14+**
- [`uv`](https://docs.astral.sh/uv/) package manager
- PyPI package [`archipy`](https://pypi.org/project/archipy/) (install the extras your service needs)
Expand Down Expand Up @@ -70,6 +70,17 @@ Then restart Claude Code or run `/reload-plugins`.
/plugin install archipy@archipy
```

### Codex — GitHub marketplace

```bash
codex plugin marketplace add SyntaxArc/archipy-plugin
codex plugin add archipy@archipy
```

Restart Codex or start a new session after installation. Invoke skills as `$skill-name` (for example, `$scaffold-app`).
Codex asks you to review and trust the bundled hooks before running them. Codex loads skills and hooks; the
`archipy-reviewer` subagent remains available only in Cursor and Claude Code.

### Companion plugin: pr-steward

The issue, branch, PR, checklist and merge workflow is not part of this plugin. Install
Expand Down Expand Up @@ -106,11 +117,12 @@ The issue, branch, PR, checklist and merge workflow is not part of this plugin.

### Skills (22)

Every skill is a slash command in both Cursor and Claude Code (Claude Code namespaces them as `/archipy:<name>`).
Cursor and Claude Code expose skills as slash commands (Claude Code namespaces them as `/archipy:<name>`); Codex
invokes them as `$skill-name`.
`docs-*` skills set `disable-model-invocation: true`: they are user shortcuts into `archipy-docs`, so the model sees
each workflow once.

| Skill | Slash | Invoked by | When to use |
| Skill | Cursor / Claude command | Invoked by | When to use |
|--------------------------|---------------------------|-------------|-------------------------------------------------------------------------|
| `scaffold-app` | `/scaffold-app` | Model + you | Bootstrap a new ArchiPy-based service layout |
| `scaffold-domain` | `/scaffold-domain` | Model + you | Full domain slice (models, repo, logic, service) |
Expand Down Expand Up @@ -150,10 +162,10 @@ the layer-producing scaffold skills run it in their `## Verify` step. Claude Cod

## Quick start

1. Install the plugin locally (symlink above) and reload Cursor.
1. Install the plugin above. For Codex, restart Codex or start a new session after installation.
2. Open an application workspace (empty or existing Python service).
3. In Agent chat, run `/scaffold-app` — answer package name and extras (e.g. `redis`).
4. Run `/docs-quickstart` to confirm config + first adapter steps.
3. In Agent chat, invoke `$scaffold-app` in Codex or `/scaffold-app` in Cursor / Claude Code — answer package name and extras (e.g. `redis`).
4. Invoke `$docs-quickstart` in Codex or `/docs-quickstart` elsewhere to confirm config + first adapter steps.
5. Expect: `AppConfig`, models stub, `repositories/<domain>/`, optional `manage.py` (if `fastapi`), helpers tree,
`.env.example`.

Expand Down Expand Up @@ -350,6 +362,7 @@ archipy-plugin/
│ ├── plugin.json # Cursor plugin manifest
│ └── marketplace.json # Cursor marketplace catalog
├── hooks/ # Cursor hooks.json + Claude claude-hooks.json
├── .codex-plugin/ # Codex manifest and hooks
├── scripts/ # Catalog checks + hook scripts
├── rules/ # .mdc rules
├── skills/ # SKILL.md directories (+ docs reference)
Expand All @@ -364,11 +377,11 @@ archipy-plugin/
```

Cursor loads `rules/` (`.mdc`), `skills/`, and `hooks/hooks.json`. Claude Code loads `skills/` and
`hooks/claude-hooks.json`. Claude Code does **not** load Cursor `.mdc` rules. In projects that depend on `archipy`, hooks in both tools add a
reminder and the app's ArchiPy version at session start and block creating new domain adapters outside
`repositories/{domain}/adapters/`; in Claude Code they also inject always-on and glob-matched rule text (once per
session). See `CONTRIBUTING.md` § Hooks.
Skills double as slash commands; only the `docs-*` shortcuts set `disable-model-invocation: true`.
`hooks/claude-hooks.json`. Codex loads `skills/` and the hooks declared in `.codex-plugin/plugin.json`; it does not
load Cursor `.mdc` rules natively. In projects that depend on `archipy`, all three clients add a reminder and the
app's ArchiPy version at session start. Claude Code and Codex also inject always-on and path-matched rule text. The
adapter guard handles Claude `Write` and Codex `apply_patch` operations. See `CONTRIBUTING.md` § Hooks.
Only the `docs-*` shortcuts set `disable-model-invocation: true`.

## ArchiPy docs map

Expand All @@ -388,10 +401,9 @@ Skills double as slash commands; only the `docs-*` shortcuts set `disable-model-

## Developing / contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for the full checklist (version bump across four JSON files, catalog sync, CI).
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full checklist (version bump across five JSON files, catalog sync, CI).

1. Clone this repo and symlink it to `~/.cursor/plugins/local/archipy` (Cursor) or `~/.claude/plugins/local/archipy`
(Claude Code).
1. Clone this repo and install it in your client using the steps above (Codex, Cursor, or Claude Code).
2. Edit rules (`.mdc` frontmatter: `description`, `alwaysApply` / `globs`), skills (`name` + `description` matching
folder name), `docs-*` skills also set
`disable-model-invocation: true`.
Expand Down
1 change: 1 addition & 0 deletions scripts/check_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
MANIFESTS = (
ROOT / ".cursor-plugin" / "plugin.json",
ROOT / ".claude-plugin" / "plugin.json",
ROOT / ".codex-plugin" / "plugin.json",
ROOT / ".cursor-plugin" / "marketplace.json",
ROOT / ".claude-plugin" / "marketplace.json",
)
Expand Down
21 changes: 14 additions & 7 deletions scripts/scaffold_hygiene.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"Domain adapters under repositories/{domain}/adapters/ only. "
"Prefer archipy.helpers.utils (DatetimeUtils, PasswordUtils, JWTUtils, TOTPUtils, StringUtils, FileUtils, AppUtils) "
"over hand-rolled datetime/password/JWT/string code. "
"Prefer the plugin skills (/scaffold-*, /redis-search, archipy-docs)."
"Prefer the plugin skills (scaffold-*, redis-search, archipy-docs)."
)

# Cursor event names (camelCase). Claude Code uses PascalCase and a different hooks.json schema.
# Cursor event names (camelCase). Claude Code and Codex use PascalCase with hookSpecificOutput.
CURSOR_SESSION = "sessionStart"
CURSOR_POST = "postToolUse"
CLAUDE_SESSION = "SessionStart"
Expand All @@ -37,10 +37,14 @@
UV_LOCK_ARCHIPY_RE = re.compile(r'^\[\[package\]\]\nname = "archipy"\nversion = "([^"]+)"', re.MULTILINE)
PYPROJECT_ARCHIPY_RE = re.compile(r"""["']archipy(?:\[([^\]]*)\])?\s*([<>=~!][^"']*)?["']""")
ARCHIPY_DEP_RE = re.compile(r"""(^|[\s"'\[,])archipy([\s"'\[\]=<>~!,]|$)""", re.MULTILINE)
APPLY_PATCH_PATH_RE = re.compile(
r"^\*\*\* (?:Add|Update|Delete) File: (.+)$|^\*\*\* Move to: (.+)$",
re.MULTILINE,
)


def _plugin_root() -> Path:
for key in ("CLAUDE_PLUGIN_ROOT", "CURSOR_PLUGIN_ROOT"):
for key in ("PLUGIN_ROOT", "CLAUDE_PLUGIN_ROOT", "CURSOR_PLUGIN_ROOT"):
raw = os.environ.get(key)
if raw:
return Path(raw)
Expand All @@ -62,12 +66,12 @@ def _emit(payload: dict[str, Any]) -> None:


def _emit_claude(event: str, context: str) -> dict[str, Any]:
"""Build Claude Code hook output; Claude ignores Cursor's top-level `additional_context`."""
"""Build Claude Code / Codex hook output; Cursor ignores `hookSpecificOutput`."""
return {"hookSpecificOutput": {"hookEventName": event, "additionalContext": context}}


def _project_dir(payload: dict[str, Any]) -> Path:
"""Claude sends `cwd`; Cursor sends `cwd` on tool events and `workspace_roots` on every event."""
"""Claude Code and Codex send `cwd`; Cursor also sends `workspace_roots` on every event."""
roots = payload.get("workspace_roots")
root = roots[0] if isinstance(roots, list) and roots else None
return Path(str(payload.get("cwd") or root or os.environ.get("CLAUDE_PROJECT_DIR") or Path.cwd()))
Expand Down Expand Up @@ -165,6 +169,9 @@ def _paths_from_payload(payload: dict[str, Any]) -> list[str]:
value = tool_input.get(key)
if value:
paths.append(str(value))
if payload.get("tool_name") == "apply_patch" and isinstance(tool_input.get("command"), str):
for match in APPLY_PATCH_PATH_RE.finditer(tool_input["command"]):
paths.append(match.group(1) or match.group(2))
elif isinstance(tool_input, str):
try:
parsed = json.loads(tool_input)
Expand Down Expand Up @@ -292,11 +299,11 @@ def _relative_to_cwd(file_path: str, cwd: str) -> str | None:


def _new_adapter_violation(payload: dict[str, Any]) -> str | None:
"""Reason to block a Write that creates a domain adapter outside repositories/{domain}/adapters/.
"""Reason to block a Write/apply_patch that creates an adapter outside repositories/{domain}/adapters/.

Only new files are blocked: legacy apps must still be able to edit an existing top-level adapters/ package.
"""
if payload.get("tool_name") != "Write" or not _is_archipy_app(payload):
if payload.get("tool_name") not in {"Write", "apply_patch"} or not _is_archipy_app(payload):
return None
cwd = str(_project_dir(payload))
for file_path in _paths_from_payload(payload):
Expand Down
2 changes: 1 addition & 1 deletion skills/redis-search/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ to this `SKILL.md`'s directory in the plugin installation — not the app worksp
`reference/fulltext_adapter.py`, `reference/vector_adapter.py`, `reference/search_cache_adapter.py`.

Resolve files under `reference/` relative to this `SKILL.md` in the plugin installation
(`$CURSOR_PLUGIN_ROOT/skills/redis-search/` or `${CLAUDE_SKILL_DIR}/`). These are plugin templates,
(`$PLUGIN_ROOT/skills/redis-search/`, `$CURSOR_PLUGIN_ROOT/skills/redis-search/`, or `${CLAUDE_SKILL_DIR}/`). These are plugin templates,
not app-relative paths. Copy and adapt them into the app; never edit the plugin copies.

## Read first
Expand Down
2 changes: 1 addition & 1 deletion skills/scaffold-bdd/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ FastAPI's `TestClient` needs nothing extra with `archipy[fastapi]`. gRPC tests n
## Generate

Resolve files under `reference/` relative to this `SKILL.md` in the plugin installation
(`$CURSOR_PLUGIN_ROOT/skills/scaffold-bdd/` or `${CLAUDE_SKILL_DIR}/`). These are
(`$PLUGIN_ROOT/skills/scaffold-bdd/`, `$CURSOR_PLUGIN_ROOT/skills/scaffold-bdd/`, or `${CLAUDE_SKILL_DIR}/`). These are
plugin templates, not app-relative paths. Copy and adapt them into the app; never edit the plugin copies.

**Copy templates from `reference/`, adapt package imports, create only if missing:**
Expand Down
Loading
Loading