Skip to content

[infra] Agent skill: Apply dot shorthands#3164

Merged
dcharkes merged 1 commit intomainfrom
agent-skill-dot-shorthands
Feb 27, 2026
Merged

[infra] Agent skill: Apply dot shorthands#3164
dcharkes merged 1 commit intomainfrom
agent-skill-dot-shorthands

Conversation

@dcharkes
Copy link
Collaborator

To play around with it start your favorite agent. The skills in the .agent/ directory are automatically picked up by multiple agents.

Base automatically changed from infra-bump-api-tool to main February 26, 2026 11:50
@dcharkes dcharkes force-pushed the agent-skill-dot-shorthands branch from e24d40c to 92a5d61 Compare February 26, 2026 11:50
super.language = Language.c,
```

Only do the refactoring if the contains the type modulo spacing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this sentence missing a word or something?


```dart
// After
super.language = Language.c,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why wouldn't this be super.language = .c,?

@dcharkes dcharkes force-pushed the agent-skill-dot-shorthands branch from 92a5d61 to 5408f0e Compare February 26, 2026 15:24
@dcharkes dcharkes force-pushed the agent-skill-dot-shorthands branch from 5408f0e to f3aacae Compare February 26, 2026 16:06
@dcharkes dcharkes requested a review from goderbauer February 26, 2026 16:09
@dcharkes dcharkes changed the title [infra] Apply dot shorthands agent skill [infra] Agent skill: Apply dot shorthands Feb 26, 2026
Copy link
Contributor

@liamappelbe liamappelbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My comments are all based on hand wavy notions of how LLMs think, so YMMV


Apply Dart 3.7+ dot shorthands (member access shorthands) to simplify code where the context type is already known.

## Constraints
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried giving it a list of when it is allowed to use dot shorthands, rather than when it isn't? And just give it a blanket "Never use dot shorthands other than these approved cases...". Seems like you're playing whack-a-mole with the possible mistakes the AI can make here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I was hoping to get more creativity out of the LLM, in cases I hadn't thought about.

super.language = .c,
```

Only do the refactoring if the receiver or parameter name contains the type modulo spacing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This use of "modulo" is suuuuuper SWE specific. I wonder if it might confuse an AI trained on ordinary language.

```

```dart
// After, bad. (Type not clear from 'type' parameter)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My working model is that AIs have the reading-comprehension of a really sleepy human. I'd distinguish this case more than just a single "bad" here. Like, you could put negative examples in a separate heading. Or just update this comment to say in 3 different ways that this is a bad example.

// NEGATIVE EXAMPLE
// After (bad, don't do this).
super(type: .library);  // BAD: Type unclear from param name

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've run the skill a couple of times, and I don't think this is necessary.

super(outputType: .library);
```

However, only do this if the code quality doesn't suffer.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vague?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this seems to work. After adding this its behavior changed and when I ask it to explain why certain refactorings were done or not it referred to this.


### Collections and Lists

Maintain multiline formatting for better readability.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I assumed the formatter overrides whatever we do here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we have turned on

formatter:
  trailing_commas: preserve

So, the last comma matters.

* Create a temporary markdown file (e.g., `SHORTHAND_PROGRESS.md`) containing a checklist of all files.
3. **Iterative Refactoring**: Work through the files in small batches (1-3 files):
* **Identify**: Search for shorthand opportunities within the files that meet the **Constraints**.
* **Apply**: Replace `TypeName.memberName` with `.memberName`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've heard that these AIs do better if you ask them to criticise their own work. You could try adding a step here like: Review: Reread your change with fresh eyes, and make sure it matches the constraints. Revert if it makes the code unclear.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, but I want it to not do the change, make it work, and then revert things again. I want it to think before doing the change.

My hunch is that your suggestion might work slightly better but be significantly slower. I guess we'd need "evals" to check that. I've just been running it locally and look at the diff between runs manually.

Copy link
Contributor

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good starting point to iterate on. LGTM

@dcharkes dcharkes merged commit b2ec0d5 into main Feb 27, 2026
9 checks passed
@dcharkes dcharkes deleted the agent-skill-dot-shorthands branch February 27, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants