os-sdlc: code-write skill — mechanical code writes (ast-grep rewrites + new-file Write) with post-apply lint hook #337
Labels
No labels
P0
P1
P2
P3
bug
create
delete
enhancement
filed-by/agent
filed-by/user
frozen
lint-rule
needs-info
needs-triage
next
plugin/cc-architect
plugin/os
plugin/os-adr
plugin/os-aidd-lint
plugin/os-backlog
plugin/os-context
plugin/os-doc-hygiene
plugin/os-sdlc
plugin/os-vault
project/cc-os
ready-for-agent
ready-for-human
recurring
review
update
waiting
wayfinder:grilling
wayfinder:map
wayfinder:map
wayfinder:research
wayfinder:task
wayfinder:task
wontfix
worklist/deviations
worklist/lint-rule
worklist/new-implement-build
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
jared/cc-os#337
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Create an ast-grep write skill (working name
code-rewrite, sibling ofcode-probein os-sdlc) that applies mechanical code changes structurally — probe, rewrite, preview, apply, lint — without Read/Write on the target file. Proven end-to-end on #316 (commita1710ed): investigation and both edits ran ast-grep-only; the two gotchas below were hit and are now the skill's reason to exist.Steps (skill body in pseudocode-skill style)
Cross-cutting preamble: mechanical transforms only — if choosing the replacement requires deciding behavior, stop and emit the matched slices plus the decision question (same gate as code-probe's rewrite.md). Never Read the target file; matched slices + preview diffs are the only context.
1. Name and scaffold
plugins/cc-architect/references/conventions/cc-os-naming.md-> noun-first kebab-case, noname:in frontmatterdescription: artifact-category-first ("A rewrite procedure that turns a mechanical change decision into an applied, linted, test-verified diff …")when_to_use: reader problem state, not a pipeline phase ("You have a settled mechanical change and want it applied structurally without loading the file")2. Locate the target structurally
ast-grep run --lang ruby -p '<pattern>' <path>— definition and call-site shapes from code-probe's cheatsheet3. Draft the rewrite
ast-grep run --lang ruby -p '<pattern>' --rewrite '<fix>' <path>(no-U= preview)kind:, relational rules, orcontext:/selector:-> only then write a YAML rule and usescan4. Preview, apply, lint
-Urubocop -a --only Layout/TrailingWhitespace <file>; other languages:sed -i 's/[ \t]*$//' <file>5. Verify
Reference files
rewrite.md(currently under code-probe's references/) so this skill owns the rewrite mechanics doc; code-probe keeps pointing at it for the fix-preview-as-evidence use1e90e5c), instead of telling the reader to go read files--rewriteform to rewrite.md — it currently documents only the YAML pathAcceptance
howto/writing-pseudocode-style-skills.md)os-sdlc: code-rewrite skill — ast-grep structural edits with post-apply lintto os-sdlc: code-write skill — mechanical code writes (ast-grep rewrites + new-file Write) with post-apply lint hookGrilling session 2026-08-10 — decision record (supersedes body where they differ):
code-write— all mechanical code writes. Existing file → ast-grep structural rewrite (anchored insertions included); nonexistent file → single Write, no read-back; scaffolding generators compatible. Invariant: never Read the target.ast-grep … -U, and Write of.rbfiles — runningrubocop -aon changed files only (per-file config resolution; never repo-wide: root-config run currently shows ~3,500 autocorrectable offenses). Skill has no lint step; step-5 verify is the backstop.Work started 2026-08-10: building the code-write skill per the decision record comment above. Working directly on main in ~/dev/cc-os (no PR branch yet).
Resolution
Done: Built the os-sdlc code-write skill: ast-grep structural rewrites with caller-intent create/transform branching, probe-pattern reuse, injected pattern catalog, preview-judged applies; moved rewrite.md to code-write; code-probe brief now emits matched patterns; added lint_changed.rb PostToolUse hook with tests. Verify step removed — testing/linting owned by hooks and the Runner state machine.
Evidence: Commit
471af272fcon main (jared/cc-os)Follow-ups: none
Approved-by: jared, in-session review 2026-08-11