ask-matt
MAmattpocock/skills337k近 7 天新增 4,978 个 star
Persist design documents with branch tracking, revision chains, and cross-session discovery
Host: Codex CLI — This skill was designed for Claude Code and adapted for Codex. Invoke installed skills by their
$skill-name. Known Octopus commands are mapped below. A remaining/octo:*reference is a Claude Code command; do not execute it in Codex or invent an equivalent. Before the first helper call, derive the absolute plugin root from this loaded skill's path by finding its ancestor containing.codex-plugin/plugin.json. Verify that root, bindOCTO_ROOT,CODEX_PLUGIN_ROOT, andCLAUDE_PLUGIN_ROOTto the same root, and export all three in each fresh shell before launching child processes. Use the verified absolute helper path when needed. Do not infer the root from the user's project or assume exports survive tool calls. Stop and report a missing installation if the root cannot be verified. Use the active Codex shell and subagent tools. Do not claim a provider, model, or host subagent is available until the current session exposes it. Claude-native tool calls in examples are prompt templates to adapt, not Codex call signatures. If a mandatory verification agent or tool is unavailable or unauthorized, report that verification did not run and stop the affected completion step. Never claim a skipped check passed. Attribute commits only to actual contributors; do not copy fixed model attribution trailers from examples. For host tool equivalents, seecodex-skills/blocks/codex-host-adapter.md.
Invoke this entry as
$skill-design-lineagein Codex. Code-fenced Claude command examples are reference text, not Codex shell commands.
When a design introduces or changes domain terms, load
codex-skills/blocks/domain-modeling.md. Record each definition in the existing design
lineage artifact with its evidence source, checked time, and scope. A changed
definition invalidates dependent decisions. Link and reopen them instead of
leaving stale implementation guidance marked current.
Persist design documents from brainstorming and planning sessions with branch tracking, revision chains, and cross-session discoverability. Design docs are immutable after creation -- new revisions supersede prior versions rather than editing in place.
All design documents are stored under:
~/.claude-octopus/designs/<project-slug>/
The project slug is derived from the current git repository name or working directory basename:
SLUG=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)")
DESIGNS_DIR="${HOME}/.claude-octopus/designs/${SLUG}"
mkdir -p "$DESIGNS_DIR"
Design documents follow a strict naming convention:
{user}-{branch}-design-{datetime}.md
Where:
{user} -- the current OS username ($USER or whoami){branch} -- the current git branch with slashes replaced with dashes,
or no-branch if Git cannot resolve HEAD{datetime} -- ISO 8601 compact timestamp (YYYYMMDD-HHmmss)If that filename already exists, the new design adds a unique suffix before
.md. Both documents remain available in the revision history.
Example:
chris-feature-auth-refactor-design-20260321-143022.md
Resolution:
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) || BRANCH=no-branch
BRANCH_SLUG=${BRANCH//\//-}
DATETIME=$(date -u +"%Y%m%d-%H%M%S") || exit 1
FILENAME="${USER}-${BRANCH_SLUG}-design-${DATETIME}.md"
Each design document contains YAML frontmatter followed by structured sections.
---
branch: feature/auth-refactor
user: chris
created: 2026-03-21T14:30:22Z
supersedes: chris-feature-auth-refactor-design-20260320-091500.md
---
Fields:
branch -- the git branch at time of creationuser -- the OS username who created the documentcreated -- ISO 8601 timestamp of creationsupersedes -- filename of the prior design document this revision replaces (omitted if this is the first design for the branch)# Design: [Title]
## Problem Statement
[What problem does this design solve? Why does it matter?]
## Constraints
[Technical, timeline, resource, or organizational constraints that bound the solution space.]
## Approaches Considered
[List each approach evaluated, with brief pros/cons for each.]
### Approach A: [Name]
- **Pros:** ...
- **Cons:** ...
### Approach B: [Name]
- **Pros:** ...
- **Cons:** ...
## Recommendation
[Which approach is recommended and why. Include the key trade-off that drove the decision.]
## Open Questions
[Unresolved questions that may affect implementation or require follow-up.]
After a brainstorm, planning, or define workflow produces design output, save it to the standard location with metadata.
SLUG=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)")
DESIGNS_DIR="${HOME}/.claude-octopus/designs/${SLUG}"
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) || BRANCH=no-branch
BRANCH_SLUG=${BRANCH//\//-}
timestamps=$(date -u "+%Y%m%d-%H%M%S %Y-%m-%dT%H:%M:%SZ") || exit 1
IFS=' ' read -r DATETIME CREATED <<< "$timestamps"
mkdir -p "$DESIGNS_DIR" || exit 1
FILENAME="${USER}-${BRANCH_SLUG}-design-${DATETIME}.md"
FRONTMATTER_DELIMITER=---
FILEPATH=$(python3 -I -c '
import os
from pathlib import Path
import shutil
import sys
import tempfile
destination = Path(sys.argv[1])
with tempfile.NamedTemporaryFile(dir=destination.parent, prefix=".design-") as draft:
shutil.copyfileobj(sys.stdin.buffer, draft)
draft.flush()
# Publish the complete document without replacing an existing revision.
try:
os.link(draft.name, destination)
except FileExistsError:
suffix = Path(draft.name).name[len(".design-"):]
destination = destination.with_name(f"{destination.stem}-{suffix}.md")
os.link(draft.name, destination)
print(destination)
' "$DESIGNS_DIR/$FILENAME" <<EOF
${FRONTMATTER_DELIMITER}
branch: ${BRANCH}
user: ${USER}
created: ${CREATED}
${SUPERSEDES:+supersedes: ${SUPERSEDES}}
${FRONTMATTER_DELIMITER}
# Design: [Title]
## Problem Statement
[Content from brainstorm/planning session]
## Constraints
[Identified constraints]
## Approaches Considered
[Evaluated approaches]
## Recommendation
[Selected approach and rationale]
## Open Questions
[Unresolved items]
EOF
) || exit 1
FILENAME="${FILEPATH##*/}"
printf 'Design saved to %s\n' "$FILEPATH"
Design docs are read-only after creation. To revise a design, create a new document with a supersedes reference to the prior version.
Before writing a new design, search for related prior designs using keyword matching.
SLUG=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)")
DESIGNS_DIR="${HOME}/.claude-octopus/designs/${SLUG}"
# Search for designs matching keywords (case-insensitive)
KEYWORDS="auth refactor"
grep -li "$KEYWORDS" "${DESIGNS_DIR}"/*.md 2>/dev/null | head -10
Constraints:
grep -liWhen prior designs are found, present them to the user:
Found 2 prior designs related to "auth refactor":
1. chris-feature-auth-refactor-design-20260320-091500.md (2026-03-20)
2. chris-main-design-20260315-140000.md (2026-03-15)
Would you like to review any of these before creating a new design?
If a prior design exists for the same branch, use the newest matching document
as SUPERSEDES before saving the next revision. Compare the original branch in
the frontmatter because different branch names can share a filename slug.
Existing designs keep their original filenames.
SLUG=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)")
DESIGNS_DIR="${HOME}/.claude-octopus/designs/${SLUG}"
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null) || BRANCH=no-branch
BRANCH_DESIGNS=$(python3 -I - "$DESIGNS_DIR" "$BRANCH" <<'PY_DESIGNS'
from pathlib import Path
import sys
root = Path(sys.argv[1])
branch_field = f"branch: {sys.argv[2]}"
matches = []
for design in root.glob("*-design-*.md"):
try:
if not design.is_file() or "\n" in design.name:
continue
with design.open(encoding="utf-8") as document:
if document.readline().rstrip("\n") != "---":
continue
branches = []
for line in document:
line = line.rstrip("\n")
if line == "---":
if branches == [branch_field]:
matches.append((design.stat().st_mtime_ns, design.name))
break
if line.startswith("branch:"):
branches.append(line)
except (OSError, UnicodeError):
continue
for _, name in sorted(matches, reverse=True)[:3]:
print(name)
PY_DESIGNS
) || exit 1
SUPERSEDES=${BRANCH_DESIGNS%%$'\n'*}
This creates a linked chain of revisions:
v3 (supersedes: v2) -> v2 (supersedes: v1) -> v1 (no supersedes)
To walk the full revision history, start with the design just saved. In a fresh
shell, set FILENAME to the basename of the printed path and DESIGNS_DIR to
the design directory from Step 1. Follow supersedes only in the frontmatter.
If a revision is missing, unreadable, or part of a cycle, report the history as
incomplete.
python3 -I - "${DESIGNS_DIR:?}" "${FILENAME:?}" <<'PY_HISTORY'
from pathlib import Path
import stat
import sys
root, current = Path(sys.argv[1]), sys.argv[2]
history = []
while current:
if current in history:
sys.exit(f"Revision history incomplete: cycle at {current!r}")
name = Path(current)
if name.name != current or not name.match("*-design-*.md") or "\n" in current:
sys.exit(f"Revision history incomplete: invalid filename {current!r}")
design = root / name
try:
if not stat.S_ISREG(design.lstat().st_mode):
raise ValueError("expected a regular design file")
with design.open("rb") as document:
if document.readline().rstrip(b"\r\n") != b"---":
raise ValueError("missing frontmatter")
predecessors = []
for raw_line in document:
line = raw_line.decode("utf-8").rstrip("\r\n")
if line == "---":
break
if line.startswith("supersedes:"):
predecessors.append(line.split(":", 1)[1].strip())
else:
raise ValueError("unclosed frontmatter")
if len(predecessors) > 1:
raise ValueError("multiple supersedes fields")
except (OSError, ValueError) as error:
sys.exit(f"Revision history incomplete: {current!r}: {error}")
history.append(current)
current = predecessors[0] if predecessors else ""
print("\n".join(history))
PY_HISTORY
Downstream commands (deliver, review, develop) can auto-discover design context. Run the lookup block from Step 3 in the same shell before running this block. It returns up to three filenames for the current branch, newest first.
if [[ -n "$BRANCH_DESIGNS" ]]; then
echo "Design context found for branch ${BRANCH}:"
while IFS= read -r design; do
printf ' - %s\n' "$design"
done <<< "$BRANCH_DESIGNS"
DESIGN_CONTEXT=$(<"${DESIGNS_DIR}/${SUPERSEDES}")
fi
Downstream skills should check for designs before starting work:
Use when the user asks whether the code still matches the saved designs. The check is read-only: never edit code or designs while running it.
List the current design of each revision chain, newest first. A design named
in another design's supersedes field is history and is skipped. At most ten
designs are checked per run. Incomplete revision chains stop selection before
any designs are compared.
The store is keyed by directory basename. Before comparing or writing a report, confirm that the selected designs belong to the current checkout. If their ownership is unclear, ask the user to confirm the design paths. If ownership cannot be confirmed, stop and report the affected paths as incomplete.
SLUG=$(basename "$(git rev-parse --show-toplevel 2>/dev/null || pwd)")
DESIGNS_DIR="${HOME}/.claude-octopus/designs/${SLUG}"
DRIFT_DESIGNS=$(python3 -I - "$DESIGNS_DIR" <<'PY_DRIFT'
from pathlib import Path
import stat
import sys
root = Path(sys.argv[1])
designs, predecessors, incomplete = [], {}, []
try:
candidates = sorted(path for path in root.iterdir() if path.match("*-design-*.md"))
except FileNotFoundError:
candidates = []
except OSError:
sys.exit(f"Revision chain selection incomplete: cannot list {str(root)!r}")
for design in candidates:
try:
metadata = design.lstat()
if not stat.S_ISREG(metadata.st_mode) or "\n" in design.name:
raise ValueError("invalid design file")
# Decode one line at a time so unreadable body text does not hide
# otherwise readable revision links.
with design.open("rb") as document:
if document.readline().rstrip(b"\r\n") != b"---":
raise ValueError("missing frontmatter")
previous = []
for raw_line in document:
line = raw_line.decode("utf-8").rstrip("\r\n")
if line == "---":
break
if line.startswith("supersedes:"):
previous.append(line.split(":", 1)[1].strip())
else:
raise ValueError("unclosed frontmatter")
if len(previous) > 1:
sys.exit(f"Revision chain selection incomplete: {design.name!r} has multiple supersedes fields.")
predecessors[design.name] = previous[0] if previous else ""
designs.append((metadata.st_mtime_ns, design.name))
except (OSError, ValueError):
incomplete.append(design.name)
if incomplete:
for name in incomplete:
print(f"Incomplete: cannot read design metadata for {name!r}", file=sys.stderr)
sys.exit("Revision chain selection incomplete; no designs compared.")
checked = set()
for name in predecessors:
revision, chain = name, set()
while revision and revision not in checked:
if revision in chain:
sys.exit(f"Revision chain selection incomplete: cycle at {revision!r}.")
if revision not in predecessors:
sys.exit(f"Revision chain selection incomplete: missing predecessor {revision!r} in the chain for {name!r}.")
chain.add(revision)
revision = predecessors[revision]
checked.update(chain)
superseded = set(predecessors.values())
current = [name for _, name in sorted(designs, reverse=True) if name not in superseded]
for name in current[:10]:
print(name)
if len(current) > 10:
print(f"Drift check skipped {len(current) - 10} older designs", file=sys.stderr)
PY_DRIFT
) || exit 1
printf '%s\n' "$DRIFT_DESIGNS"
If selection fails, include its diagnostics in the report once checkout ownership is confirmed. Stop the check without comparing designs, since an unreadable revision could supersede a readable one. Otherwise, proceed one design at a time:
Incomplete,
never No drift found.After confirming checkout ownership, create a unique report file:
DRIFT_TIMESTAMP=$(date -u +%Y%m%dT%H%M%SZ) || exit 1
mkdir -p -- "${DESIGNS_DIR}/drift" || exit 1
DRIFT_REPORT=$(mktemp "${DESIGNS_DIR}/drift/drift-${DRIFT_TIMESTAMP}-XXXXXX") || exit 1
printf '%s\n' "$DRIFT_REPORT"
Include one section per design with its filename, then each difference with
file:line evidence, No drift found or Incomplete. Give the user the path.
The user decides whether the code or the design should change. Save design
changes as new revisions.
Cap enforcement:
DOC_COUNT=$(ls "${DESIGNS_DIR}"/*.md 2>/dev/null | wc -l | tr -d ' ')
if [[ "$DOC_COUNT" -ge 50 ]]; then
echo "Warning: ${DOC_COUNT} design docs in ${DESIGNS_DIR}. Consider archiving old designs."
fi
Design docs are read-only after creation. To update a design:
supersedes to the prior document's filenameThis ensures a complete history of design evolution is always available.
MAmattpocock/skills337k近 7 天新增 4,978 个 star
MAmattpocock/skills337k近 7 天新增 4,978 个 star
MAmattpocock/skills337k近 7 天新增 4,978 个 star
OBobra/superpowers331k近 7 天新增 4,772 个 star
AFaffaan-m/ECC315k近 7 天新增 4,381 个 star
AFaffaan-m/ECC315k近 7 天新增 4,381 个 star