feat(SCOPONE-0010): vendor agent assets and clean docs
This commit is contained in:
36
.github/skills/simplify-code/APPENDIX.md
vendored
Normal file
36
.github/skills/simplify-code/APPENDIX.md
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
# Simplify Code Appendix
|
||||
|
||||
Extended examples and pattern notes live here to keep `SKILL.md` lean.
|
||||
|
||||
## Pattern Details
|
||||
|
||||
- Extract Method: split large functions into named units.
|
||||
- Guard Clauses: replace deep nesting with early returns.
|
||||
- Decompose Conditional: extract complex conditions and branches.
|
||||
- Replace Magic Numbers: promote literals to named constants.
|
||||
- Rename for Clarity: explicit, searchable, domain terms.
|
||||
- Remove Dead Code: delete commented or unreachable code.
|
||||
- Parameter Object: group related arguments when signatures are too long.
|
||||
|
||||
## Language-Specific Reminders
|
||||
|
||||
- JavaScript/TypeScript: prefer `const`, pure helpers, and array transforms.
|
||||
- Python: prefer clear names, type hints where useful, and small functions.
|
||||
- Java/C#: prefer focused classes and guard clauses.
|
||||
- Go: keep functions small, explicit error paths.
|
||||
|
||||
## Anti-Patterns
|
||||
|
||||
- Large-bang rewrites
|
||||
- Behavioral changes without explicit requirement
|
||||
- Premature abstractions
|
||||
- Clever code at cost of readability
|
||||
|
||||
## Suggested Validation Loop
|
||||
|
||||
1. Build/test baseline
|
||||
2. Apply one simplification pass
|
||||
3. Re-run build/tests
|
||||
4. Repeat
|
||||
|
||||
If a pass introduces failures, stop and document in `simplification-report.md`.
|
||||
103
.github/skills/simplify-code/SKILL.md
vendored
Normal file
103
.github/skills/simplify-code/SKILL.md
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
---
|
||||
name: simplify-code
|
||||
description: Systematic code simplification using proven refactoring patterns. Apply incrementally with tests at each step.
|
||||
---
|
||||
|
||||
# Simplify Code
|
||||
|
||||
Lean-mode simplification contract optimized for low token usage.
|
||||
Detailed pattern catalog and examples are in [APPENDIX.md](./APPENDIX.md).
|
||||
|
||||
## Execution Workflow
|
||||
|
||||
### 1. Setup
|
||||
- Detect build and test commands from project files.
|
||||
- If missing, ask user once and store commands.
|
||||
- Build candidate file list from git-visible files only:
|
||||
- prefer `git ls-files` for tracked + unignored files
|
||||
- include untracked-but-unignored files when relevant (`git ls-files --others --exclude-standard`)
|
||||
- NEVER simplify files ignored by `.gitignore` (or `.git/info/exclude` / global gitignore)
|
||||
- if workspace is not a git repo, ask user for include paths before modifying files
|
||||
|
||||
### 2. Baseline Validation
|
||||
- Run build; if failing, STOP.
|
||||
- Run tests; if failing, STOP.
|
||||
|
||||
### 3. Prepare Tooling
|
||||
- Detect and run formatter/linter appropriate for the language.
|
||||
- Keep edits style-compliant before simplification passes.
|
||||
|
||||
### 4. Simplification Passes
|
||||
- Prioritize largest or most complex files first (within the git-visible candidate list).
|
||||
- Apply one refactoring pattern at a time.
|
||||
- Keep behavior unchanged.
|
||||
|
||||
### 5. Verify
|
||||
- Re-run build and tests after each pass or grouped pass.
|
||||
- If failures appear, go to failure handling.
|
||||
|
||||
### 6. Failure Handling
|
||||
- Generate `simplification-report.md` with:
|
||||
- files touched
|
||||
- patterns applied
|
||||
- failures and diagnostics
|
||||
- rollback guidance
|
||||
|
||||
## Detection Triggers
|
||||
|
||||
Target code that shows one or more of:
|
||||
- long methods / large classes
|
||||
- nested or complex conditionals
|
||||
- duplicate logic
|
||||
- magic numbers
|
||||
- ambiguous naming
|
||||
- long parameter lists
|
||||
- dead code / commented code
|
||||
- impure stateful helpers
|
||||
|
||||
## Core Patterns
|
||||
|
||||
Apply these patterns first:
|
||||
1. Extract Method
|
||||
2. Guard Clauses
|
||||
3. Decompose Conditional
|
||||
4. Replace Magic Number with Constant
|
||||
5. Rename for clarity
|
||||
6. Remove dead/commented code
|
||||
7. Introduce parameter object when argument lists are large
|
||||
|
||||
Prefer pure functions and immutability where idiomatic for the language.
|
||||
|
||||
## Constraints
|
||||
|
||||
- Avoid large-bang refactors.
|
||||
- Keep each change small and reversible.
|
||||
- Do not change public behavior unless explicitly requested.
|
||||
- Do not introduce speculative abstractions.
|
||||
- Do not read, modify, or propose edits for files ignored by git ignore rules.
|
||||
|
||||
## Metrics (Targets)
|
||||
|
||||
- Cyclomatic complexity `< 10`
|
||||
- Method length `< 30` lines
|
||||
- Nesting depth `< 4`
|
||||
- Parameter count `< 4`
|
||||
- Class length `< 300` lines
|
||||
|
||||
## Language Notes
|
||||
|
||||
- Use ecosystem formatters/linters (Prettier/ESLint, Black/isort, gofmt, etc.).
|
||||
- Follow project-native naming conventions.
|
||||
- Prefer readability over cleverness.
|
||||
|
||||
## Quick Mapping
|
||||
|
||||
- Long method → Extract Method
|
||||
- Nested conditionals → Guard Clauses + Decompose Conditional
|
||||
- Duplicate code → Extract shared helper
|
||||
- Magic numbers → Named constants
|
||||
- Dead code → Remove
|
||||
|
||||
## Reference
|
||||
|
||||
For expanded examples and anti-pattern details, see [APPENDIX.md](./APPENDIX.md).
|
||||
Reference in New Issue
Block a user