201-book-effective-java

201-book-effective-java is a cursor rule for Cursor from jabrena/jbang-mcp-examples. It costs 1,147 tokens per session, scanned A, original, Apache-2.0.

Java development guidance based on the book Effective Java, covering object creation, methods, classes, interfaces, and related design choices.

In plain words
What is it for?
Use it while designing or reviewing Java classes, constructors, object lifecycles, equality methods, inheritance, interfaces, and resource handling.
Why use it?
It gives developers practical rules for avoiding common Java design and resource-management mistakes.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/jabrena/jbang-mcp-examples/201-book-effective-java
Clone the repo
git clone --depth 1 https://github.com/jabrena/jbang-mcp-examples

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for 201-book-effective-java

README.md
[![agentmods](https://agentmods.dev/badge/rules/jabrena/jbang-mcp-examples/201-book-effective-java.svg)](https://agentmods.dev/rules/jabrena/jbang-mcp-examples/201-book-effective-java)
Your own site
<a href="https://agentmods.dev/rules/jabrena/jbang-mcp-examples/201-book-effective-java"><img src="https://agentmods.dev/badge/rules/jabrena/jbang-mcp-examples/201-book-effective-java.svg" alt="Measured on agentmods" height="20"></a>
Per session 1,147 This file is loaded in full into every session.
When invoked 1,147 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.01147 $0.01147
Opus 5 $0.00574 $0.00574
Sonnet 5 $0.00229 $0.00229
Haiku 4.5 $0.00115 $0.00115

Measured 3d ago against content hash fedc208a6ed5, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

201-book-effective-java scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/201-book-effective-java.mdc · 141 lines

How it starts

The opening of the file, as written. The whole thing — 141 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Development Guidelines

effective_java_notes: chapter_2: title: "Creating and Destroying Objects" items: - "Consider static factory methods instead of constructors" - "Consider a builder when faced with many constructor parameters" - "Enforce the singleton property with a private constructor or an enum type" - "Enforce noninstantiability with a private constructor" - "Prefer dependency injection to hardwiring resources" - "Avoid creating unnecessary objects" - "Eliminate obsolete object references" - "Avoid finalizers and cleaners" - "Prefer try-with-resources to try-finally"

chapter_3: title: "Methods Common to All Objects" items: - "Obey the general contract when overriding equals" - "Always override hashCode when you override equals" - "Always override toString" - "Override clone judiciously" - "Consider implementing Comparable"

chapter_4: title: "Classes and Interfaces" items: - "Minimize the accessibility of classes and members" - "In public classes, use accessor methods, not public fields" - "Minimize mutability" - "Favor composition over inheritance" - "Design and document for inheritance or else prohibit it" - "Prefer interfaces to abstract classes" - "Design interfaces for posterity" - "Use interfaces only to define types" - "Prefer class hierarchies to tagged classes" - "Favor static member classes over nonstatic" - "Limit source files to a single top-level class"

chapter_5: title: "Generics" items: - "Don't use raw types" - "Eliminate unchecked warnings" - "Prefer lists to arrays" - "Favor generic types" - "Favor generic methods" - "Use bounded wildcards to increase API flexibility" - "Combine generics and varargs judiciously" - "Consider typesafe heterogeneous containers"

chapter_6: title: "Enums and Annotations" items: - "Use enums instead of int constants" - "Use instance fields instead of ordinals" - "Use EnumSet instead of bit fields" - "Use EnumMap instead of ordinal indexing" - "Emulate extensible enums with interfaces" - "Prefer annotations to naming patterns" - "Consistently use the Override annotation" - "Use marker interfaces to define types"

chapter_7: title: "Lambdas and Streams" items: - "Prefer lambdas to anonymous classes" - "Prefer method references to lambdas" - "Favor the use of standard functional interfaces" - "Use streams judiciously" - "Prefer side-effect-free functions in streams" - "Prefer Collection to Stream as a return type" - "Use caution when making streams parallel"

chapter_8: title: "Methods" items: - "Check parameters for validity" - "Make defensive copies when needed" - "Design method signatures carefully" - "Use overloading judiciously" - "Use varargs judiciously" - "Return empty collections or arrays, not nulls" - "Return optionals judiciously" - "Write doc comments for all exposed API elements"

chapter_9: title: "General Programming" items: - "Minimize the scope of local variables" - "Prefer for-each loops to traditional for loops" - "Know and use the libraries" - "Avoid float and double if exact answers are required" - "Prefer primitive types to boxed primitives" - "Avoid strings where other types are more appropriate" - "Beware the performance of string concatenation" - "Refer to objects by their interfaces" - "Prefer interfaces to reflection" - "Use native methods judiciously" - "Optimize judiciously" - "Adhere to generally accepted naming conventions"

chapter_10: title: "Exceptions" items: - "Use exceptions only for exceptional conditions" - "Use checked exceptions for recoverable conditions and runtime exceptions for programming errors" - "Avoid unnecessary use of checked exceptions" - "Favor the use of standard exceptions" - "Throw exceptions appropriate to the abstraction" - "Document all exceptions thrown by each method" - "Include failure-capture information in detail messages" - "Strive for failure atomicity" - "Don't ignore exceptions"

Read the full file on GitHub · 141 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 141 lines · 1,147 tokens per session scan A fedc208a6ed5

Subscribe to this mod's changes

201-book-effective-java is a cursor rule published in the GitHub repository jabrena/jbang-mcp-examples (1 stars, last pushed 1y ago), licensed Apache-2.0. It adds 1,147 tokens to every session, about $0.0057 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.