Guide · Agent skill
How to use the const-let agent skill: prefer const and let over var
Updated · written with AI from the project's own documentation and checked against our catalogue data
The const-let skill is a checklist-style guide for an AI agent that handles one JavaScript best practice: replacing the old var keyword with const for values that never change, or let for values that do. It is useful for developers cleaning up older JavaScript, students learning how var, let and const differ, and code reviewers who want a consistent check for this rule. After this guide you will know what the skill does, how to install it, how to trigger it with plain requests, and where its limits are.
Quick start
- 1Download the ZIP. Download the const-let skill ZIP file from this page.
- 2Unzip into a skills folder. Unzip it into ~/.claude/skills/ for personal use, or into a project's .claude/skills/ folder for one project.
- 3Or upload in the Claude apps. Alternatively, open Settings → Capabilities → Skills in the Claude apps and upload the skill.
- 4Make a natural request. Ask the agent in plain words, for example to check a file for var and give line numbers.
- 5Review the rewrite. Read each const or let change and check that the variable is reassigned only where let is used.
- 6Verify in a browser. Run the code in a browser to confirm the behavior still matches what you expect.
What does the const-let skill make the agent do?
When the skill is active, the agent follows a checklist for the rule Prefer const and let over var. When you ask it to check a file, it scans for every use of var and flags each one with its line number. It then rewrites each declaration: const when the variable is never reassigned, let otherwise.
The agent also explains why the change matters, covering function scope, hoisting and the temporal dead zone. For example, a var inside a for loop leaks out of the loop, so setTimeout callbacks may all log 3 instead of 0, 1, 2. With let, each iteration gets its own binding and they log 0, 1, 2.
For front-end work, the skill can also review scripts, client components, bundles and browser-side behavior related to this rule. It flags imports, event handlers, runtime side effects or blocking operations that break the rule, and suggests how to verify the change in a browser.
How do you install the const-let skill?
You can install the skill in either of two ways. Download the ZIP file from this page and unzip it into one of these locations: ~/.claude/skills/ for your personal skills, or .claude/skills/ inside a project if you want the skill only for that project.
Alternatively, upload the skill in the Claude apps under Settings → Capabilities → Skills.
- Personal: unzip into ~/.claude/skills/
- Project only: unzip into the project's .claude/skills/ folder
- Claude apps: Settings → Capabilities → Skills, then upload
Which files are included?
The skill contains two files. SKILL.md holds the main instructions: the quick reference, and the check, fix, explain and code review steps. references/rule.md holds fuller background, including code examples and the reasoning behind the rule. The agent can read the reference file when it needs more detail.
- SKILL.md: main instructions and quick reference
- references/rule.md: full examples and rationale
How do you trigger the skill with natural requests?
You do not need a special command. Describe the task in plain words that mention the rule or the kind of code involved. The skill's description covers reviewing scripts, client components, bundles and runtime behavior related to preferring const and let over var, so requests in those terms are most likely to activate it.
- Check this file for var and tell me the line numbers.
- Replace the var declarations in utils.js with const or let and explain each choice.
- Review this client component for var usage and anything that breaks this rule.
- Explain the difference between var, let and const using this code as an example.
What do the examples look like?
The reference file shows two common bugs. In the first, a for loop using var with setTimeout logs 3, 3, 3; switching to let logs 0, 1, 2. In the second, reading a var before its declaration returns undefined, while reading a let or const before its declaration throws a ReferenceError because of the temporal dead zone.
for (var i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 100)
}
// Logs: 3, 3, 3
for (let i = 0; i < 3; i++) {
setTimeout(() => console.log(i), 100)
}
// Logs: 0, 1, 2What does the skill need, and is it safe to run?
The skill requires nothing beyond the agent itself. It does not run scripts and does not use the network, so it works by reading and editing code. Because it reviews by reading rather than running tooling, it may miss occurrences in large codebases. For a full automated check, use a linter instead.
Remember that const does not make data immutable. Objects and arrays declared with const can still be changed, so the skill's rewrite does not protect against mutation.
- Requirements: none listed
- Runs scripts: no
- Uses network: no
What tips help you get better results?
Give the agent a specific file or component rather than a whole project, so it can flag every var with line numbers. For browser-side review, state what you expect the code to do so the advice targets a real problem. Check the agent's changes by running the code, since the skill is designed to suggest browser verification steps.
Expect generic advice on broad browser questions. The skill is strongest on the var-to-let/const rule itself, and weaker on performance bottlenecks or bugs in code that does not use var.
- Point the agent at one file or component at a time
- Use const by default, then let only where reassignment happens
- Run the code in a browser after changes to confirm behavior
What people use it for
- Cleaning up an older JavaScript file that still uses var, with line numbers for each occurrence.
- Learning the difference between var, let and const through worked examples of loops and hoisting.
- Reviewing a client component or script for var usage and related runtime issues.
- Applying one consistent checklist for this rule across a code review.
Frequently asked questions
Is the const-let skill free to use?
The skill is published under the MIT licence, as listed on this page. The source does not mention pricing, so check the repository for the licence terms that apply to you.
What does the const-let skill require?
The source lists no requirements. It does not run scripts and does not use the network, so it works by reading and editing your code.
How do I install the const-let skill?
Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use or a project's .claude/skills/ folder. You can also upload it in the Claude apps under Settings → Capabilities → Skills.
Why does the skill recommend const over let?
The skill uses const for values that are never reassigned, since const signals that a binding should not change and helps readers follow data flow. It uses let only when reassignment is needed.
Does const make objects immutable?
No. Objects and arrays declared with const can still be mutated. The skill's guidance covers the binding, not the contents.
Can the skill replace a linter?
Not for large projects. The skill reviews by reading code rather than running tooling, so it may miss occurrences in large codebases. A full automated linter run is the better choice for that.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Use the const-let skill if you maintain older JavaScript that still uses var, are learning the differences between var, let and const, or want a consistent review checklist for this rule. Pick a linter or another tool if you need a complete automated scan of a large codebase, or help with performance problems unrelated to var.
Download the skill