feat: Add pflow skill command to publish workflows as AI agent skills#81
Conversation
Code Review: Task 119 - Publish Workflows as Claude Code SkillsThis is a solid implementation with excellent test coverage and clean separation of concerns. The code follows project conventions well and the symlink-based architecture is elegant. ✅ Strengths
|
Response to Code ReviewThanks for the thorough review! After careful analysis, I've concluded that no changes are needed. Here's my reasoning: Warning 1: Import Organization (contextlib inside function)Decision: Won't fix This is a lazy import pattern used elsewhere in pflow (e.g., Warning 2: Error Handling GapsDecision: Won't fix The current pattern in except Exception:
Path(temp_path).unlink(missing_ok=True)
raise # Re-raises original exception with full contextThis is the standard atomic write cleanup pattern. The suggested fix would lose the original exception context. In Warning 3: Potential Race Condition (TOCTOU)Decision: Won't fix The pre-check exists for better error messages, not atomicity: if symlink_path.exists() or symlink_path.is_symlink():
raise FileExistsError(f"Skill '{skill_name}' already exists at {symlink_path}")This is a single-user CLI tool. The theoretical race condition is irrelevant in practice. If it did occur, Warning 4: Inconsistent String FormattingDecision: Won't fix The code Warning 5: Missing Validation (Path Traversal)Decision: Won't fix — already mitigated
re.match(r"^[a-z0-9]+(?:-[a-z0-9]+)*$", name)This pattern cannot contain Suggestions 1-5All declined as over-engineering or marginal value for this codebase. Summary: The review raised valid theoretical concerns, but the current implementation is correct for a single-user CLI tool. The patterns used are intentional and consistent with the rest of the codebase. |
Show `|` (literal block scalar) syntax in two existing examples: the yaml body deep nesting example and a batch item prompt. Add parser tests verifying block scalars work inside yaml code blocks.
Implements Task 119 - publish saved workflows as Claude Code skills (and other AI coding tools like Cursor, Codex, Copilot). New commands: - pflow skill save <name> [--personal] [--cursor/--codex/--copilot] - pflow skill list - pflow skill remove <name> [--personal] [--cursor/--codex/--copilot] Also adds: - pflow workflow history <name> - show execution history and last inputs - Re-save detection hook to restore enrichment after workflow save --force - Reserved name "skill" to prevent workflow naming conflicts Key features: - Symlink-based: skills point to saved workflows (single source of truth) - Idempotent: skill save creates or updates without --force - Multi-target: save to multiple tools in one command - Enrichment: adds name/description frontmatter and ## Usage section
- Add 'skill' to Commands section with description - Update 'workflow' description to mention 'history' - Hide planner options (--trace-planner, --planner-model, etc.) - Hide repair options (--auto-repair, --no-update) - Remove Natural Language example (planner is gated) - Fix Examples section formatting (was broken by Click wrapping) - Use compact format: command + description on same line - Update test assertions for new help text
- Add docs/reference/cli/skill.mdx with full command documentation - Add docs/guides/publishing-skills.mdx explaining skill publishing workflow - Update CLI index and workflow reference with skill/history commands - Add skill sections to Claude Code and Cursor integration pages - Link to Anthropic's Agent Skills docs instead of re-explaining concept
Summary
Implements Task 119 - publish saved workflows as AI agent skills for Claude Code, Cursor, Codex, and Copilot.
Skills are symlinks from tool-specific directories to saved workflows in
~/.pflow/workflows/. The workflow file is enriched with a## Usagesection and frontmatter metadata that AI tools can read.Task
119
Changes
New CLI commands:
pflow skill save <name> [--personal] [--cursor/--codex/--copilot]- Publish workflow as skillpflow skill list- List all pflow-managed skills across toolspflow skill remove <name> [--personal] [--cursor/--codex/--copilot]- Remove skill symlinkspflow workflow history <name>- Show execution history and last used inputsCore features:
--forceneeded)## Usagesection and frontmatter metadataworkflow save --forceExplanation
The design uses symlinks rather than copies so that changes to the saved workflow automatically propagate to all tools. The
## Usagesection is injected into the workflow file itself (before## Steps) and is silently ignored by the markdown parser during execution.Multi-target support was added to make pflow useful beyond Claude Code. The same symlink pattern works for all tools - only the directory paths differ.
The
--forceflag was intentionally removed from the spec because symlink creation is naturally idempotent (pointing to the same file), and enrichment replaces rather than duplicates the## Usagesection.Created Docs
.taskmaster/tasks/task_119/task-119.md- Task specification.taskmaster/tasks/task_119/task-review.md- Implementation review.taskmaster/tasks/task_119/implementation/progress-log.md- Development logTesting
Run
make testto verify.