Repository navigation
Conversation
Reviewer's GuideThe PR replaces a late, path-based comment rule with a dedicated auto-triggered comment-style skill and a shared pre-write gate delivered at session and every subagent start, while preserving fail-open behavior and adding documentation and hook tests. Sequence diagram for the comment-style pre-write gatesequenceDiagram
participant Session as SessionStart
participant Subagent as SubagentStart
participant Gate as comment-gate.txt
participant Agent as Agent
participant Skill as comment-style
participant Review as code-reviewer
Session->>Gate: read gate text
Gate-->>Session: gate with absolute plugin path
Session->>Agent: add pre-write self-check
Subagent->>Gate: read gate text
Gate-->>Subagent: gate with absolute plugin path
Subagent->>Agent: add pre-write self-check
Agent->>Skill: activate on comment-style, cold read, or comment-fix request
Skill-->>Agent: normative rule and examples
Agent->>Review: submit changed code
Review->>Skill: apply comment hygiene rule
Flow diagram for fail-open SubagentStart behaviorflowchart TD
Start[SubagentStart] --> Python{python3 available}
Python -->|no| Silent[exit zero without output]
Python -->|yes| Read[read comment-gate.txt as UTF-8]
Read --> Available{file readable and non-empty}
Available -->|no| Silent
Available -->|yes| Substitute[substitute absolute plugin path]
Substitute --> Context[emit additionalContext]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 4 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="plugins/functional-clarity/hooks/subagent_comment_gate.py" line_range="58" />
<code_context>
+ "additionalContext": text,
+ }
+ }
+ print(json.dumps(output, ensure_ascii=False))
+ return 0
+
</code_context>
<issue_to_address>
**Subagent gate fails on legacy encodings**
When a Python runtime's stdout encoding cannot represent the gate text, such as under a legacy locale or code page, `print` serializes the Russian and symbol-containing gate with `ensure_ascii=False`; when stdout uses an encoding that cannot represent those characters, it raises `UnicodeEncodeError` and the SubagentStart hook emits no context. The subagent starts without the rule and the hook reports a failure.
Use ASCII-escaped JSON (omit `ensure_ascii=False`) or explicitly configure stdout for UTF-8 before printing.
</issue_to_address>
### Comment 2
<location path="plugins/functional-clarity/hooks/session-start.sh" line_range="31-32" />
<code_context>
EOF
+
+if [[ -n "$CLAUDE_PLUGIN_ROOT" ]]; then
+ gate_text="$(cat "${CLAUDE_PLUGIN_ROOT}/hooks/comment-gate.txt" 2>/dev/null)"
+ echo "${gate_text//\{\{PLUGIN_ROOT\}\}/$CLAUDE_PLUGIN_ROOT}"
+fi
</code_context>
<issue_to_address>
**Invalid gate bytes reach session context**
When the gate file contains bytes that are not valid UTF-8, `session-start.sh` stores `cat`'s raw bytes in `gate_text` and `echo` forwards them without validation, so the session receives corrupted gate text or a malformed hook response instead of remaining silent.
Validate the gate text as UTF-8 before echoing it and emit nothing when it is invalid.
</issue_to_address>
### Comment 3
<location path="plugins/functional-clarity/hooks/session-start.sh" line_range="32" />
<code_context>
+
+if [[ -n "$CLAUDE_PLUGIN_ROOT" ]]; then
+ gate_text="$(cat "${CLAUDE_PLUGIN_ROOT}/hooks/comment-gate.txt" 2>/dev/null)"
+ echo "${gate_text//\{\{PLUGIN_ROOT\}\}/$CLAUDE_PLUGIN_ROOT}"
+fi
</code_context>
<issue_to_address>
**Allowed XXX comments are rejected**
When an agent is writing or evaluating an unfinished-work comment using `XXX`, an agent considering an unfinished-work comment marked `XXX` receives a gate that names only `TODO/FIXME` as the accepted format, while the normative skill explicitly allows `XXX` with content. The gate therefore discourages a comment the skill permits.
Add `XXX` with content to the gate's unfinished-work exception so it matches the normative allowlist.
Also at `plugins/functional-clarity/hooks/subagent_comment_gate.py:55`.
</issue_to_address>
### Comment 4
<location path="plugins/functional-clarity/skills/functional-clarity/SKILL.md" line_range="130" />
<code_context>
- **`references/03-developer-levels.md`** — Developer level definitions (Junior → Senior+)
- **`references/04-bash-instructions.md`** — Bash script guidelines
- **`references/frameworks/python.md`** — Python-specific: modern syntax, pathlib, type annotations, pytest patterns
</code_context>
<issue_to_address>
**Comment-style source link is broken**
When a reader follows the comment-style Sources link in the functional-code-clarity spec, the Sources link still targets `plugins/functional-clarity/skills/functional-clarity/references/05-comment-style.md`, which no longer exists after the rule moved to the `comment-style` skill, so readers following the spec get a missing file.
Update the spec link to `plugins/functional-clarity/skills/comment-style/SKILL.md`.
</issue_to_address>Sourcery assessment
Approval pending. 3 findings to address first.
Blocking findings: plugins/functional-clarity/hooks/subagent_comment_gate.py:58, plugins/functional-clarity/hooks/session-start.sh:32, plugins/functional-clarity/hooks/session-start.sh:32
The norm sat in the context of almost every session and still had to be asked for by hand. The SessionStart hook described it in a paragraph and pointed at references/05-comment-style.md — a path relative to a plugin directory the model cannot resolve, so reaching the norm started with a filesystem-wide search and happened after the review rather than before the write. Subagents never saw the rule at all: SessionStart fires per session, and subagents write most of the code. The norm now lives in its own skill, comment-style, whose description names the phrasings it must answer to — comment style, cold read, "поправь комментарии" — so the skill loads without being named. The normative text itself is unchanged apart from the enforcement section, which lists three layers instead of two. The gate text moved to hooks/comment-gate.txt, one source for every consumer. It states when it fires, lists the four forbidden classes one line each, and asks for a self-check before submitting, in place of the descriptive paragraph. The carve-outs for external standards and versioned-API notes are new and account for the roughly 400 characters of added length. The norm's address is substituted from the plugin directory at run time, so it is absolute and opens in one read. A SubagentStart hook puts the same gate into every subagent's context, with no agent-type matcher: a subagent from any marketplace receives it, and a new writing agent cannot fall out of coverage silently. The gate stays silent and exits zero whenever its text is unavailable, including a file that does not decode as UTF-8. When python3 is missing the hook does not start at all — otherwise every subagent launch would carry a hook-error notice, noise where the design calls for silence. Pointers in functional-clarity and in the sdlc skills name the skill instead of the file path. The plugin version is not bumped — bumping belongs to the release pass. (cherry picked from commit c638870) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Спецификация прежде задавала содержание комментария, но не передачу правила основному агенту и субагентам. Теперь договор доставки отделён от предписаний модели, а завершённое описание изменения сохраняет сценарии отказа, результаты регрессионных проверок и ограничения общей проверки исходного проекта. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The norm sat in the context of almost every session and still had to be asked for by hand. The SessionStart hook described it in a paragraph and pointed at references/05-comment-style.md — a path relative to a plugin directory the model cannot resolve, so reaching the norm started with a filesystem-wide search and happened after the review rather than before the write. Subagents never saw the rule at all: SessionStart fires per session, and subagents write most of the code.
The norm now lives in its own skill, comment-style, whose description names the phrasings it must answer to — comment style, cold read, "поправь комментарии" — so the skill loads without being named. The normative text itself is unchanged apart from the enforcement section, which lists three layers instead of two.
The gate text moved to hooks/comment-gate.txt, one source for every consumer. It states when it fires, lists the four forbidden classes one line each, and asks for a self-check before submitting, in place of the descriptive paragraph. The carve-outs for external standards and versioned-API notes are new and account for the roughly 400 characters of added length. The norm's address is substituted from the plugin directory at run time, so it is absolute and opens in one read.
A SubagentStart hook puts the same gate into every subagent's context, with no agent-type matcher: a subagent from any marketplace receives it, and a new writing agent cannot fall out of coverage silently.
The gate stays silent and exits zero whenever its text is unavailable, including a file that does not decode as UTF-8. When python3 is missing the hook does not start at all — otherwise every subagent launch would carry a hook-error notice, noise where the design calls for silence.
Pointers in functional-clarity and in the sdlc skills name the skill instead of the file path.
The plugin version is not bumped — bumping belongs to the release pass.
(cherry picked from commit c638870)
Summary by Sourcery
Make comment guidance available before code changes by promoting it to a dedicated skill and delivering a shared, fail-open gate to sessions and every subagent.
New Features:
Bug Fixes:
Enhancements:
Documentation:
Tests:
Chores: