agentleFS
mykytasomykytaso/claude-skills/skills/comments-rewrite/SKILL.md

comments-rewrite

Skill0 starsChanged 2 months agoMITView on GitHub

Deletes the comments from code and writes new ones. Use when the user asks to rewrite, replace, refresh, or clean up and re-document comments.

The file

Show its rules and text

We split this skill into the rules it gives an agent

34 rules. About 0 are common, 32 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈32

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the input is a path to a file or a directory that exists, use the file or the directory.

    line 17
  2. Distinctive:

    If the input looks like a path, and the path does not exist, stop.

    line 18
  3. Distinctive:

    If the input is code, or the message has a code block, find that code in the project:

    line 19
  4. Distinctive:

    Use Grep with a line from the code that is unusual, for example a name or a string literal.

    line 20
  5. Distinctive:

    If you find one location, use that file.

    line 21
  6. Distinctive:

    If you find more than one location, show the list of the files with the line numbers, and ask which one to use.

    line 22
  7. Distinctive:

    If you find no location, tell the user, and show the code with the new comments in the chat.

    line 23
  8. Distinctive:

    If there is no input, and the message has no code block, stop immediately.

    line 24
  9. Distinctive:

    Do this step only for a directory target.

    line 30
  10. Distinctive:

    Do not use a hidden file or a hidden folder.

    line 33
  11. Very specific:

    Do not use a build folder or a dependency folder, for example build, dist, .build, DerivedData, node_modules, Pods, vendor, .venv.

    line 34
  12. Distinctive:

    Do not use a file that a tool made.

    line 35
  13. Distinctive:

    Do not use a file that is not source code, for example an image or a data file.

    line 36
  14. Distinctive:

    If the list has more than 10 files, show the list, and ask before you make a change.

    line 37
  15. Distinctive:

    Delete the comments, then write new comments.

    line 41
  16. Distinctive:

    Delete line comments and block comments.

    line 45
  17. Distinctive:

    Keep every comment that the compiler, a tool, or the operating system reads.

    line 46
  18. Distinctive:

    If you are not sure that a comment is only for a person, keep it.

    line 53
  19. Very specific:

    Keep a documentation comment that a tool reads, for example a Swift /// comment or a Python docstring.

    line 54
  20. Distinctive:

    Do not change comment text that is in a string literal or a regular expression.

    line 55
  21. Distinctive:

    If the comment was alone on its line, delete the full line.

    line 56
  22. Distinctive:

    Do not write a comment that you kept a second time.

    line 57
  23. Distinctive:

    If the code uses an element from a different file, and you cannot understand the code without it, find that element first.

    line 61
  24. Distinctive:

    Use Grep and Glob to find where each one is defined.

    line 64
  25. Distinctive:

    Read the definition only. Do not change the other file.

    line 65
  26. Distinctive:

    If you cannot find the definition, do not guess what it does.

    line 66
  27. Distinctive:

    Write all comments in ASD-STE100 Simplified Technical English.

    line 70
  28. Distinctive:

    Do not add a comment to code that is already clear.

    line 72
  29. Distinctive:

    Put the comment on the line above the code.

    line 73
  30. Distinctive:

    Use one-line comments. Use more lines only when this makes the text easier to read.

    line 74
  31. Distinctive:

    Do not divide one sentence into more than one line.

    line 75
  32. Distinctive:

    Do not change, refactor, or reformat the executable code.

    line 81
  33. Distinctive:

    Do not change a file that is not in the target.

    line 83
  34. Distinctive:

    After the work, give this data:

    line 92

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Input: $ARGUMENTS

Precondition

Find the target

Find the type of the input:

  1. If the input is a path to a file or a directory that exists, use the file or the directory.
  2. If the input looks like a path, and the path does not exist, stop. Show the path. Do not guess. Do not search for the path text.
  3. If the input is code, or the message has a code block, find that code in the project:
    • Use Grep with a line from the code that is unusual, for example a name or a string literal.
    • If you find one location, use that file.
    • If you find more than one location, show the list of the files with the line numbers, and ask which one to use. Do not make a change.
    • If you find no location, tell the user, and show the code with the new comments in the chat. Do not write a file.
  4. If there is no input, and the message has no code block, stop immediately. Do not guess. Write only this message:

Usage: /comments-rewrite <file-or-directory | code block>

Find the files

Do this step only for a directory target.

  1. Make the list of the source files in the directory.
  2. Do not use a hidden file or a hidden folder.
  3. Do not use a build folder or a dependency folder, for example build, dist, .build, DerivedData, node_modules, Pods, vendor, .venv.
  4. Do not use a file that a tool made. A generated file usually has a header, for example "Do not edit".
  5. Do not use a file that is not source code, for example an image or a data file.
  6. If the list has more than 10 files, show the list, and ask before you make a change.

Task

Delete the comments, then write new comments. Do the three steps in this order.

Step 1 — Delete the comments

  1. Delete line comments and block comments.
  2. Keep every comment that the compiler, a tool, or the operating system reads. Delete only a comment that is for a person. Keep these comments:
    • The first line of the file, if it starts with #!.
    • License headers and copyright headers.
    • A comment that gives a version or a build rule, for example // swift-tools-version:6.0, //go:build linux, # -*- coding: utf-8 -*-, # frozen_string_literal: true.
    • A directive for a tool or the compiler, for example // swiftlint:disable, // swiftformat:disable, # type: ignore, # noqa, // @ts-ignore, // eslint-disable, // prettier-ignore, #pragma.
    • TODO, MARK, and FIXME comments.
    • A comment that gives data that the code does not show, for example a reason, a defect number, a link, or a description of a workaround. You cannot write this comment again from the code.
  3. If you are not sure that a comment is only for a person, keep it. Put it in the report.
  4. Keep a documentation comment that a tool reads, for example a Swift /// comment or a Python docstring. A docstring is a string, not a comment. Do not delete it.
  5. Do not change comment text that is in a string literal or a regular expression.
  6. If the comment was alone on its line, delete the full line. Do not leave an empty line in its place.
  7. Do not write a comment that you kept a second time.

Step 2 — Read the code that you cannot see

If the code uses an element from a different file, and you cannot understand the code without it, find that element first.

  1. Make a list of the types, the functions, the properties, and the constants that the code uses but does not define.
  2. Use Grep and Glob to find where each one is defined. Read that file.
  3. Read the definition only. Do not change the other file.
  4. If you cannot find the definition, do not guess what it does. Write a comment about the code that you can see, and put the element in the report.

Step 3 — Write the comments

  1. Write all comments in ASD-STE100 Simplified Technical English.
  2. Give the reason for the code. Do not say again what the code shows.
  3. Do not add a comment to code that is already clear.
  4. Put the comment on the line above the code. Do not put a comment at the end of a line of code.
  5. Use one-line comments. Use more lines only when this makes the text easier to read.
  6. Do not divide one sentence into more than one line.
  7. For the Swift language, use //. Do not use /* */.
  8. For a different language, use the comment style that the file uses already.

Limits

  1. Do not change, refactor, or reformat the executable code.
  2. Change only the comments, and the lines that stay empty because you deleted a comment.
  3. Do not change a file that is not in the target.

Output

For a file or a directory, change the comments in the files. For a block of code that you found in the project, change the comments in that file. Change only the lines of that block.

Report

After the work, give this data:

  1. A list of the files or the sections, with the number of the deleted comments and the number of the new comments.
  2. A list of the comments that you deleted and did not write again.
  3. A list of the comments that you kept, with the reason.
  4. A list of the logic that stays unclear.
  5. A short list of the code that can be unsafe, for example a forced unwrap, an unfinished error operation, or a race condition. Tell the user that /security-review does a full examination.
  6. A list of the external elements that you read, with their files, and a list of the elements that you did not find.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.