[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7F46WFBQ1W77F0FP56CA1DY":3,"skill-same:01M7F46WFBQ1W77F0FP56CA1DY":77},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":37,"commitSha":38,"skillDirectory":39,"forksCount":40,"repositoryHtmlUrl":41,"repositoryHomepageUrl":6,"ownerHtmlUrl":42,"ownerBlogUrl":6,"ownerDescription":43,"updatedAt":44,"install":45,"resources":58},"01M7F46WFBQ1W77F0FP56CA1DY","ruby",null,"Use when writing or refactoring plain Ruby outside Rails — scripts, CLIs, gems, libraries: Enumerable chains and blocks, module mixins and value objects, Bundler\u002Fgemspec packaging, whether metaprogramming earns its keep, Minitest or RSpec, Ruby 3.4\u002F4.0 frozen-string hygiene. NOT Rails, ActiveRecord, or ActiveSupport idioms (that is `rails`).","lza6\u002FArmor-piercing-system-prompts","lza6","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F128880206?v=4","01M7EB3K7WPX5T28EJ2NVHE6EG","Chinese-tingfeng","01M7EB3K97E1KQ16QWKJMFNGX8",11,"MIT","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F05-技能与代理开发\u002Fruby\u002FSKILL.md",[],[],"2026-11-16 10:05:34",false,"---\nname: ruby\ndescription: \"Use when writing or refactoring plain Ruby outside Rails — scripts, CLIs, gems, libraries: Enumerable chains and blocks, module mixins and value objects, Bundler\u002Fgemspec packaging, whether metaprogramming earns its keep, Minitest or RSpec, Ruby 3.4\u002F4.0 frozen-string hygiene. NOT Rails, ActiveRecord, or ActiveSupport idioms (that is `rails`).\"\ntags: [ruby, gems, bundler, metaprogramming, rspec, minitest, enumerable]\nrecommends: [rails, testing-web, secure-coding]\nprofiles: []\norigin: risco\n---\n\n# Idiomatic Ruby, the language\n\nWrite Ruby a senior Rubyist would sign off on: expression-oriented, block-driven,\nleaning on `Enumerable` and `Comparable` instead of hand-rolled loops, with\n`frozen_string_literal` hygiene and a real `Gemfile`\u002F`.gemspec` when you package.\n\nThis is **Ruby the language and its non-Rails ecosystem** — blocks, modules, gems,\nmetaprogramming, Minitest\u002FRSpec. Delegate: Rails apps, ActiveRecord models, controllers,\nmigrations, views, Hotwire — anything that loads Rails or uses ActiveSupport\u002FActiveRecord\nidioms — to [`rails`](..\u002Frails\u002FSKILL.md); the same task in another language to\n[`python`](..\u002Fpython\u002FSKILL.md), [`go`](..\u002Fgo\u002FSKILL.md), [`rust`](..\u002Frust\u002FSKILL.md),\n[`elixir`](..\u002Felixir\u002FSKILL.md), [`php`](..\u002Fphp\u002FSKILL.md) or\n[`typescript`](..\u002Ftypescript\u002FSKILL.md); the CI pipeline that runs your Ruby tests to\n[`github-actions`](..\u002Fgithub-actions\u002FSKILL.md) — this skill writes the tests, not the workflow.\n\nTargets **Ruby 4.0** (released 2025-12-25) on **3.4** semantics: Prism is the default\nparser, string literals warn on mutation without a magic comment, `it` is an implicit\nblock param, and `Set` is now a core class.\n\n## Mental model\n\nInternalize these before writing a line:\n\n1. **Everything is an expression and returns a value.** `if`, `case`, blocks, method\n   bodies all yield a value — name and return it instead of threading a flag.\n2. **Everything is an object receiving messages.** `5.times`, `nil.to_a`, `\"x\".freeze`.\n   There are no primitives to special-case.\n3. **Reach for `Enumerable` before you write a loop.** A manual index loop in Ruby is\n   almost always a `map`\u002F`select`\u002F`reduce` you have not spotted yet.\n4. **Prefer returning new values to mutating in place.** Mutation is allowed but it is\n   the exception you justify, not the default.\n5. **Freeze your string literals.** New files start with `# frozen_string_literal: true`.\n6. **Dynamism is the trap, not the feature.** Metaprogramming is a scalpel; if a plain\n   method, a `Struct`, or a `Data` does the job, use that.\n\n## Blocks, procs, lambdas, yield\n\nBlocks are the spine of Ruby. A method takes a block implicitly via `yield`, or\nexplicitly with `&block` when it must store or forward it.\n\n```ruby\n# frozen_string_literal: true\n\n# Implicit: yield runs the caller's block and returns its value.\ndef with_timing\n  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n  result = yield\n  [result, Process.clock_gettime(Process::CLOCK_MONOTONIC) - start]\nend\n\n# Explicit: capture the block as a Proc to forward or store it.\ndef retrying(times, &block)\n  attempts = 0\n  begin\n    block.call\n  rescue StandardError\n    (attempts += 1) \u003C times ? retry : raise\n  end\nend\n```\n\n`proc` vs `lambda` differ in two ways that bite:\n\n| Aspect | `proc` \u002F block | `lambda` \u002F `->` |\n|--------|----------------|-----------------|\n| Arity  | Lenient — extra args dropped, missing become `nil` | Strict — wrong count raises `ArgumentError` |\n| `return` | Returns from the enclosing method (can surprise) | Returns from the lambda only |\n\nRule: use a **lambda** for a function-like value you call yourself; use a **block\u002Fproc**\nfor the \"do this with each element\" pattern. For cheap accumulation prefer\n`each_with_object` (returns the seed) or `reduce`; use `tap` (returns the receiver) for\nside effects and `then` for piping a value through a transform.\n\n```ruby\n# Bad: index loop building a result by mutation.\nresult = []\n(0...items.length).each { |i| result \u003C\u003C items[i].upcase if items[i].size > 3 }\n\n# Good: intent reads top-to-bottom, no index, no pre-seeded array.\nresult = items.select { |s| s.size > 3 }.map(&:upcase)\n```\n\n## Enumerable & Comparable\n\nMost loops map to one named method. Pick by **intent**, not by habit:\n\n| You want to…                          | Use                          |\n|---------------------------------------|------------------------------|\n| Transform every element               | `map`                        |\n| Keep \u002F drop by predicate              | `select` \u002F `reject`          |\n| Fold into one value                   | `reduce` \u002F `sum` \u002F `min_by`  |\n| Build a Hash or accumulate into a seed| `each_with_object`           |\n| Count occurrences                     | `tally`                      |\n| Bucket by a key                       | `group_by`                   |\n| First match                           | `find` (`detect`)            |\n| Pair index with element               | `each_with_index`            |\n\nMake your own classes first-class collections by including `Enumerable` and defining\n`each`; get `\u003C`, `>`, `between?`, `clamp`, `sort` for free by including `Comparable` and\ndefining `\u003C=>`.\n\n```ruby\n# frozen_string_literal: true\n\nclass Playlist\n  include Enumerable\n\n  def initialize(tracks) = @tracks = tracks\n  def each(&) = @tracks.each(&)   # one method unlocks map\u002Fselect\u002Fsort\u002F...\nend\n\nclass Version\n  include Comparable\n  attr_reader :major, :minor\n\n  def initialize(major, minor)\n    @major = major\n    @minor = minor\n  end\n\n  def \u003C=>(other) = [major, minor] \u003C=> [other.major, other.minor]\nend\n```\n\n## Modules & composition\n\nRuby favors composition through mixins over deep inheritance.\n\n- `include M` — adds `M`'s instance methods to instances (the default mixin).\n- `prepend M` — inserts `M` *before* the class in the lookup chain, so `M`'s methods can\n  wrap the originals via `super` (cleaner than aliasing for decoration).\n- `extend M` — adds `M`'s methods as *class\u002Fsingleton* methods.\n\nRule: reach for a **module mixin** when the same behavior is shared across unrelated\nclasses; reserve inheritance for a genuine is-a hierarchy. Namespace with `module Foo`\nto avoid global constant clashes. Need to patch a class without polluting it globally?\nUse a **refinement** (`refine … using`) — a scoped, reversible scalpel — never a bare\nmonkey-patch. Full refinement scoping and `prepend`-wrapping in\n[references\u002Fmetaprogramming.md](references\u002Fmetaprogramming.md).\n\n## Value objects: Data vs Struct\n\n```ruby\n# frozen_string_literal: true\n\nPoint  = Data.define(:x, :y)         # immutable value object (Ruby 3.2+)\norigin = Point.new(x: 0, y: 0)       # no setters; with(x: 1) returns a copy\n\nCursor = Struct.new(:x, :y)          # mutable; has setters and is Enumerable\n```\n\n| Need                                       | Reach for     |\n|--------------------------------------------|---------------|\n| Immutable value with equality + `with`     | `Data.define` |\n| Mutable record, or array\u002Fpositional access | `Struct.new`  |\n\nDefault to `Data` for value semantics; pick `Struct` only when you genuinely need\nmutation or positional\u002F`to_a` behavior.\n\n## Metaprogramming, sparingly\n\nDecision rule, in order: **could a plain method, a `Struct`, or a `Data` do this?**\nIf yes, do that. Only when the method *names themselves* are dynamic (driven by data or\nconfig) does metaprogramming earn its keep.\n\n- Prefer `define_method` (defines real, introspectable methods) over `method_missing`\n  (intercepts at call time, slower, invisible to `respond_to?` and tooling).\n- If you *must* use `method_missing`, you **must** also define `respond_to_missing?` —\n  otherwise `respond_to?`, `method`, and duck-typing all lie about your object.\n- Never `eval` a string built from user input.\n\n```ruby\n# Good: dynamic method names, but real methods that introspect and document themselves.\nclass Config\n  def initialize(**data) = @data = data\n\n  %i[host port timeout].each do |key|\n    define_method(key)       { @data[key] }\n    define_method(\"#{key}=\") { |value| @data[key] = value }\n  end\nend\n```\n\nBuilding a real DSL, `instance_eval`\u002F`class_eval`, and the full\n`method_missing` + `respond_to_missing?` pairing live in\n[references\u002Fmetaprogramming.md](references\u002Fmetaprogramming.md).\n\n## Gems & Bundler\n\nBundler is the universal dependency manager. `bundle init` creates a `Gemfile`;\n`bundle install` resolves and writes `Gemfile.lock`; run project binaries with\n`bundle exec` so they use the locked versions.\n\n- Use the **pessimistic constraint** `~> 2.3` (allows `2.x >= 2.3`, blocks `3.0`) for\n  libraries; pin tighter only when forced.\n- **Commit `Gemfile.lock` for applications** (reproducible installs); for a *library*\n  gem, do not commit the lock — let consumers resolve.\n- Scaffold a gem with `bundle gem NAME`, which generates the `lib\u002F`, `test\u002F`\u002F`spec\u002F`,\n  `.gemspec`, and Rakefile layout.\n\n```ruby\n# my_gem.gemspec\nGem::Specification.new do |spec|\n  spec.name        = \"my_gem\"\n  spec.version     = MyGem::VERSION       # SemVer: MAJOR.MINOR.PATCH\n  spec.summary     = \"One-line description.\"\n  spec.authors     = [\"You\"]\n  spec.files       = Dir[\"lib\u002F**\u002F*.rb\"]\n  spec.required_ruby_version = \">= 3.4\"\n  spec.add_dependency \"thor\", \"~> 1.3\"\nend\n```\n\nFull `bundle gem` tree, publishing flow (`gem build` \u002F `gem push`), and Rake test tasks\nare in [references\u002Fgems-and-testing.md](references\u002Fgems-and-testing.md).\n\n## Ruby 4.0 \u002F 3.4 hygiene\n\n```ruby\n# frozen_string_literal: true     # without it, 3.4+ warns under -W:deprecated on mutation\n\nnums.map { it * 2 }               # `it` is the implicit single block param (3.4+)\nseen = Set.new([1, 2, 3])         # Set is a core class in 4.0 — no `require \"set\"`\n```\n\n- The magic comment freezes every string literal in the file; mutating one then raises\n  `FrozenError`. This is the cause of most \"my string froze after upgrading\" reports.\n- `it` reads cleaner than `_1` for one-arg blocks.\n- Ruby 4.0 ships **ZJIT** (a new JIT written in Rust, successor to YJIT) and removed\n  `Ractor.yield`\u002F`Ractor#take` in favor of `Ractor::Port`.\n\n## Testing\n\nBoth ship a clean path; choose by ceremony tolerance:\n\n| Framework | Pick when… |\n|-----------|-----------|\n| **Minitest** | You want the default — ships with Ruby, tiny surface, `assert`-style or spec-style, fast. |\n| **RSpec** | You want the expressive DSL and large ecosystem (`describe`\u002F`context`\u002F`it`\u002F`expect`, `let`, mocks). |\n\n```ruby\n# test\u002Ftally_test.rb  (Minitest)\nrequire \"minitest\u002Fautorun\"\nrequire \"tally\"\n\nclass TallyTest \u003C Minitest::Test\n  def test_counts_words\n    assert_equal({ \"a\" => 2, \"b\" => 1 }, Tally.count(\"a b a\"))\n  end\nend\n```\n\n```ruby\n# spec\u002Ftally_spec.rb  (RSpec)\nRSpec.describe Tally do\n  subject(:counts) { described_class.count(\"a b a\") }\n  it { is_expected.to eq(\"a\" => 2, \"b\" => 1) }\nend\n```\n\nRun via `bundle exec rake test` (Minitest) or `bundle exec rspec` (RSpec). Fuller\nexamples with `let`\u002F`subject`\u002F`context` are in\n[references\u002Fgems-and-testing.md](references\u002Fgems-and-testing.md).\n\n## Linting & typing (optional layers)\n\n- **Linter:** Standard (zero-config, \"no bikeshadding\" wrapper) when you want one less\n  argument; RuboCop (`.rubocop.yml`, every cop opt-in\u002Fout) when the team wants control.\n- **Types:** two coexisting systems — **RBS** (official signatures in separate `.rbs`\n  files, checked by Steep) and **Sorbet** (inline `sig` blocks, with experimental\n  inline-RBS-comment support). Add types only on a library's public surface or a hot,\n  bug-prone core — not on throwaway scripts. RuboCop vs Standard config sits in\n  [references\u002Fgems-and-testing.md](references\u002Fgems-and-testing.md).\n\n## Anti-patterns\n\n| Anti-pattern | Why it bites | Do instead |\n|--------------|--------------|------------|\n| Monkey-patching a core class globally | Action-at-a-distance; collides with gems and future Ruby | A refinement (scoped) or a wrapper\u002Fhelper |\n| `method_missing` without `respond_to_missing?` | `respond_to?`\u002F`method`\u002Fduck-typing all lie | Pair them, or prefer `define_method` |\n| Mutating a frozen string literal | `FrozenError` after the magic comment | `dup` before mutating, or build a new string |\n| `for x in coll` loops | Leaks the loop var; un-idiomatic | `coll.each`\u002F`map`\u002F`select` |\n| `rescue Exception` (bare) | Swallows `SignalException`, `NoMemoryError`, exit | `rescue StandardError` (or specific classes) |\n| Not committing `Gemfile.lock` for an app | Non-reproducible installs across machines | Commit it for apps; omit only for library gems |\n| `eval` of user-derived input | Remote code execution | Parse explicitly; never `eval` untrusted data |\n| Over-DSLing config a Hash would serve | Hidden control flow, slow `method_missing` | A plain Hash or `Data` object |\n","# Idiomatic Ruby, the language\n\nWrite Ruby a senior Rubyist would sign off on: expression-oriented, block-driven,\nleaning on `Enumerable` and `Comparable` instead of hand-rolled loops, with\n`frozen_string_literal` hygiene and a real `Gemfile`\u002F`.gemspec` when you package.\n\nThis is **Ruby the language and its non-Rails ecosystem** — blocks, modules, gems,\nmetaprogramming, Minitest\u002FRSpec. Delegate: Rails apps, ActiveRecord models, controllers,\nmigrations, views, Hotwire — anything that loads Rails or uses ActiveSupport\u002FActiveRecord\nidioms — to [`rails`](..\u002Frails\u002FSKILL.md); the same task in another language to\n[`python`](..\u002Fpython\u002FSKILL.md), [`go`](..\u002Fgo\u002FSKILL.md), [`rust`](..\u002Frust\u002FSKILL.md),\n[`elixir`](..\u002Felixir\u002FSKILL.md), [`php`](..\u002Fphp\u002FSKILL.md) or\n[`typescript`](..\u002Ftypescript\u002FSKILL.md); the CI pipeline that runs your Ruby tests to\n[`github-actions`](..\u002Fgithub-actions\u002FSKILL.md) — this skill writes the tests, not the workflow.\n\nTargets **Ruby 4.0** (released 2025-12-25) on **3.4** semantics: Prism is the default\nparser, string literals warn on mutation without a magic comment, `it` is an implicit\nblock param, and `Set` is now a core class.\n\n## Mental model\n\nInternalize these before writing a line:\n\n1. **Everything is an expression and returns a value.** `if`, `case`, blocks, method\n   bodies all yield a value — name and return it instead of threading a flag.\n2. **Everything is an object receiving messages.** `5.times`, `nil.to_a`, `\"x\".freeze`.\n   There are no primitives to special-case.\n3. **Reach for `Enumerable` before you write a loop.** A manual index loop in Ruby is\n   almost always a `map`\u002F`select`\u002F`reduce` you have not spotted yet.\n4. **Prefer returning new values to mutating in place.** Mutation is allowed but it is\n   the exception you justify, not the default.\n5. **Freeze your string literals.** New files start with `# frozen_string_literal: true`.\n6. **Dynamism is the trap, not the feature.** Metaprogramming is a scalpel; if a plain\n   method, a `Struct`, or a `Data` does the job, use that.\n\n## Blocks, procs, lambdas, yield\n\nBlocks are the spine of Ruby. A method takes a block implicitly via `yield`, or\nexplicitly with `&block` when it must store or forward it.\n\n```ruby\n# frozen_string_literal: true\n\n# Implicit: yield runs the caller's block and returns its value.\ndef with_timing\n  start = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n  result = yield\n  [result, Process.clock_gettime(Process::CLOCK_MONOTONIC) - start]\nend\n\n# Explicit: capture the block as a Proc to forward or store it.\ndef retrying(times, &block)\n  attempts = 0\n  begin\n    block.call\n  rescue StandardError\n    (attempts += 1) \u003C times ? retry : raise\n  end\nend\n```\n\n`proc` vs `lambda` differ in two ways that bite:\n\n| Aspect | `proc` \u002F block | `lambda` \u002F `->` |\n|--------|----------------|-----------------|\n| Arity  | Lenient — extra args dropped, missing become `nil` | Strict — wrong count raises `ArgumentError` |\n| `return` | Returns from the enclosing method (can surprise) | Returns from the lambda only |\n\nRule: use a **lambda** for a function-like value you call yourself; use a **block\u002Fproc**\nfor the \"do this with each element\" pattern. For cheap accumulation prefer\n`each_with_object` (returns the seed) or `reduce`; use `tap` (returns the receiver) for\nside effects and `then` for piping a value through a transform.\n\n```ruby\n# Bad: index loop building a result by mutation.\nresult = []\n(0...items.length).each { |i| result \u003C\u003C items[i].upcase if items[i].size > 3 }\n\n# Good: intent reads top-to-bottom, no index, no pre-seeded array.\nresult = items.select { |s| s.size > 3 }.map(&:upcase)\n```\n\n## Enumerable & Comparable\n\nMost loops map to one named method. Pick by **intent**, not by habit:\n\n| You want to…                          | Use                          |\n|---------------------------------------|------------------------------|\n| Transform every element               | `map`                        |\n| Keep \u002F drop by predicate              | `select` \u002F `reject`          |\n| Fold into one value                   | `reduce` \u002F `sum` \u002F `min_by`  |\n| Build a Hash or accumulate into a seed| `each_with_object`           |\n| Count occurrences                     | `tally`                      |\n| Bucket by a key                       | `group_by`                   |\n| First match                           | `find` (`detect`)            |\n| Pair index with element               | `each_with_index`            |\n\nMake your own classes first-class collections by including `Enumerable` and defining\n`each`; get `\u003C`, `>`, `between?`, `clamp`, `sort` for free by including `Comparable` and\ndefining `\u003C=>`.\n\n```ruby\n# frozen_string_literal: true\n\nclass Playlist\n  include Enumerable\n\n  def initialize(tracks) = @tracks = tracks\n  def each(&) = @tracks.each(&)   # one method unlocks map\u002Fselect\u002Fsort\u002F...\nend\n\nclass Version\n  include Comparable\n  attr_reader :major, :minor\n\n  def initialize(major, minor)\n    @major = major\n    @minor = minor\n  end\n\n  def \u003C=>(other) = [major, minor] \u003C=> [other.major, other.minor]\nend\n```\n\n## Modules & composition\n\nRuby favors composition through mixins over deep inheritance.\n\n- `include M` — adds `M`'s instance methods to instances (the default mixin).\n- `prepend M` — inserts `M` *before* the class in the lookup chain, so `M`'s methods can\n  wrap the originals via `super` (cleaner than aliasing for decoration).\n- `extend M` — adds `M`'s methods as *class\u002Fsingleton* methods.\n\nRule: reach for a **module mixin** when the same behavior is shared across unrelated\nclasses; reserve inheritance for a genuine is-a hierarchy. Namespace with `module Foo`\nto avoid global constant clashes. Need to patch a class without polluting it globally?\nUse a **refinement** (`refine … using`) — a scoped, reversible scalpel — never a bare\nmonkey-patch. Full refinement scoping and `prepend`-wrapping in\n[references\u002Fmetaprogramming.md](references\u002Fmetaprogramming.md).\n\n## Value objects: Data vs Struct\n\n```ruby\n# frozen_string_literal: true\n\nPoint  = Data.define(:x, :y)         # immutable value object (Ruby 3.2+)\norigin = Point.new(x: 0, y: 0)       # no setters; with(x: 1) returns a copy\n\nCursor = Struct.new(:x, :y)          # mutable; has setters and is Enumerable\n```\n\n| Need                                       | Reach for     |\n|--------------------------------------------|---------------|\n| Immutable value with equality + `with`     | `Data.define` |\n| Mutable record, or array\u002Fpositional access | `Struct.new`  |\n\nDefault to `Data` for value semantics; pick `Struct` only when you genuinely need\nmutation or positional\u002F`to_a` behavior.\n\n## Metaprogramming, sparingly\n\nDecision rule, in order: **could a plain method, a `Struct`, or a `Data` do this?**\nIf yes, do that. Only when the method *names themselves* are dynamic (driven by data or\nconfig) does metaprogramming earn its keep.\n\n- Prefer `define_method` (defines real, introspectable methods) over `method_missing`\n  (intercepts at call time, slower, invisible to `respond_to?` and tooling).\n- If you *must* use `method_missing`, you **must** also define `respond_to_missing?` —\n  otherwise `respond_to?`, `method`, and duck-typing all lie about your object.\n- Never `eval` a string built from user input.\n\n```ruby\n# Good: dynamic method names, but real methods that introspect and document themselves.\nclass Config\n  def initialize(**data) = @data = data\n\n  %i[host port timeout].each do |key|\n    define_method(key)       { @data[key] }\n    define_method(\"#{key}=\") { |value| @data[key] = value }\n  end\nend\n```\n\nBuilding a real DSL, `instance_eval`\u002F`class_eval`, and the full\n`method_missing` + `respond_to_missing?` pairing live in\n[references\u002Fmetaprogramming.md](references\u002Fmetaprogramming.md).\n\n## Gems & Bundler\n\nBundler is the universal dependency manager. `bundle init` creates a `Gemfile`;\n`bundle install` resolves and writes `Gemfile.lock`; run project binaries with\n`bundle exec` so they use the locked versions.\n\n- Use the **pessimistic constraint** `~> 2.3` (allows `2.x >= 2.3`, blocks `3.0`) for\n  libraries; pin tighter only when forced.\n- **Commit `Gemfile.lock` for applications** (reproducible installs); for a *library*\n  gem, do not commit the lock — let consumers resolve.\n- Scaffold a gem with `bundle gem NAME`, which generates the `lib\u002F`, `test\u002F`\u002F`spec\u002F`,\n  `.gemspec`, and Rakefile layout.\n\n```ruby\n# my_gem.gemspec\nGem::Specification.new do |spec|\n  spec.name        = \"my_gem\"\n  spec.version     = MyGem::VERSION       # SemVer: MAJOR.MINOR.PATCH\n  spec.summary     = \"One-line description.\"\n  spec.authors     = [\"You\"]\n  spec.files       = Dir[\"lib\u002F**\u002F*.rb\"]\n  spec.required_ruby_version = \">= 3.4\"\n  spec.add_dependency \"thor\", \"~> 1.3\"\nend\n```\n\nFull `bundle gem` tree, publishing flow (`gem build` \u002F `gem push`), and Rake test tasks\nare in [references\u002Fgems-and-testing.md](references\u002Fgems-and-testing.md).\n\n## Ruby 4.0 \u002F 3.4 hygiene\n\n```ruby\n# frozen_string_literal: true     # without it, 3.4+ warns under -W:deprecated on mutation\n\nnums.map { it * 2 }               # `it` is the implicit single block param (3.4+)\nseen = Set.new([1, 2, 3])         # Set is a core class in 4.0 — no `require \"set\"`\n```\n\n- The magic comment freezes every string literal in the file; mutating one then raises\n  `FrozenError`. This is the cause of most \"my string froze after upgrading\" reports.\n- `it` reads cleaner than `_1` for one-arg blocks.\n- Ruby 4.0 ships **ZJIT** (a new JIT written in Rust, successor to YJIT) and removed\n  `Ractor.yield`\u002F`Ractor#take` in favor of `Ractor::Port`.\n\n## Testing\n\nBoth ship a clean path; choose by ceremony tolerance:\n\n| Framework | Pick when… |\n|-----------|-----------|\n| **Minitest** | You want the default — ships with Ruby, tiny surface, `assert`-style or spec-style, fast. |\n| **RSpec** | You want the expressive DSL and large ecosystem (`describe`\u002F`context`\u002F`it`\u002F`expect`, `let`, mocks). |\n\n```ruby\n# test\u002Ftally_test.rb  (Minitest)\nrequire \"minitest\u002Fautorun\"\nrequire \"tally\"\n\nclass TallyTest \u003C Minitest::Test\n  def test_counts_words\n    assert_equal({ \"a\" => 2, \"b\" => 1 }, Tally.count(\"a b a\"))\n  end\nend\n```\n\n```ruby\n# spec\u002Ftally_spec.rb  (RSpec)\nRSpec.describe Tally do\n  subject(:counts) { described_class.count(\"a b a\") }\n  it { is_expected.to eq(\"a\" => 2, \"b\" => 1) }\nend\n```\n\nRun via `bundle exec rake test` (Minitest) or `bundle exec rspec` (RSpec). Fuller\nexamples with `let`\u002F`subject`\u002F`context` are in\n[references\u002Fgems-and-testing.md](references\u002Fgems-and-testing.md).\n\n## Linting & typing (optional layers)\n\n- **Linter:** Standard (zero-config, \"no bikeshadding\" wrapper) when you want one less\n  argument; RuboCop (`.rubocop.yml`, every cop opt-in\u002Fout) when the team wants control.\n- **Types:** two coexisting systems — **RBS** (official signatures in separate `.rbs`\n  files, checked by Steep) and **Sorbet** (inline `sig` blocks, with experimental\n  inline-RBS-comment support). Add types only on a library's public surface or a hot,\n  bug-prone core — not on throwaway scripts. RuboCop vs Standard config sits in\n  [references\u002Fgems-and-testing.md](references\u002Fgems-and-testing.md).\n\n## Anti-patterns\n\n| Anti-pattern | Why it bites | Do instead |\n|--------------|--------------|------------|\n| Monkey-patching a core class globally | Action-at-a-distance; collides with gems and future Ruby | A refinement (scoped) or a wrapper\u002Fhelper |\n| `method_missing` without `respond_to_missing?` | `respond_to?`\u002F`method`\u002Fduck-typing all lie | Pair them, or prefer `define_method` |\n| Mutating a frozen string literal | `FrozenError` after the magic comment | `dup` before mutating, or build a new string |\n| `for x in coll` loops | Leaks the loop var; un-idiomatic | `coll.each`\u002F`map`\u002F`select` |\n| `rescue Exception` (bare) | Swallows `SignalException`, `NoMemoryError`, exit | `rescue StandardError` (or specific classes) |\n| Not committing `Gemfile.lock` for an app | Non-reproducible installs across machines | Commit it for apps; omit only for library gems |\n| `eval` of user-derived input | Remote code execution | Parse explicitly; never `eval` untrusted data |\n| Over-DSLing config a Hash would serve | Hidden control flow, slow `method_missing` | A plain Hash or `Data` object |\n",{"name":5,"tags":24,"origin":31,"profiles":32,"recommends":33,"description":7},[5,25,26,27,28,29,30],"gems","bundler","metaprogramming","rspec","minitest","enumerable","risco",[],[34,35,36],"rails","testing-web","secure-coding","main","d69096e239f2a89aabc2cd078c47664a9d3b1e11","05-技能与代理开发\u002Fruby",3,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts","https:\u002F\u002Fgithub.com\u002Flza6","个人vx：Tf00798\r\n个人✈：@TFGY999","2026-10-08 14:29:22",{"source":8,"skillName":5,"commands":46,"prompt":56,"zipAvailable":57},[47,50,53],{"tool":48,"command":49},"npx","npx skills add lza6\u002FArmor-piercing-system-prompts --skill ruby",{"tool":51,"command":52},"bunx","bunx skills add lza6\u002FArmor-piercing-system-prompts --skill ruby",{"tool":54,"command":55},"pnpm","pnpm dlx skills add lza6\u002FArmor-piercing-system-prompts --skill ruby","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F05-技能与代理开发\u002Fruby\u002FSKILL.md",true,[59,65,69,73],{"path":60,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":63,"sourceHtmlUrl":64},"evals\u002Fcases.yaml","REFERENCE","参考文档",2837,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F05-技能与代理开发\u002Fruby\u002Fevals\u002Fcases.yaml",{"path":66,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":67,"sourceHtmlUrl":68},"evals\u002FREADME.md",878,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F05-技能与代理开发\u002Fruby\u002Fevals\u002FREADME.md",{"path":70,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":71,"sourceHtmlUrl":72},"references\u002Fgems-and-testing.md",5380,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F05-技能与代理开发\u002Fruby\u002Freferences\u002Fgems-and-testing.md",{"path":74,"resourceType":61,"resourceTypeDesc":62,"sizeBytes":75,"sourceHtmlUrl":76},"references\u002Fmetaprogramming.md",5309,"https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F05-技能与代理开发\u002Fruby\u002Freferences\u002Fmetaprogramming.md",[78,85,90,97,104,111],{"skillNo":79,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":82,"categories":83,"keywords":84,"publishedAt":19},"01M7FFG485KY83TD6HSC4YPCMC","obsidian-clipper-template-creator","Guide for creating templates for the Obsidian Web Clipper. Use when you want to create a new clipping template, understand available variables, or format clipped content.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator\u002FSKILL.md",[],[],{"skillNo":86,"name":80,"nameZh":6,"description":81,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M7FFG0T6AZ0STEJPSB3CX84K","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobsidian-clipper-template-creator-antigravity-awesome-skills-main\u002FSKILL.md",[],[],{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M7FFFY0QEM14SKWPDYGMXM2P","python-api","Programmatic Object-Detection-Metrics API guidance for BoundingBox, BoundingBoxes, Evaluator, enums, coordinate conversion, AP\u002FmAP semantics, and source-style import diagnostics.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Fpython-api\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":19},"01M7FFFVZQZ2GJ0C0TGP7JHD20","file-evaluation","Folder-based PASCAL VOC AP\u002FmAP evaluation from ground-truth and detection text files.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002Fsub-skills\u002Ffile-evaluation\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":19},"01M7FFFSFNYSE77SJ6PE1CK2DA","object-detection-metrics","Guides legacy Object-Detection-Metrics PASCAL VOC AP\u002FmAP evaluation from detection text folders and direct Python API classes.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fobject-detection-metrics\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":19},"01M7FFFP0GCK1RVXBCPQ8APBMT","nx-workspace-patterns","Configure and optimize Nx monorepo workspaces. Use when setting up Nx, configuring project boundaries, optimizing build caching, or implementing affected commands.","https:\u002F\u002Fgithub.com\u002Flza6\u002FArmor-piercing-system-prompts\u002Fblob\u002Fmain\u002F07-后端与架构\u002Fnx-workspace-patterns\u002FSKILL.md",[],[]]