Skip to content
Back to skills

Pharo Coding

ASecurity

Write, review or refactor Pharo code the way Pharo does it, whichever tool edits it: messages over type checks, nil, fused collection messages, initialization, selectors, extensions and tests. Use when writing or changing Pharo code and the project has no coding guidance of its own.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 4, 2026
ai-agentsexpressrefactoringapi

Works with

  • api
  • mcp

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned December 4, 2026

npx -y skills add Evref-BL/pharo-agent-plugin --skill pharo-coding --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pharo Coding?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Pharo Coding
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/evref-bl-pharo-coding/badge)](https://www.skillsdirectory.com/skills/evref-bl-pharo-coding)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: pharo-coding
description: Write, review or refactor Pharo code the way Pharo does it, whichever tool edits it: messages over type checks, nil, fused collection messages, initialization, selectors, extensions and tests. Use when writing or changing Pharo code and the project has no coding guidance of its own.
---

# Pharo Coding

What is particular to Pharo, for writing, reviewing or refactoring its code
with whatever tool is at hand: through MCP, through a source projection, or in
the files themselves.

General programming practice is not repeated here, and neither are the smells a
rule recognises: Pharo's own critiques report those.

## Dispatch Over Inspection

Pharo code communicates through messages and protocols. Send a domain message
to the receiver, or add the protocol to the object that owns the behavior,
rather than asking what the receiver is.

The reflective escapes are not equally defensible:

- `respondsTo:` as control flow is almost never right. It asks whether a send
  would work instead of sending it. Keep it for genuinely reflexive code that
  reads a protocol as data.
- `isKindOf:` and `isMemberOf:` are fine where a type really must be checked
  and nothing else can say it, such as a boundary receiving foreign objects.
- `perform:` is fine where the selector is data rather than a disguised
  switch, such as turning a transport message into a send.
- `class = ...`, method dictionary and instance-variable reflection belong to
  tools, proxies and compatibility shims.

Keep reflective behavior isolated and named as tooling or boundary behavior;
do not spread it through ordinary domain logic.

## The Main Send

A Pharo conditional is an expression, so the send can stand outside it. When
both branches perform the same operation, lift it out and let the conditional
answer only the receiver or argument that varies.

```smalltalk
result := self transform: (condition ifTrue: [ selectedValue ])
```

This applies to return expressions, assigned values, message arguments, and
nested expressions.

## Nil

- Use `ifNotNil:` for local nil traversal when a boundary API can genuinely
  return `nil` and the next step is asking the non-nil object for a value.
- Keep simple boolean predicates simple. Expressions such as
  `value isNotNil and: [ value isReady ]` are idiomatic when the result is a
  boolean. Do not rewrite them into `ifNil:`/`ifNotNil:` only to return a
  boolean literal from one branch.

## Intermediate Objects

A step that builds a collection or a string only to hand it to the next step
allocates something nobody asked for. Pharo's fused messages exist for that:
`collect:as:` rather than `collect:` and a conversion, `select:thenDo:` rather
than a filtered copy to iterate over, `String streamContents:` rather than a
chain of `,`, where every comma copies everything to its left.

Sorting is the usual case. `sort` and `sort:` sort a `SequenceableCollection`
in place; `sorted` and `sorted:` leave the receiver alone and answer a sorted
copy. Neither needs a `SortedCollection`, which earns its keep only when a
collection must *stay* sorted as things are added to it — not for sorting
something once.

## Initialization

- Initialize sensible defaults in `initialize`.
- Do not redefine class-side `new` just to call `initialize`.
- Use class-side creation messages such as `on:`, `with:`, or domain-specific
  constructors when required data exists.
- Use `basicNew` only when deliberately bypassing initialization.

## Selectors

- The getter selector is the variable name; the setter selector is `name:`.
  Not `getName` or `setName:`.
- Predicates read as predicates: `isReady`, `hasErrors`, `canHandle:`.
- Action selectors use verbs: `parseRequest:`, `addTool:`, `writeResponseOn:`.
- Conversion selectors start with `as`.

## Collections

- Prefer collection protocol such as `collect:`, `select:`, `reject:`,
  `detect:ifNone:`, `inject:into:`, `anySatisfy:`, and `allSatisfy:`.
- Do not mutate a collection while iterating it unless iterating a copy is
  intentional.
- Do not rely on `add:` answering the collection; use a variable, or cascade
  with `yourself`.

## Class Extensions

Be conservative with extensions on broad system classes such as `Object`,
`Behavior`, `String`, or `Exception`. They should model a real boundary
protocol, not hypothetical defense against wrong callers.

## Tests

- Use `assert:equals:` for comparisons, and `deny:` for negative assertions.
- Use `should:raise:` and `shouldnt:raise:` with blocks for exception
  behavior.
- Use memory filesystems, fakes, or injected collaborators where a unit test
  would otherwise reach outside the image.
- Keep live-image and external-state tests separate from source-only checks.

Files in this skill

  • SKILL.md4.6 KB
  • agents/openai.yaml182 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.