Skip to content

docs(skills): fix styleguide skills + add hook so they actually trigger#6083

Open
valkirilov wants to merge 3 commits into
mainfrom
docs/agent-styleguide-triggering
Open

docs(skills): fix styleguide skills + add hook so they actually trigger#6083
valkirilov wants to merge 3 commits into
mainfrom
docs/agent-styleguide-triggering

Conversation

@valkirilov

@valkirilov valkirilov commented Jun 17, 2026

Copy link
Copy Markdown
Member

Why

We've been seeing PRs where agents ignore our frontend file-organization and testing (factory) conventions. Investigation found two root causes — not "skills aren't installed":

  1. Triggering is model-discretionary. Skills are registered fine (.claude/skills.ai/skills, good descriptions). But skill invocation is up to the model: on a task like "implement feature X", an agent dives into editing files and never pauses to load frontend/testing. The rules that get violated (FE structure, test factories) are exactly the ones not in CLAUDE.md's always-loaded layer — so they depended entirely on a skill firing.

  2. The skills taught the wrong pattern. The repo has an established convention — redisinsight/ui/src/mocks/factories/ (21 Fishery factories used by 55 specs) — that the testing skill never mentioned. Its frontend examples modeled inline mock objects, i.e. the anti-pattern. So even when the skill fired, the agent followed it correctly into the wrong code.

What changed

Fix the skills (commits 1–2)

  • testing skill now documents the real mocks/factories/<domain>/<Name>.factory.ts convention and shows reuse instead of inline mocks.
  • frontend skill's renderComponent example builds default props from a factory.

Enforce triggering (commit 3)

  • New PreToolUse hook (.ai/hooks/styleguide-reminder.sh) on Edit/Write/MultiEdit that maps the changed path to its styleguide and injects a reminder, so the rules no longer rely on a skill self-triggering:

    Path edited Skill(s) surfaced
    redisinsight/ui/src/** frontend (+ testing for *.spec.ts(x))
    redisinsight/api/src / /test/** backend (+ testing for *.spec.ts)
    tests/e2e-playwright/** e2e-testing
    other (desktop, configs) silent

    E2E specs get the e2e skill, not the unit-testing one. Reminders name the skill file so the agent loads full detail on demand.

Notes

  • .claude/settings.json is committed so the team gets the hook. It merges with each dev's gitignored settings.local.json.
  • Takes effect in new Claude Code sessions; first run prompts once to approve the hook command.
  • Hook is jq-only (no node startup), exits silently for unrelated paths. Self-tested across all branches.

🤖 Generated with Claude Code


Note

Low Risk
Documentation and Claude Code hook configuration only; no application runtime or production code paths change.

Overview
Aligns AI agent guidance with repo conventions and automatically surfaces the right styleguide when editing files, instead of relying on the model to load skills on its own.

Skill doc fixes: The testing and frontend skills now point at redisinsight/ui/src/mocks/factories/<domain>/<Name>.factory.ts (Fishery reuse) and show renderComponent examples that build entities from factories—not inline mock objects.

Enforcement: A new PreToolUse hook (.ai/hooks/styleguide-reminder.sh) runs on Edit/Write/MultiEdit, maps the target path to frontend, backend, testing, or e2e-testing reminders (E2E paths checked first), and injects additionalContext. .claude/settings.json is committed so the team gets the hook; unrelated paths exit silently.

Reviewed by Cursor Bugbot for commit 91637f5. Bugbot is set up for automated code reviews on this repo. Configure here.

valkirilov and others added 3 commits June 17, 2026 15:46
… skill

The testing skill modeled inline mock objects in its frontend examples and
never mentioned redisinsight/ui/src/mocks/factories/, where the repo's 21
Fishery factories actually live. Agents followed the skill correctly into the
wrong pattern. Point the skill at <domain>/<Name>.factory.ts and show reuse.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The frontend skill's renderComponent example spread inline faker props, which
contradicts the use-factories rule. Build default props from a shared factory
instead so the example matches the convention it should teach.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Skill triggering is model-discretionary, so agents editing fe/be/test/e2e
files often never load the relevant skill. Add a PreToolUse hook on
Edit/Write/MultiEdit that maps the changed path to its styleguide
(frontend / backend / testing / e2e-testing) and injects a reminder, so the
rules no longer depend on a skill self-triggering.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@valkirilov valkirilov requested a review from a team as a code owner June 17, 2026 12:50
@valkirilov valkirilov self-assigned this Jun 17, 2026
@jit-ci

jit-ci Bot commented Jun 17, 2026

Copy link
Copy Markdown

❌ Jit Scanner failed - Our team is investigating

Jit Scanner failed - Our team has been notified and is working to resolve the issue. Please contact support if you have any questions.


💡 Need to bypass this check? Comment @sera bypass to override.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants