~ことだ (advice)
Give direct advice about what someone should do
You’ll be able to state a recommended action concisely, especially when presenting guidance or a solution.

安全に山道を運転したければ、スピードを落としてゆっくり走ることだ。
anzen ni yamamichi o unten shitakereba, supiido o otoshite yukkuri hashiru koto da.
What do you think this sentence means?
If you want to drive mountain roads safely, the best thing is to reduce speed and drive slowly.
Advise the best course of action
~ことだ is used to give direct personal advice or guidance ("you should...", "the best thing is to..."). It recommends an effective action or cautions against an unwise one.
疲れたときは、よく休むことだ。
tsukareta toki wa, yoku yasumu koto da.
When you are tired, the best thing is to rest well.
試験に合格したいなら、毎日少しずつ勉強することだ。
shiken ni goukaku shitai nara, mainichi sukoshi zutsu benkyou suru koto da.
If you want to pass the exam, the best thing is to study a little every day.
Attach ことだ to plain verbs
Attach ことだ directly to the dictionary form or ない-form of a verb. It is used to advise someone directly about what they should or should not do in a situation.
風邪を早く治したければ、温かくしてよく寝ることだ。
kaze o hayaku naoshitakereba, atatakaku shite yoku neru koto da.
If you want to recover from a cold quickly, you should keep warm and sleep well.
~べきだ vs ~ことだ
~べきだ says what is right or expected of everyone. ~ことだ gives personal advice: if you want a result, this is the best way to get it.
~べきだ, you ought to (it’s proper)
困っているなら、先生に聞くべきだ。
komatte iru nara, sensei ni kiku beki da.
If you're stuck, you ought to ask your teacher.
It is the proper thing to do.
~ことだ, the best thing is to
困っているなら、先生に聞くことだ。
komatte iru nara, sensei ni kiku koto da.
If you're stuck, the best thing is to ask your teacher.
The best way to solve it.
肩こりを治したければ、毎日少しずつ体を動かすことだ。
katakori o naoshitakereba, mainichi sukoshi zutsu karada o ugokasu koto da.
If you want to get rid of stiff shoulders, the best thing is to move your body a little every day.
早く仕事に慣れたいなら、分からないことをそのままにしないことだ。
hayaku shigoto ni naretai nara, wakaranai koto o sono mama ni shinai koto da.
If you want to get used to the job quickly, don’t leave things you don’t understand as they are.
お金をためたければ、まず毎月何にいくら使っているか書いてみることだ。
okane o tametakereba, mazu maitsuki nani ni ikura tsukatte iru ka kaite miru koto da.
If you want to save money, first try writing down how much you spend on what each month.
7 more examples in the grammar path — free for a limited time.